Problem updating a texture using SDL_Renderer


Hi, I’m writing a software renderer for learning purposes, and I chose SDL to display the rendered frames. To do it, I have a SDL_Renderer to which I render a fullscreen SDL_Texture containing the frame pixel data.

I have a function that draws a line into the frame buffer, and I thought that it was working fine until I tried to swap lines to see if it updated correctly, but it doesn’t, it just displays the first thing I wrote to the framebuffer. I’ve been trying things for two days without success, and I don’t know where the problem could be. This is the link to the code Software Renderer

This is the frame correctly rendered (Just one green line), if I press space it should draw a different blue one, but it doesn’t.


I tested this on my system (Mac running MacOS 10.14.4) with SDL 2.0.9 and it worked fine. Pressing space switches between the green and blue line.

Not very helpful but it seems the problem is probably not your code.

As an aside, if you’re going to use a streaming texture, use SDL_LockTexture() and SDL_UnlockTexture() instead of SDL_UpdateTexture(). It’s faster, and won’t require you to keep your own memory buffer around.


Thanks a lot for you time, I’ll try to test it in another system as well. Also, thanks for the advice on the texture stuff.