Reinitializing state machine to its default


How about a new command called glReset(GLenum param) which would reset all or part of the state machine to the “default” values (the initial state).

For instance, lights could be set to their original position and colors by calling :
or maybe :

The latter would allow to perform a multiple reset in one command thanks to an OR’ed argument.


The set of “resetable” parameters could be associated to the equivalent attrib bits of glPushAttrib. This way there would be an orthogonality between glPushAttrib/glPopAttrib/glResetAttrib a bit like in glPushMatrix/glPopMatrix/glLoadIdentity

Why do I need default values?

Because you may want to setup some state regardless of what has been called on it before.

When you want to reset a matrix, you just have to call glLoadIdentity(), right ? That’s easy, fast, and very handy because you take control over the matrix value no matter how many times glTranslate/Rotate/MultMatrix/etc was called.

In the same way, it could be handy to reset eg material parameters with a single GL call, which would let you take control of the material parameters no matter how many glMaterial commands were called.

Default values for all state variables are contained in the specification. You can just write your own functions to reinitialize the GL state.