View Full Version : push and pop matrix
06-12-2005, 05:32 PM
hello i want to rotate the texture matrix and the codes are like this follow:
i want to know whether the glPushMatirxand glPopMatrix are useful in this accation?thank you very much!!
W.r.t. the code you posted:
1. Your code also does a loadidentity between the push and the pop. This is only necessary if you want to use a non-identity matrix as the default.
2. You seem to pop the matrix before you render anything. Don't pop the matrix until you've actually rendered something or you'll see no difference.
W.r.t. the general question:
My guess is no.
The matrix stack is not of infinite depth (the mininum I believe is just one), so don't nest those push/pop pairs.
My guess is that a glLoadIdentity would be optimised, and since the identity matrix is the default, you would not need a push/pop pair to restore it.
And my guess is that one glLoadIdentity is at least as fast as a push, and a pop combined.
But I'm just guessing here.
1. When activating a texture: do the scales, translates and rotates you need. Don't do the glLoadIdentity, since the default state is an identity matrix. Nothing to rotate etc: just skip this part.
2. render the geometry
3. When deactivating the texture, if it has modified the texture matrix (you can keep track of this with some booleans), do a glLoadIdentity
4. go to step 1
This limits the loadidentities to the bare minimum - only when resetting the matrix to the default. But you have to do it consistently or your textures go crazy.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.