SDL_HINT_RENDER_BATCHING

Hello,

So I’ve used SDL2 for a while now and I JUST came across this interesting hint called “SDL_HINT_RENDER_BATCHING”.

I’ve tried to do some brief research on it and really not finding any information or examples.

How do you get this working exactly? Can anyone link a simple example? I’m assuming it will render all on the same frame, but how does it accomplish that? It seems impossible without setting it up yourself to where it draws in one frame?

Thanks

In most cases, you shouldn’t need to do anything to use render batching: SDL will batch rendering commands automatically behind the scenes for you. This should give you improved performance if you do lots of similar rendering calls in a row.

The render batching will always complete all rendering when SDL_RenderPresent() is called, so yes — everything will render on the same frame.

The only complicated case is if you’re mixing SDL_Renderer calls and your own rendering (e.g., by calling OpenGL directly), in which case render batching needs to be disabled. This happens automatically if SDL_HINT_RENDER_DRIVER is set.

There’s a pretty good explanation of it here, if you want more details:

It needn’t be disabled, you can call SDL_RenderFlush() before the direct calls to OpenGL etc.