I have a SDL_Renderer in SDL2 that I use both to render textures on screen and to render textures on textures, my problem is that when I render to texture the renderer may have some content in it which needs to be drawn, but if it's empty and I call SDL_RenderPresent() on it the screen flickers. So how can I check if there's something drawn inside the renderer?

  • \$\begingroup\$ Track it separately. \$\endgroup\$ – ratchet freak Nov 9 '15 at 13:14

Ok, so from what I understood, when you are rendering to a texture there's no need to flush the renderer before, not even after; that's why there isn't such function to check if the renderer is empty or not.

So the steps are these:

// This draws inside the renderer's buffer
SDL_RenderCopy(renderer, texture, source, bounds);
// This switches to rendering on texture
SDL_SetRenderTarget(renderer, target_texture);
// Apparently this is enough to draw on the texture (so there's no buffer I guess?)
SDL_RenderCopy(renderer, texture2, source, bounds);
// This switches to rendering on renderer buffer
SDL_SetRenderTarget(renderer, NULL);
// This flushes the renderer buffer (so only the SDL_RenderCopy() before rendering on texture)

See my other question for this.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.