Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the current size of a matrix stack in OpenGL?

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.

like image 348
Ashley Davis Avatar asked Sep 22 '08 09:09

Ashley Davis


People also ask

What is current matrix in opengl?

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 ...

What is matrix stack in OpenGL?

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.


1 Answers

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();.

like image 174
Nils Pipenbrinck Avatar answered Nov 10 '22 10:11

Nils Pipenbrinck