PDA

View Full Version : gluLookAt



mr_coolio
01-28-2003, 04:23 AM
why does not gluLookAt commute with gluPerspective?

JustHanging
01-28-2003, 04:41 AM
Commute as in you can't switch their order?Those commands correspond to matrix multiplications and they aren't commutative.

The camera transform (as in gluLookAt) must be done in world coordinates and if you do it before gluPerspective it gets done in normalized device coordinates or something like that. That's wrong, just don't do it.

Arguably the gluLookAt belongs to the modelview matrix and gluPerspective to the projection, so you shouldn't apply them to the same matrix anyway.

-Ilkka

mr_coolio
01-28-2003, 04:56 AM
Originally posted by JustHanging:
Commute as in you can't switch their order?Those commands correspond to matrix multiplications and they aren't commutative.

The camera transform (as in gluLookAt) must be done in world coordinates and if you do it before gluPerspective it gets done in normalized device coordinates or something like that. That's wrong, just don't do it.

Arguably the gluLookAt belongs to the modelview matrix and gluPerspective to the projection, so you shouldn't apply them to the same matrix anyway.

-Ilkka

It seemed to me that these two functions affect different and independent things, so I thought they should commute. I'll take it as just one of those things that gluPerspective has to be done first.

nexusone
01-28-2003, 06:25 AM
Again this goes back to Projection matrix vs. model view matrix.

gluPerspective set's up a Perspective view of the 3D world.

Where gluLookAt is the placement of the camera in the world is a model view operation.

You set your Projection view first then you set your model view and the drawing of the objects.

If you look at most tutors and demo's will see this format of the Projection and model views.



Originally posted by mr_coolio:
why does not gluLookAt commute with gluPerspective?