You have to remember anything in the current matrix is affected by any changes to it. example would be glrotate and gltranslate.

What happens is when you push the matrix, every thing that has been done before the push matrix is saved in a stack. Look at it like a save command, you have saved and closed the last items you worked on.

Now anything you do after the push matrix will not change the past saved matrix.

now you can translate and rotate a new object without it effecting the past matrix.

Then after you have complete changes to that object you pop the matrix back, which combines the past matrix with the current matrix.

example:

display()

{

glLoadIdenty(); // Lets start a new

glMatrixMode(GL_MODELVIEW);

glRotate(); //Rotate world

glTranslate() //Translater world

glPushMatrix()// Save past matrix to stack

Draw_cube(); Draw a cube some where

glPopMatrix(); Now add it to our past matrix.

with out using the glPush/pop we get a rotation of the whole world each time we call the glrotate command, but by using the glPush/pop we select what objects we want to rotate and translate.

example without using glpush/pop

glRotate(15,1,0,0);

drawcube(); drawn rotated 15 degrees

glRotate(15,1,0,0);

drawcube(); but this cube will be drawn with a rotation of 15 + 15 = 30 degrees

Hope this helps…

Originally posted by LostInTheWoods:

[b]I am a bit new, and a bit confussed. I am making a scene. In the scene I want a room, with about 10 independently moving objects.

I understand if the user moves around the scene I simply load the identity matrix Rotate or translate(in the negative direction), then draw my room. Now I want to draw the objects, after they have moved.

Should I Push the current matrix, move object one, pop the matrix, push the matrix, move object two, pop the matrix, and so on??

Is this how its done?? [/b]