camera, gluPersective woes

Hi All, I have the following pseudo-code:

main (){
…other init stuff
glutDisplayFunc (displayIt);
glViewport(0, 0, 640, 480);

void displayIt() {
glMatrixMode(GL_PROJECTION); //set the camera
glLoadIdentity(); //load the identity matrix
glOrtho (-50 , 50 , -25 , 50 , -40 , 400);

GLdouble eyeX = 10.0; GLdouble eyeY = 2.0;
GLdouble eyeZ = 7.0;

gluLookAt(10 , 2 , 7,

The code above results in a sphere being displayed…Cool.

Now instead of using glOrtho, I want to use gluPerspective();
and another routing that sets the MODELVIEW matrix
Im really confused regarding the ordering of how I should do operations… This is the bogus code I have now:

gluPerspective(45 , 64/48, 0.1 , 40);
//HOW do I know what to pick for the above,
// guess?

//This is a working function which
//manually loads the modelview matrix
set_ModelView_Matrix(eye, lookat, up);

The output of this code is a blank screen. Im not sure how to solve this problem.

Hi !

If you want to setup everything yourself you could just replace glOrtho with glFrustum instead, it does the same thing but with a perspective projection instead, you will have to modify the clipping planes though.

gluPerspective will call glFrustum in the end what it does is that it use the field of view angle to calculate the coordinates, most people find the gluPerspective easier to use.

The aspect ration is to make sure a circle look like a circle and not an oval depending on the width/height retio, and the angle specifies the height of the projection, and the clipping planes are pretty ok as they are, make sure you do not set the near clipping plane to close to zero and everything should be ok.