shaders headerfile, and added CRTP shader to Point
This commit is contained in:
+4
-2
@@ -39,11 +39,13 @@ int main(void) {
|
|||||||
UwU::Surface surface = UwU::Surface(w, h, onKey);
|
UwU::Surface surface = UwU::Surface(w, h, onKey);
|
||||||
|
|
||||||
UwU::ColorShader fuchsia = UwU::ColorShader(UwU::Color(0xb00b69ff));
|
UwU::ColorShader fuchsia = UwU::ColorShader(UwU::Color(0xb00b69ff));
|
||||||
|
|
||||||
UwU::Rectangle rectangle = UwU::Rectangle(69, 69, 420, 420);
|
UwU::Rectangle rectangle = UwU::Rectangle(69, 69, 420, 420);
|
||||||
|
|
||||||
rectangle.draw(surface.buffer, fuchsia);
|
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
|
// // Benchmarking
|
||||||
// struct timespec start, end;
|
// struct timespec start, end;
|
||||||
// const int WARMUP = 100;
|
// const int WARMUP = 100;
|
||||||
|
|||||||
+5
-16
@@ -5,7 +5,7 @@
|
|||||||
#include "../datatypes.cpp"
|
#include "../datatypes.cpp"
|
||||||
#include "../helpers.cpp"
|
#include "../helpers.cpp"
|
||||||
#include "../buffer.cpp"
|
#include "../buffer.cpp"
|
||||||
#include "../shader.cpp"
|
#include "../shaders/shaders.h"
|
||||||
|
|
||||||
namespace UwU {
|
namespace UwU {
|
||||||
// point
|
// point
|
||||||
@@ -19,22 +19,11 @@ namespace UwU {
|
|||||||
uint16_t x;
|
uint16_t x;
|
||||||
uint16_t y;
|
uint16_t y;
|
||||||
|
|
||||||
// Draw a rectangle
|
// Draw a point
|
||||||
void draw (Buffer buffer, Shader shader) {
|
template <class ShaderT>
|
||||||
|
void draw (Buffer buffer, ShaderBase<ShaderT>& shader) {
|
||||||
if (x > buffer.width || y > buffer.height) {return;};
|
if (x > buffer.width || y > buffer.height) {return;};
|
||||||
|
buffer.drawPixel(x, y, shader.shade(x, y));
|
||||||
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));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "../helpers.cpp"
|
#include "../helpers.cpp"
|
||||||
#include "../buffer.cpp"
|
#include "../buffer.cpp"
|
||||||
#include "../shaders/shaderbase.cpp"
|
#include "../shaders/shaderbase.cpp"
|
||||||
#include "../shaders/colorshader.cpp"
|
#include "../shaders/shaders.h"
|
||||||
|
|
||||||
namespace UwU {
|
namespace UwU {
|
||||||
// rectangle
|
// rectangle
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#include "shaderbase.cpp"
|
||||||
|
#include "colorshader.cpp"
|
||||||
|
// #include "hgradientshader.cpp"
|
||||||
|
// #include "vgradientshader.cpp"
|
||||||
Reference in New Issue
Block a user