Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

wolfman8k

OpenGL PUSHing and POPing matrices in OpenGL

This topic is 6619 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

What does pushing and poping matrices in openGL do? I know it has something to do with the stack and saving matrices but I don''t know what it does exactly and what you''d need it for. Thanks, wolfman8k

Share this post


Link to post
Share on other sites
Advertisement
The glPushMatrix and glPopMatrix calls are used to save/restore
the current matrices in the selected matrix mode
GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE.

glPushMatrix makes a copy of the current selected matrix
and pushes it onto a stack. You can then work on the
current matrix and alter it as you need.
When you call glPopMatrix it''s restores the last pushed
matrix to bein the current matrix - within that matrix
mode. Slightly convoluted but I think you get the idea.

I use it for keeping track of camera/model matrices.
What I do is I build the camera matrix at the start of the
frame into GL_MODELVIEW - then when I render an object, I
push the matrix onto the stack - make alterations for the
model transforms (and sub-models - using glPush aswell). Then
when I leave the rendering for the model I pop off the original
camera matrix - leaving things nice.

_Definately_ useful functions if used correctly.


--
Code..reboot..code..reboot..sigh!

Share this post


Link to post
Share on other sites
Perfectly agree with MrFlibble.

BTW, MrFlibble if you want to change your signature to :

Code..test..code..test..

Simply use BeOS

(I love BeOS, it makes me happily code in C and C++ with OpenGL and SDL)

-* So many things to do, so little time to spend. *-

Share this post


Link to post
Share on other sites
also u can go ( its all the same jist)
glPushAttrib(GL_ALL_ATTRIBUTES?)
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE)
glEnable(GL_WIREFRAME?)
// draw someit that you want to be textured + wireframed
glPopAtrrib();
now the state is back to what it was before maybe lite maybe solid maybe not textured etc

Share this post


Link to post
Share on other sites

for glPushAttrib the flag to push all the attributes is:

GL_ALL_ATTRIB_BITS

Generally its a define in the header which is all the
individual push masks OR''d together.

Never actually looked at that - learn something new everyday =)

Ingenu:
Aye might take a look into BeOS again sometime soon.
Though I''d rather use Linux really =)

Still trying to get XFree 4.0.1 working - problems with
windowmanagers crashing when I log in atm *sigh*

Anyway - I like my sig the way it is =)

--
Code..reboot..code..reboot..sigh!

Share this post


Link to post
Share on other sites

  • 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!