why does not gluLookAt commute with gluPerspective?

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

Originally posted by JustHanging:

[b]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[/b]

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.

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?