Jump to content
  • Advertisement
Sign in to follow this  

glPopMatrix does not get what was pushed

This topic is 2114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I have noticed that I don't get the same matrix I pushed !!

Does anybody have an idea ?

Thank you


Here is the code I am using:


#include <assert.h>


int DrawGLScene(GLvoid)
      GLdouble mat5[16],mat6[16];
      glGetDoublev(GL_MODELVIEW_MATRIX, (GLdouble *)&mat5);
      glGetDoublev(GL_MODELVIEW_MATRIX, (GLdouble *)&mat6);
      assert(matequal(mat5,mat6));                                                               <----- execution breaks here
bool matequal(GLdouble *N,GLdouble *M)
            M[0]==N[0] && M[1]==N[1] && M[2]==N[2] && M[3]==N[3] && 
            M[4]==N[4] && M[5]==N[5] && M[6]==N[6] && M[7]==N[7] && 
            M[8]==N[8] && M[9]==N[9] && M[10]==N[10] && M[11]==N[11] && 
            M[12]==N[12] && M[13]==N[13] && M[14]==N[14] && M[15]==N[15]  )
            return true;
      return false;

Share this post

Link to post
Share on other sites

Is it widely different?

glPush/PopMatrix() should just be a memcpy() call internally


From reading your code, I can see nothing wrong. Your results are puzzling smile.png


I'm not entirely sure why you would expect anything with GPU to be double-precision though.. tongue.png

The drivers will just convert everything to float, but there is nothing in your code that shouldn't return the same values both times

Although, try using glGetFloatv instead, just to see if it's a precision issue


I probably should mention that using == with floating point numbers, with few exceptions (one being this case), is generally dangerous :)


Edited by Kaptein

Share this post

Link to post
Share on other sites

I am Sorry.

It was my mistake :

I had one glPushMatrix in excess elsewhere in the code. So at the end of each frame, I had a matrix forgotten in the stack.

and at the 32nd frame, the matrix poped no longer corresponded to the one immediately pushed.



I guess openGL should signal the overflow in the matrix stack by a crash or a warning, rather than poping an incorrect matrix.  



Thank you for your answer and your time


Share this post

Link to post
Share on other sites
According to the docs, GL_STACK_OVERFLOW can be generated. However, since this is completely deprecated functionality it is of course possible modern drivers don't bother anymore.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!