Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

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);
glLoadMatrixf(floatArray);
share|improve this answer
    
I have glPushMatrix and Pop matrix. I didn't know they were deprecated! Also, this is a pretty old link, but it was recommended not to use glGetFloatV to retrieve value and set them later on. opengl.org/resources/features/KilgardTechniques/oglpitfall –  brainydexter Feb 21 '11 at 20:18
    
It is interesting, but i do not see any glGetFloatV in this article. Can you please specify it? And if you can use glPushMatrix and glPopMatrix is problem solved? –  Notabene Feb 21 '11 at 20:26
    
I think that even glPushMatrix and glPopMatrix are depricated, they can be easily used. I don't have any idea how to use it with non-depricated functions. –  zacharmarz Feb 21 '11 at 20:27
6  
It's also not recommended to use any Get command. The best you can do is probably to keep and set your matrices by your self. so restore is just another set. The matrix stack in general is also deprecated, the future proof way of setting them is using constants to your vertex program. –  void Feb 22 '11 at 12:45
1  
@BlueRaja because the fixed pipeline was removed; to great avail. Perhaps that can be the question of your study; look at why the fixed pipeline was deprecated, and you shall find your answer. –  Daniel Jun 22 '11 at 0:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.