Save to file

This commit is contained in:
NukeBird 2025-02-12 16:26:59 +03:00
parent a4727881c5
commit 4b56e3fa71

View file

@ -40,7 +40,7 @@ struct kdtree
void draw() void draw()
{ {
DrawRectangleLines(aabb_min.x, aabb_min.y, aabb_size.x, aabb_size.y, BLACK); DrawRectangleLines(aabb_min.x, aabb_min.y, aabb_size.x, aabb_size.y, WHITE);
if(left && right) if(left && right)
{ {
left->draw(); left->draw();
@ -75,6 +75,7 @@ int main (int argc, char *argv[])
std::vector<glm::uvec2> pts; std::vector<glm::uvec2> pts;
for (int i = 0; i < img.width * img.height; ++i) for (int i = 0; i < img.width * img.height; ++i)
{ {
int x = i % img.width; int x = i % img.width;
@ -115,13 +116,16 @@ int main (int argc, char *argv[])
kdtree tree(pts); kdtree tree(pts);
while (!WindowShouldClose()) auto target = LoadRenderTexture(img.width, img.height);
{
BeginDrawing(); BeginTextureMode(target);
ClearBackground(WHITE); ClearBackground(BLACK);
tree.draw(); tree.draw();
EndDrawing(); EndTextureMode();
}
auto t = LoadImageFromTexture(target.texture);
ImageFlipVertical(&t);
ExportImage(t, "test.jpg");
CloseWindow(); CloseWindow();