moved textures into their own classes, better tilemapping

This commit is contained in:
2026-07-25 23:47:54 -07:00
parent e6ce80ce13
commit 1c2579148e
19 changed files with 277 additions and 56 deletions
+4 -4
View File
@@ -6,8 +6,8 @@
#include "../datatypes.cpp"
#include "../helpers.cpp"
#include "../buffer.cpp"
#include "../shaders/shaders.h"
#include "../mappers/mappers.h"
#include "../textures/textures.h"
namespace UwU {
// trapezoid (horizontally constrained)
@@ -31,8 +31,8 @@ namespace UwU {
// Draw a horizontally bounded trapezoid
// y1 >= y0
template <class MapperT, class ShaderT>
void draw (Buffer buffer, MapperBase<MapperT>& mapper, ShaderBase<ShaderT>& shader) {
template <class MapperT, class TextureT>
void draw (Buffer buffer, MapperBase<MapperT>& mapper, TextureBase<TextureT>& texture) {
uint16_t height = 1 + y1 - y0;
int16_t LeftBound[height];
int16_t RightBound[height];
@@ -45,7 +45,7 @@ namespace UwU {
for (uint16_t i = 0; i < height; i++) {
for (uint16_t x = LeftBound[i]; x <= RightBound[i]; x++) {
Coord2 uv = mapper.map(x0, y0, x, i + y0);
buffer.drawPixel(x, i + y0, shader.shade(uv.x, uv.y));
buffer.drawPixel(x, i + y0, texture.texel(uv.x, uv.y));
}
}
return;