How to restore OpenGL default state ?

Posted on 2009-04-20
Last Modified: 2013-12-21
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,
Question by:Alexander
    LVL 3

    Expert Comment

    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:

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

    Hope this helps,

    LVL 1

    Author Comment

    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...
    LVL 3

    Accepted Solution

    Maybe you could create a brand new OpenGL context, then all your states would be the default ones.
    LVL 1

    Author Comment

    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...
    LVL 1

    Author Closing Comment

    It is the good idea, everything works very well now !

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    If you are interested in the gaming world and want to try World of Warcraft, I'd recommend this basic set of add-ons to get you started.  All add-ons are available either by Google search or on For the person who doesn't want to get in…
    As we all know Counter Strike is a very popular computer game. Usually it is played over a network for which people create a server and users join it but it is interesting to know that one can creates a dedicated server which not only hosts the game…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now