Is SDL Render to Texture advisable?

Dear Everyone,

As a new SDL user, in particular, an SDL3 user, I was wondering if someone could possible give me some advice.

I am writing a program to render fractals using SDL3.

Currently I’m using SDL3 functions for writing pixels and I am not using OpenGL shaders etc.

The problem I have is that as I write each horizonal line of pixels as I go through the fractal generation process, when I perform a page flip, the back buffer gets erased and consequently, as the fractal is rendered, I miss every second horizontal line.

Am I right in presuming the workaround for this is to render to a texture, and then perform the ‘RenderPresent’ function?

If I am right, if someone could please advise as to the best way to do this, I’d be most grateful.

Thanks for your help in advance.

Kind regards,

Ashley Farnham

Not sure why you render before you have drawn the whole fractal but if you want what you have drawn to persist after calling SDL_RenderPresent then rendering to a texture is indeed the way to accomplish that. The only other alternative I can think of is to rerender everything that you had rendered previously plus the new stuff.

1 Like

Exactly, but it’s not a workaround, it’s simply the correct solution.

2 Likes