We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1138

Summary: Create functions to save/restore render state
Product: SDL Reporter: Sam Lantinga <slouken>
Component: videoAssignee: Gabriel Jacobo <gabomdq>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: gabomdq
Version: HG 2.1   
Hardware: All   
OS: All   

Description Sam Lantinga 2011-02-20 12:22:19 UTC
It should be possible to use SDL rendering with native OpenGL or Direct3D.

This task is to create functions to save and restore render state so 2D rendering can be mixed with 3D rendering.  e.g.

while (true) {
   3D rendering...
   SDL_RenderSaveState()
   2D rendering...
   SDL_RenderRestoreState()
   3D present
}

We'll also need some test programs for this using the various native 3D APIs.
Comment 1 Gabriel Jacobo 2013-05-21 09:34:48 UTC
I've done a bit of this here: http://mdqinc.com/blog/2013/01/integrating-librocket-with-sdl-2/ where I do the "resetting" to a known state by drawing a point outside of the screen. I ended up building SDL_RenderGeometry out of that code to be able to integrate with SDL's shader management (there's another wishlist item!), but the idea still holds...

Basically I think a solution could be implemented with a SDL_RenderResetState function which can be called before the 2D functions, something like...

app specific 3D rendering setup...
3D rendering
SDL_RenderResetState()
2D rendering (using SDL_Render* functions)
2D/3D present
Comment 2 Sam Lantinga 2013-05-21 23:57:56 UTC
That seems like a decent approach to me. :)