0
\$\begingroup\$

I am trying to simulate a camera which is always at same distance behind my player, my plan is, to transform the projection matrix correctly with glPush/PopMatrix, as i do it with the modelview matrix. While it's no problem, to rotate the view constantly, it doesn't work to save the current matrix with glPush/PopMatrix. In another thread, I've read that the size projection stack is very limited, one or two at most. If this is true and the 'stack' doesn't offer the possibility to save the current matrix, is there another way to get what i want? Or is my idea a non-practicable approach at all? Is there no alternative to use gluLookAt()? Or is it the right solution to transform the modelview matrix and save the position of the player figure?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Assuming that what you want to achieve is done as you outline, you can emulate pushing and popping by reading and loading the matrix into storage of your own with:

  • float m[16]; glGetFloatv(GL_PROJECTION_MATRIX, m); and
  • glMatrixMode(GL_PROJECTION); glLoadMatrixf(m)
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .