PDA

View Full Version : query on pop/push matrixes



coda
12-12-2003, 03:11 AM
what is the actual purpose and meaning of popping/pushing matrixes? does it save the previous scene?

ZbuffeR
12-12-2003, 04:35 AM
Originally posted by coda:
what is the actual purpose and meaning of popping/pushing matrixes? does it save the previous scene?
No, just the projection or modelview matrix. You don't seem to know that matrices are used for transformations/projections, for instance when you rotate, translate, scale your objects. Try to read some reference book on computer graphics.

nexusone
12-12-2003, 05:06 AM
Its store current rotations and translations, scale ect, which are in the model matrix.

It does not store any scene data.

Remember all matrix operations are cumlative, so in order to have future object that are draw not effected by some rotation or translation we use push/pop matrix.

Lets say we want to view all object from a 45 degree angle and we want to rotate only one object on it axis.


glRotatef(45, 1.0,0.0, 0.0);

glPushMatrix(); Save matrix state
glRotatef(RX,0.0, 1.0, 0.0);
Draw_object();
glPopMatrix(); // Restore matrix
Draw_object();

Only the object between the Push/Pop Matrix will be effect by the glRotate RX.



Originally posted by coda:
what is the actual purpose and meaning of popping/pushing matrixes? does it save the previous scene?