Skip to main content
gamedev.net
🔒 Locked

Matrix functions?

Started by Kaezin 2 replies 350+ views
Original Post
Kaezin
Kaezin
What do glPushMatrix() and glPopMatrix() do? There are probably other functions, too, but I haven''t seen them. Can anyone tell me what these do or how to use them?
Half the people you know are below average.Trogdor the Burninator
Gladiator
Gladiator
glPushMatrix and glPopMatrix are responsible for saving and restoring the transformation matrix, respectively. They work the same way a stack works.

glPushMatrix() // save current state of transformation matrix
... // apply some other transformations to the matrix
glPopMatrix() // restore matrix to the state it was when glPushMatrix() was issued

It would help to google for the sake of research before posting questions here
Kaezin
Kaezin
I did do some searching before I posted, but everything I found was either unclear or I didn't understand it. I thought it might be what it said, but wanted to make sure anyway. So basically it's just a way of changing things around without having to change the view?

[edited by - Kaezin on January 11, 2003 5:11:44 PM]
Half the people you know are below average.Trogdor the Burninator
ga
ga
yes, and you can do hierarchical things with it also: e.g. you have got a car:
do the view things
glPushMatrix();
rotate&move it to its position & orientation
draw car body
for each wheel:
-glPushMatrix();
-move wheel to proper postion & rotate to proper orientation relative to the car
-draw wheel
-glPopMatrix();
glPopMatrix();



GA
Visit our homepage: www.rarebyte.de.stGA

Topic Locked

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

Sign in to reply to this topic.