added mappers to rest of primatives

This commit is contained in:
2026-07-24 18:31:49 -07:00
parent 78ec985f7a
commit eddbb85256
6 changed files with 49 additions and 33 deletions
+5 -3
View File
@@ -7,6 +7,7 @@
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "../shaders/shaders.h"
#include "../mappers/mappers.h"
namespace UwU {
// trapezoid (horizontally constrained)
@@ -30,8 +31,8 @@ namespace UwU {
// Draw a horizontally bounded trapezoid
// y1 >= y0
template <class ShaderT>
void draw (Buffer buffer, ShaderBase<ShaderT>& shader) {
template <class MapperT, class ShaderT>
void draw (Buffer buffer, MapperBase<MapperT>& mapper, ShaderBase<ShaderT>& shader) {
uint16_t height = 1 + y1 - y0;
int16_t LeftBound[height];
int16_t RightBound[height];
@@ -41,7 +42,8 @@ namespace UwU {
for (uint16_t i = 0; i < height; i++) {
for (uint16_t x = LeftBound[i]; x <= RightBound[i]; x++) {
buffer.drawPixel(x, i + y0, shader.shade(x, i + y0));
Coord2 uv = mapper.map(x, i + y0);
buffer.drawPixel(x, i + y0, shader.shade(uv.x, uv.y));
}
}
return;