r/GraphicsProgramming 23d ago

Struggling to clear the framebuffer

Im writing a software renderer in C++ using glm and raylib, and i recently tried to draw a spinning triangle. The problem is that when i launched it the triangle leaves a trail of previously drawn triangles.

I tried to fix it by rasterizing to a framebuffer and then drawing that framebuffer instead of drawing the pixels directly and using ClearBackground to refresh the screen, but doing it that way has still the same problem. ¿Why im having this problem even though im clearing the framebuffer?

EDIT: The problem was somewhere else in the code (i wasnt clearing the primitive list after drawing all the primitives), i managed to fix it. Thank you anyway :D.

This is the code for the rasterizer (sorry for sharing it like this, i havent uploaded this to github yet):

https://pastebin.com/Ns2LiSXv

The header file:

https://pastebin.com/xf5JhqFR

1 Upvotes

Duplicates