shaders headerfile, and added CRTP shader to Point
This commit is contained in:
+4
-2
@@ -39,10 +39,12 @@ int main(void) {
|
||||
UwU::Surface surface = UwU::Surface(w, h, onKey);
|
||||
|
||||
UwU::ColorShader fuchsia = UwU::ColorShader(UwU::Color(0xb00b69ff));
|
||||
|
||||
UwU::Rectangle rectangle = UwU::Rectangle(69, 69, 420, 420);
|
||||
|
||||
rectangle.draw(surface.buffer, fuchsia);
|
||||
|
||||
UwU::ColorShader green = UwU::ColorShader(UwU::Color(0x00ff00ff));
|
||||
UwU::Point point = UwU::Point(187, 37);
|
||||
point.draw(surface.buffer, green);
|
||||
|
||||
// // Benchmarking
|
||||
// struct timespec start, end;
|
||||
|
||||
+5
-16
@@ -5,7 +5,7 @@
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "../shader.cpp"
|
||||
#include "../shaders/shaders.h"
|
||||
|
||||
namespace UwU {
|
||||
// point
|
||||
@@ -19,22 +19,11 @@ namespace UwU {
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
|
||||
// Draw a rectangle
|
||||
void draw (Buffer buffer, Shader shader) {
|
||||
// Draw a point
|
||||
template <class ShaderT>
|
||||
void draw (Buffer buffer, ShaderBase<ShaderT>& shader) {
|
||||
if (x > buffer.width || y > buffer.height) {return;};
|
||||
|
||||
if (shader.shaderType == COLOR) {
|
||||
buffer.drawPixel(x, y, shader.c0);
|
||||
return;
|
||||
} else if (shader.shaderType == HGRADIENT) {
|
||||
buffer.drawPixel(x, y, ShaderMethods::gradient(shader.u0, shader.scale, shader.c0, shader.c1, x));
|
||||
return;
|
||||
} else if (shader.shaderType == VGRADIENT) {
|
||||
buffer.drawPixel(x, y, ShaderMethods::gradient(shader.v0, shader.scale, shader.c0, shader.c1, y));
|
||||
return;
|
||||
} else if (shader.shaderType == BUFFER) {
|
||||
buffer.drawPixel(x, y, ShaderMethods::buffer(shader.u0, shader.v0, shader.buffer, x, y));
|
||||
}
|
||||
buffer.drawPixel(x, y, shader.shade(x, y));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "../shaders/shaderbase.cpp"
|
||||
#include "../shaders/colorshader.cpp"
|
||||
#include "../shaders/shaders.h"
|
||||
|
||||
namespace UwU {
|
||||
// rectangle
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "shaderbase.cpp"
|
||||
#include "colorshader.cpp"
|
||||
// #include "hgradientshader.cpp"
|
||||
// #include "vgradientshader.cpp"
|
||||
Reference in New Issue
Block a user