Question on using glPopMatrix()

Post Reply
Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Question on using glPopMatrix()

Post by Sylus101 » Mon Oct 26, 2009 6:30 pm

So far, I've used glPushMatrix() and glPopMatrix() to draw two or more objects with different transformations successfully. However, I now need to have a particular object move relative to another object... which, from what I'm gathering, means I need to use glPushMatrix() a second time before I've popped the previous matrix off the stack. In the OpenGL tutorials I've read, there is no parameter for glPopMatrix() which I believe I understand, it's just reverting to the Matrix that was on the stack at the time it was last Pushed.

The libnds version has a parameter for what number to pop down the stack. The question is... do I leave that "1" in this case? Like so:

Code: Select all

glPushMatrix();

  //Rotate, Translate, Scale...

  glCallList((u32*)object_bin);

  glPushMatrix();

    //Rotate, Translate, Scale...

    glCallList((u32*)object2_bin);

  glPopMatrix(1);

glPopMatrix(1);
This does, by the way, appear to be working as intended. The docs say "Pops num matrices off the stack," so I'm supposing now that I think about it, I could just use glPopMatrix(2) instead of calling it with 1 twice at the end?
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

Discostew
Posts: 103
Joined: Sun Mar 08, 2009 7:24 pm

Re: Question on using glPopMatrix()

Post by Discostew » Tue Oct 27, 2009 2:06 am

Sylus101 wrote:The docs say "Pops num matrices off the stack," so I'm supposing now that I think about it, I could just use glPopMatrix(2) instead of calling it with 1 twice at the end?
Exactly.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest