If you are only rotating or translating one object you will not see any effect from push/pop the matrix, depending on your code.
But if you have more then one object, then it is a must that you use them.
You must remember that any time you use a command that changes the matrix it effects every object in that matrix.
example:
glRotate(15, 1, 0, 0);
My_Object1(); this object is rotated 15 degrees
glRotate(15, 1, 0, 0);
My_Object2(); this object is rotated 15 degress plus the 15 degrees from the past rotate, a total of 30 degrees is what this object will be rotated.
example with glPush/pop
glPushMatrix(); // save past matrix, before next operation
glRotate(15, 1, 0, 0);
My_Object1(); this object is rotated 15 degrees.
glPopMatrix(); // Combine past matrix with current
glPushMatrix(); // save matrix
glRotate(15, 1, 0, 0);
My_Object2(); this object is rotate 15 degrees, is not effected by past matrix rotation before Push Matrix
glPopMatrix(); //Combine past matrix with current.
Originally posted by fabianspring:
[b]Hello guys!
I have a little question, for what do I need the function glPushMatrix()? I know that its like “remembereing the current position of the matrix”, but no matter if i execute my programme with the glPushMatrix() and glPopMatrix() functions, its absolutely the same. In example, I rotate a cube… with or without this function, its still the same.
Could someone please explain me the basic usage of that stuff and when exactly I need it and for what?
Thank you 1000 times,
Fabian[/b]