I have a programe that has many functions. Each function is written by a person. So I don’t know what did they do with the OpenGL state in these functions (glEnable, glDisable …).
When I draw my scene I would like to reset all state of OpenGL machine to default value. How can I do that?
The answer ist to instruct these persons to restore the state they are changing after they have done their part. glPushAttrib() anf glPopAttrib() will help them.
Alternativly, you can call glPushAttrib(GL_ALL_ATTRIB_BITS) before you call any of these functions and glPopAtrib() when they return. But this can be easily become a performance bottleneck if done many times per frame.
Textures are objects too. And the binding for each target push/pops. But not for framebuffer or renderbuffer objects.
If you need to restore the FBO that was bound before you called some library function (or equivalently, before your middleware implementation returns to a client) then you need to GetInteger and re-bind it yourself.
The point here is that middleware layers already can’t rely on push/pop for state management.
Same story goes for program object binding, XFB buffer bindings, and uniform buffer binding.