views:

499

answers:

1

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.

+4  A: 

Try:

  GLint depth;
  glGetIntergerv (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 texure matrix stack to query. To do so set the current texture-unit via glActiveTexture ();

Nils Pipenbrinck