Skip to main content
gamedev.net
🔒 Locked

Basic glPushMatrix()/glPopMatrix() question

Started by John_23 Mar 15, 2007 at 11:32 AM 2 replies 2.6k views
Original Post
John_23
John_23
Hey all :] I have been programming in OpenGL for a little while now but have been pondering a question for a while. I have often made object via the glVertex3f() but recently in one of my OpenGL books I saw this: glPushMatrix(); [use of glVertex3f() function] glPopMatrix(); I understand martrices and how they work, but do I really need to include the first and third line? I commented them out and it works fine. Any benefits of using glPushMartrix() and glPopMatrix()? Thanks all, John
_the_phantom_
_the_phantom_
generally one when you've got transformations going on which you want to undo; if there are no functions inside the push/pop block which adjust the matrix then it's a waste of time calling it.
John_23
John_23
Ah OK. Just wondered :]

Thanks!
Xai
Xai
push and pop matrices are VERY important for your system in general (not so much for rendering a single opengl function).

Without them, how would you have something like a general scene graph draw all its objects on the screen such that they don't interfere with each other?

How would you implement composite objects:

For instance say you have code which can draw a model, and then you have composite code which uses this code and draws multiple models on the screen / window.

Then with push / pop matrices, you can shrink that "whole window" drawing code down, translate it to a corner and have multi-view support.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.