Setting up a camera

Whats best to use when setting up camera?, gluLookat, glFrustum, gluPrespective or what?
I’m gonna use data from MAX’s ascii exporter to get camera position and angels and so far i haven’t succeded to get it completly right.
So, anyony got some hints?

I suggest you use gluLookAt to set cameraposition, and gluPerspective to set field of view and near/far clipping planes. Two simple functions.
gluLookAt’s last three arguments is called the upvector and can be a bit hard to understand. Its a vector pointing upwards relative to the camera.
Also make sure you have the correct matrix active when calling these functions. When calling gluLookAt, you should have the modelview matrix active. When calling gluPerspective, the projectionmatrix should be active.

glMatrixMode(GL_PERSPECTIVE);
gluPerspective(fov, aspect, near, far);
glMatrixMode(GL_MODELVIEW);
gluLookAt(p.x, p.y, p.z, t.x, t.y, t.z, u.x, u.y, u.z);

This will place the camera at position p, pointing towards t, and have u as upvector.
fov is field of view. The angle between the line of sight and the upvector ahould always be 90 degrees.
aspect is the aspect ratio, screen width/screen height (can be height/width… not sure)
near/far is near and far clipping planes.

Thanks, works fine. But i had to use the
glMatrixMode(GL_PERSPECTIVE) when running gluLookAt() otherwise it didn’t work!??

Don’t you mean glMatrixMode(GL_PROJECTION) ?

Of course i meant GL_PROJECTION. First line in my code above should be what MikeC said, sorry…