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.
The current matrix, M, defines a transformation of coordinates. For instance, assume M refers to the modelview matrix. If v = v 0 v 1 v 2 v 3 is the set of object coordinates of a vertex, and m points to an array of 16 single- or double-precision floating-point values m = m 0 m 1 ...
The matrix stack is used to concatinate matrices. Typically used for heirarchical models where a transformation is expressed relative to another. One can load a matrix on the stack and transform vertices in that space and then go back to the parent space by popping the stack.
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();
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With