added basic mappers

This commit is contained in:
2026-07-24 18:01:59 -07:00
parent c7cdfd402e
commit a89ef52247
10 changed files with 127 additions and 20 deletions
+5 -4
View File
@@ -5,8 +5,8 @@
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "../shaders/shaderbase.cpp"
#include "../shaders/shaders.h"
#include "../mappers/mappers.h"
namespace UwU {
// rectangle
@@ -25,12 +25,13 @@ namespace UwU {
uint16_t y1;
// Draw a rectangle
template <class ShaderT>
void draw (Buffer buffer, ShaderBase<ShaderT>& shader) {
template <class ShaderT, class MapperT>
void draw (Buffer buffer, MapperBase<MapperT>& mapper, ShaderBase<ShaderT>& shader) {
if (x0 > buffer.width || y0 > buffer.height || x1 > buffer.width || y1 > buffer.height) {return;};
for (uint16_t y = y0; y <= y1; y++) {
for (uint16_t x = x0; x <= x1; x++) {
buffer.drawPixel(x, y, shader.shade(x, y));
Coord2 uv = mapper.map(x, y);
buffer.drawPixel(x, y, shader.shade(uv.x, uv.y));
}
}
return;