Link to home
Start Free TrialLog in
Avatar of Alexander
AlexanderFlag for France

asked on

How to restore OpenGL default state ?

Hello everybody,
I think it is maybe not possible but who kows ? ;)
I'm developping an OpenGL plug-in under X-Plane 9 (flight simulation game) and I would like to recover OpenGL "default" draw state (enable bits, binds, unbinds, matrixes, etc...) like if I've just opened a new window... Some kind of "glLoadDefaults()" that may restore all Internal OpenGL states (enable bits, matrixes, etc...).
Do some of you think it is possible ? if yes : how ?

I'm asking you that question because into my plug-in the FrameBufferObjects (FBO) doesn't seem to work in the same way as in X-Plane 8.XX, (same PC, same VideoCard, same Drivers), so I'm beginint to wonder if X-Plane 9 doesn't sets a "special" context I'm not aware of squizzing FBOs (?!)

thank you for your attention,
Alexander
Avatar of vhpgomes
vhpgomes
Flag of Brazil image

It's not exactly what you asked for but you could call  glPushAttrib(GL_ALL_ATTRIB_BITS); at the beginning of your code, and then call glPopAtrib(); to get it back.

This will save a lot of state variables, as can be seen here:

http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/pushattrib.html

But some things may not be saved, as can be seen here:

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=244259

Hope this helps,

Victor
Avatar of Alexander

ASKER

Sorry, I'm already aware about PushAttrib()/PopAttrib() functions. I'm looking for something that can restore a kind of "initial default state", in other words, the state at the main() enter point before any GL draw or setting done...
ASKER CERTIFIED SOLUTION
Avatar of vhpgomes
vhpgomes
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's a good idea, I've already started to set it in place this afternoon, I'll do some tests tonight, could be the answer, I'll keep you informed...
It is the good idea, everything works very well now !