Questions On The Matrix Stack

I’m working with the old classic GL. Have questions about the matrix stack. Let’s say I have 6 transformations in the stack applied to my model which is made up of 50,000 vertices. Is the matrix stack resolved BEFORE application to the model? By ‘resolved’ I mean all 6 matrices in the stack are reduced to one via matrix multiplication. This would make sense because only one matrix would have to be applied to the 50,000 vertices of my model. Could it be that the 6 transformations are applied to the model one at a time? That would seem much slower to me.

Assuming the stack is reduced to one matrix before application to the model, how often is this done? Is it done every time I refresh the screen - even if nothing in the stack has changed? Is GL smart enough to know that it doesn’t have to reduce the stack again if none of the transformations have changed. Put another way - does it save this ‘resolved’ matrix and only update it if one of the transformations on the stack has changed? Or does it simply do all the matrix multiplications every time I render a frame?


It’s neither. You start out with only an identity matrix on the stack, and any matrix functions are applied to that matrix; i.e. glTransform, glRotate, and glScale all multiply their “matrix” with the matrix on the stack currently. Then, when you call glPushMatrix, it duplicates the current matrix and puts it on top. That way, you can apply operations to it, and then restore it with a glPopMatrix. A glLoadIdentity loads the identity matrix on the current matrix.

So, OpenGL doesn’t have to do anything to the matrix when you draw stuff. Since all matrix operations affect the current matrix, all OpenGL needs to use is the current matrix.