u/Otherwise-Pear2054

▲ 2 r/raylib+1 crossposts

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.

https://preview.redd.it/5plfv6kkhbbh1.png?width=804&format=png&auto=webp&s=6d1a6479e6b6c142f7c58572afd62bc904557ba8

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: Now im using textures to draw the pixels to the screen instead of drawing them using DrawRectangle, but it still doesnt work.

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

reddit.com
u/Otherwise-Pear2054 — 24 hours 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.

https://preview.redd.it/5plfv6kkhbbh1.png?width=804&format=png&auto=webp&s=6d1a6479e6b6c142f7c58572afd62bc904557ba8

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?

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

https://pastebin.com/1GMFA2iU

The header file:

https://pastebin.com/mXnGrLwK

reddit.com
u/Otherwise-Pear2054 — 1 day ago