[SDL] SDL 1.3 and rendering API state management

Bob Pendleton bob at pendleton.com
Sun Sep 3 19:13:15 PDT 2006

On Sun, 2006-09-03 at 11:47 +0200, David Olofson wrote:
> On Sunday 03 September 2006 11:12, Ryan C. Gordon wrote:
> >
> > > A simple solution would be some kind of mutual notification
> > > interface, so that SDL renderers can tell the application when
> > > they've messed with the API state, and vice versa.
> > 
> > Alternately, you can use glPushAttrib().
> Well, the hard part is figuring out when to do this... I can't see any 
> sensible way to automate it, so for all practical matters, it's 
> "manual control" from the application side. Error prone and hard to 
> debug - especially if the offending code is not your own, but inside 
> various add-on libs that you're trying to use together.

David, I do this kind of stuff all the time. The SDL API *must* push all
attributes, set what it needs, do the job, and restore the attribute and
return. This way the context stays the same from the end users point of
view. Someone is going to say that pushing and popping the context is to
time consuming, I don't believe it. 

The alternative is to put in a wedge layer to capture OpenGL context
changes (a shadow stack) so that the context can be saved and restored
out side of OpenGL. And I think that is an even worse idea that having a
notification API. :-)

It is better to drop the whole idea than to put in the kind of
notification API you were talking about. Us mere mortals don't want to
deal with it and will get it wrong all the time. Consider how few people
actually check return codes from C standard library calls. :-)

If anything this is an argument for having a higher level SLD3D API that
can take care of all of this stuff correctly no matter what the lower
level API is. And, I know how popular that idea is! (Not at all.)

		Bob Pendleton

> //David Olofson - Programmer, Composer, Open Source Advocate
> .-------  http://olofson.net - Games, SDL examples  -------.
> |        http://zeespace.net - 2.5D rendering engine       |
> |       http://audiality.org - Music/audio engine          |
> |     http://eel.olofson.net - Real time scripting         |
> '--  http://www.reologica.se - Rheology instrumentation  --'
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
+ Bob Pendleton: writer and programmer +
+ email: Bob at Pendleton.com             +
+ web: www.GameProgrammer.com          +
+ www.Wise2Food.com                    +
+ nutrient info on 7,000+ common foods +

More information about the SDL mailing list