View Full Version : How to clean up Matrix stacks

09-18-2003, 07:53 AM
Back to basics again!

How to clean matrix stacks?
I mean glLoadMatrix, glLoadIdentity will just replace the current
Matrix - the matrix at the top of the stack. glPopMatrix() will
pop out just the matrix at the top - not the whole stack

Only way I can think of is calling glPopMatrix again and again
till one gets an error flag set. Is there ne simpler/cleaner way?

- Chetan

09-18-2003, 09:58 AM
Why do you need to "clean the matrix stack?"

You should always be making sure you have a glPop corresponding to ever glPush. Just like you should always have a delete/free for every new/malloc in C/C++.

09-19-2003, 06:17 AM
Oh right!

- Chetan