gluLookAt call in wrong matrix

Wol
Posts: 2
Joined: Sun Feb 03, 2008 5:19 pm

gluLookAt call in wrong matrix

Post by Wol »

Hi,

Just been looking through the basics of how you're implementing the OpenGL calls into the world object, and noticed that in "updateCamera()" in "DemoApplication.cpp", you select the GL_PROJECTION matrix, and load the camera position and direction into this with the gluLookAt function.

As is commonly known, and documented on the opengl website, the camera view information should be in the GL_MODELVIEW matrix.
OpenGL Website wrote:8.030 Where should my camera go, the ModelView or Projection matrix?

The GL_PROJECTION matrix should contain only the projection transformation calls it needs to transform eye space coordinates into clip coordinates.

The GL_MODELVIEW matrix, as its name implies, should contain modeling and viewing transformations, which transform object space coordinates into eye space coordinates. Remember to place the camera transformations on the GL_MODELVIEW matrix and never on the GL_PROJECTION matrix.
Any reason why it has been done this way?

The basic gluPerspective(field of view, aspect, near, far) in GL_PROJECTION and the gluLookAt(camxyz, targetxyz, upxyz) in the GL_MODELVIEW matrix has always worked for me with no problems.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: gluLookAt call in wrong matrix

Post by Erwin Coumans »

Wol wrote:Any reason why it has been done this way?
It was an accident, the GL_PROJECTION is used for glFrustum. I'll move up the GL_MODELVIEW before the gluLookAt.

Thanks for the report,
Erwin