Jump to content
  • Advertisement
Sign in to follow this  
subflood

Pushing and Popping

This topic is 4954 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why would you want to push and pop matrices? I mean I don't really understand the purpose of the commands. In my code I draw a bunch of quads and I tried using the command glPushMatrix(); before I start the drawing and glPopMatrix() after the drawing is completed but they have no effect. Can anyone give me a scenario where using these commands would be usefult? thanks.

Share this post


Link to post
Share on other sites
Advertisement
pretty simplistic use of them, but suppose you have a bunch of objects to render, and the code to render these objects uses gl calls that change the position of the origin, like glTranslatef and glRotatef. To return to the normal origin after drawing, you'd have to reverse all of the calls (so if you move 3 units down the z axis, you have to move 3 units back up, and so on). Alternatively, you could push on a new matrix before you draw each object, and set it to the identity, and then pop it off after uve drawn said object. When u get to push one on for the next object, you are back where you started, and you dont have to do any wierd reversing of stuff.
hope that helps!


Scott

Share this post


Link to post
Share on other sites
Yeah, the whole point of push and pop is that when you push the matrix it effectively saves the state of the matrix, so you can change it , render some things, and when you pop it you get the original matrix back. It's just a stack.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!