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
+18 -18
View File
@@ -16,7 +16,7 @@
// #include "primatives/rectangle.cpp"
// #include "primatives/trapezoid.cpp"
// #include "primatives/triangle.cpp"
// #include "shader.cpp"
// #include "Texture.cpp"
#include "uwugl.h"
#include <time.h>
@@ -43,31 +43,31 @@ int main(void) {
UwU::Color green = UwU::Color(0x00ff00ff);
UwU::Color blue = UwU::Color(0x0000ffff);
// UwU::ColorShader fuchsia = UwU::ColorShader(UwU::Color(0xb00b69ff));
UwU::HGradientShader bisexual = UwU::HGradientShader(0, 179, red, blue);
UwU::TileMapper tileMapper = UwU::TileMapper();
// UwU::ColorTexture fuchsia = UwU::ColorTexture(UwU::Color(0xb00b69ff));
UwU::HGradientTexture bisexual = UwU::HGradientTexture(180, red, blue);
UwU::OffsetMapper offsetMapper = UwU::OffsetMapper();
UwU::Tilemap myTilemap = UwU::Tilemap();
myTilemap.tilemap[0] = 0x0000;
myTilemap.tilemap[1] = 0x0001;
myTilemap.tilemap[2] = 0x0000;
myTilemap.tilemap[3] = 0x0002;
myTilemap.tilemap[4] = 0x0003;
UwU::Buffer fontBuffer = font();
UwU::BufferShader textMap = UwU::BufferShader(fontBuffer);
tileMapper.tileMap[0] = 0x0000;
tileMapper.tileMap[1] = 0x0111;
tileMapper.tileMap[2] = 0x0000;
tileMapper.tileMap[3] = 0x0222;
tileMapper.tileMap[4] = 0x0333;
UwU::TilemapTexture textMap = UwU::TilemapTexture(myTilemap, fontBuffer);
UwU::Rectangle rectangle = UwU::Rectangle(69, 69, 420, 420);
rectangle.draw(surface.buffer, tileMapper, textMap);
rectangle.draw(surface.buffer, offsetMapper, textMap);
UwU::ColorShader greenShader = UwU::ColorShader(green);
UwU::ColorTexture greenTexture = UwU::ColorTexture(green);
UwU::NullMapper nullMapper = UwU::NullMapper();
UwU::Point point = UwU::Point(187, 37);
point.draw(surface.buffer, nullMapper, greenShader);
point.draw(surface.buffer, nullMapper, greenTexture);
UwU::ColorShader blueShader = UwU::ColorShader(blue);
UwU::ColorTexture blueTexture = UwU::ColorTexture(blue);
UwU::Trapezoid trapezoid = UwU::Trapezoid(100, 300, 690, 320, 720, 780);
trapezoid.draw(surface.buffer, nullMapper, blueShader);
trapezoid.draw(surface.buffer, nullMapper, blueTexture);
UwU::ColorShader redShader = UwU::ColorShader(red);
UwU::ColorTexture redTexture = UwU::ColorTexture(red);
UwU::Triangle triangle = UwU::Triangle(140, 140, 60, 400, 240, 240);
UwU::OffsetMapper offsetMapper = UwU::OffsetMapper();
triangle.draw(surface.buffer, offsetMapper, bisexual);
// // Benchmarking
@@ -109,7 +109,7 @@ int main(void) {
};
for (uint16_t i = 0; i < 8; i++) {
lines[i].draw(surface.buffer, nullMapper, blueShader);
lines[i].draw(surface.buffer, nullMapper, blueTexture);
}