clearing the matrix stack

Hi

I’m trying to find a easy way to clear the matrix stack. Basically I’m loading my model and adding transforms according to user input. I would like to enable the user to reset the model to its original position. Rather than Popping matrices off the stack as many times as it’s been modified, is there a easier more elegant way?

thanks
James

glLoadIdentity()
that’ll clear it
but u prolly wanna save the original matrix in a var and just reload it so glLoadMatrix…(originalmatrix)

Thanks. I tried glLoadMatrix, but didn’t get the effect I wanted. I’ll try adding code to save the original matrix and reload it as necessary.

thanks again.

Originally posted by zed:
glLoadIdentity()
that’ll clear it
but u prolly wanna save the original matrix in a var and just reload it so glLoadMatrix…(originalmatrix)

glPushMatrix()
glLoadIdentity()
do what you need
glPopMatrix()

or
float mat[16];
glGetfv(GL_MODELVIEW_MATRIX, mat);
glLoadIdentity();
do what you need;
glLoadMatrix(mat);

I tried this and it works partially. When the user begins to rotate, translate or zoom the model again, it seems to pick up where the last matrix before the glLoadMatrix left off. In other words the same view before the reset. Any clues why this is happening?

Originally posted by mr x:
float mat[16];
glGetfv(GL_MODELVIEW_MATRIX, mat);
glLoadIdentity();
do what you need;
glLoadMatrix(mat);[/b]

Nevermind! =)

I’m such a goofball. I forgot to reset some global values such as:
-zoomAmount
-moveAmount
-rotationAngle

I created these variables to maintain degrees of movement or rotation. Silly me, I fogot about them.

Thanks for everyones help.

best
James

Originally posted by jwlee:
[b]I tried this and it works partially. When the user begins to rotate, translate or zoom the model again, it seems to pick up where the last matrix before the glLoadMatrix left off. In other words the same view before the reset. Any clues why this is happening?

[/b]

[This message has been edited by jwlee (edited 11-20-2000).]