OT: a way to save opengl default states and restore them

tb

Newcomer
hi,
this could be a little bit off-topic, but does anyone know a way how I cn save and restore mos of opengl's states? I know the glpushattrib/glpopattrib stuff, but here is the problem, I want to do the following:

save default
do something
save new states
restore default states
do something
restore new states

best regards,
thomas
 
tb said:
hi,
this could be a little bit off-topic, but does anyone know a way how I cn save and restore mos of opengl's states? I know the glpushattrib/glpopattrib stuff, but here is the problem, I want to do the following:

save default
do something
save new states
restore default states
do something
restore new states

best regards,
thomas


Without writing a wrapper for state setting that maintains a list of states, no way I know of.

Having said that you probably only think you want this, I've seen many attempts in API's to abstract the state problem, and without exception every one of them ends up making it more difficult to manage state accross the application as a whole than just accepting the fact that the graphics hardware is a statemachine.

Having said that we commonly do build a wrapper around state changes, to cache current state and remove redundant state changes. On PC the driver is likely doing this anyway.
 
You can't save the current state in this way.
However, you can compile settings for all states (that interest you ...) into a display list.
 
tb said:
hi,
this could be a little bit off-topic, but does anyone know a way how I cn save and restore mos of opengl's states? I know the glpushattrib/glpopattrib stuff, but here is the problem, I want to do the following:

save default
do something
save new states
restore default states
do something
restore new states

best regards,
thomas

I'm doing something fairly close to that in my framework. It's all manual though, there's no magical API call you can use. The closest would indeed be glPush/PopAttrib. Writing your own wrapper to manage states is probably your best bet. I've found that it improves my productivity quite a lot.
 
Back
Top