Jump to content

  • Log In with Google      Sign In   
  • Create Account


Nehe lesson 17 - about glPopMatrix()


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 wil_   Members   -  Reputation: 164

Like
0Likes
Like

Posted 11 June 2009 - 11:06 PM

Hello first thanks for making such material available on Nehe. I met for the first time multiple use of glPopMatrix() in lesson 17 today : in custom function glPrint(..) we find something that looks a bit like that : glMatrixMode(GL_PROJECTION); glPushMatrix(); // set ortho matrix // ... glMatrixMode(GL_MODELVIEW); glPushMatrix(); // display stuff // ... glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); The author comments about the uses of popmatrix: "It's important to restore things in the opposite order you stored them in. " Which is the reverse order ? I thought it would mean pop the last matrix we pushed, and then the first one. When trying to do this (popping modelview matrix before projection matrix), the textured square displayed in the lesson disappears from my scene. I don't understand why, how it is connected to the order of calls to popmatrix. Does anyone know what is happening in that case ? Thanks in advance for any comment. +

Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 7426

Like
0Likes
Like

Posted 11 June 2009 - 11:37 PM

The matrix modes have separate stacks, so it doesn't matter in which order you pop them. However, what does makes a difference is the current matrix mode after the code is executed. If you change the order, the matrices will be restored properly, but the active matrix is now the projection matrix and not the modelview matrix. If, further down the code, you assume the modelview is active, you're screwed.

#3 wil_   Members   -  Reputation: 164

Like
0Likes
Like

Posted 12 June 2009 - 12:08 AM

Ok, that works when I set back the modelview matrix to current mode, thanks !




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS