• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

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
0
Alexander
Asked:
Alexander
  • 3
  • 2
1 Solution
 
vhpgomesCommented:
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
0
 
AlexanderAuthor Commented:
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...
0
 
vhpgomesCommented:
Maybe you could create a brand new OpenGL context, then all your states would be the default ones.
0
 
AlexanderAuthor Commented:
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...
0
 
AlexanderAuthor Commented:
It is the good idea, everything works very well now !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now