Hello first thanks for making such material available on Nehe.
I met for the first time multiple use of glPopMatrix() in lesson 17 today : in custom function glPrint(..) we find something that looks a bit like that :
// set ortho matrix
// display stuff
The author comments about the uses of popmatrix: "It's important to restore things in the opposite order you stored them in. "
Which is the reverse order ? I thought it would mean pop the last matrix we pushed, and then the first one. When trying to do this (popping modelview matrix before projection matrix), the textured square displayed in the lesson disappears from my scene.
I don't understand why, how it is connected to the order of calls to popmatrix.
Does anyone know what is happening in that case ?
Thanks in advance for any comment.
The matrix modes have separate stacks, so it doesn't matter in which order you pop them. However, what does makes a difference is the current matrix mode after the code is executed. If you change the order, the matrices will be restored properly, but the active matrix is now the projection matrix and not the modelview matrix. If, further down the code, you assume the modelview is active, you're screwed.