How do I get the current size of a matrix stack in OpenGL?
Question
How do I get the current size of a matrix stack (GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE) in OpenGL?
I want this so that I can do some error checking to ensure that in certain parts of the code I can check that the matrix stacks have been left in the original condition.
Solution
Try:
GLint depth;
glGetIntegerv (GL_MODELVIEW_STACK_DEPTH, &depth);
The enums for the other stacks are:
GL_MODELVIEW_STACK_DEPTH
GL_PROJECTION_STACK_DEPTH
GL_TEXTURE_STACK_DEPTH
If you use multi-texturing, you have more than one texture matrix stack to query. To do so, set the current texture-unit via glActiveTexture();
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow