implemented shaders, gradients, and uv mapping
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "../shaders/shader.cpp"
|
||||
#include "../shaders/colorshader.cpp"
|
||||
#include "../shaders/gradientshader.cpp"
|
||||
#include "../mapper.cpp"
|
||||
|
||||
namespace UwU {
|
||||
// rectangle
|
||||
@@ -24,11 +27,14 @@ namespace UwU {
|
||||
uint16_t y1;
|
||||
|
||||
// Draw a rectangle
|
||||
void draw (Buffer buffer, Shader shader) {
|
||||
void draw (Buffer buffer, Mapper mapper, Shader& shader) {
|
||||
// printf("color: %u, %u, %u, %u", shader.color().r, shader.color().g, shader.color().b, shader.color().a);
|
||||
if (x0 > buffer.width || y0 > buffer.height || x1 > buffer.width || y1 > buffer.height) {return;};
|
||||
Coord2 uv = Coord2();
|
||||
for (uint16_t y = y0; y < y1; y++) {
|
||||
for (uint16_t x = x0; x < x1; x++) {
|
||||
buffer.drawPixelShader(Coord2(x, y), shader);
|
||||
uv = mapper.map(Coord2(x, y));
|
||||
buffer.drawPixelShader(x, y, uv.x, uv.y, shader);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user