# Restoring projection matrix

I am learning to use FBOs and one of the things that I need to do when rendering something onto user defined FBO, I have to setup the projection, modelview and viewport for it. Once I am done rendering to the FBO, I need to restore these matrices. I found:

glPushAttrib(GL_VIEWPORT_BIT);
glPopAttrib();


to restore the viewport to its old state. Is there a way to restore the projection and modelview matrix to whatever it was earlier ?

Tech: C++/OpenGL

Thanks!

There are depricated functions glPushMatrix and glPopMatrix. I'm not sure if you have them in your version of opengl.

You can also very easily use function glGetFloatv. Example

//save matrix
glGetFloatv(GL_PROJECTION_MATRIX, &floatArray[0]);
//set matrix back
glMatrixMode(GL_PROJECTION);