feat: switched to qt and refactored

This commit is contained in:
2025-11-12 10:41:40 +01:00
parent adafae2d84
commit e9e4eed79b
3 changed files with 124 additions and 14 deletions

42
renderer.hpp Normal file
View File

@@ -0,0 +1,42 @@
#ifndef RENDERER_H
#define RENDERER_H
#include "fastmath.hpp"
#include "polygon.hpp"
#include "rendertarget.hpp"
#include <memory.h>
class Renderer {
public:
Rendertarget *target;
bool clearTarget = true;
Renderer() : clearTarget(false) {}
void render(polygon *p) {
decimal widthScale = decimal(1.0) / decimal((float)target->width);
decimal heightScale = decimal(1.0) / decimal((float)target->height);
// std::cout << widthScale << std::endl;
vec3 pos = vec3();
if (clearTarget) {
memset((wchar_t *)target->pixels, 0,
target->height * target->width * sizeof(target[0]));
}
for (int x = 0; x < target->height; x++) {
for (int y = 0; y < target->height; y++) {
if (p->contains(pos)) {
target->set(x, y, vec3(0.0, 255.0, 0.0));
}
pos.y() += heightScale;
}
pos.y() = decimal(0);
pos.x() += widthScale;
}
}
};
#endif