11-01-2005, 11:52 AM

Hi All, I have the following pseudo-code:

main (){

...other init stuff

glutDisplayFunc (displayIt);

glViewport(0, 0, 640, 480);

glutMainLoop();

}

void displayIt() {

glMatrixMode(GL_PROJECTION); //set the camera

glLoadIdentity(); //load the identity matrix

glOrtho (-50 , 50 , -25 , 50 , -40 , 400);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

GLdouble eyeX = 10.0; GLdouble eyeY = 2.0;

GLdouble eyeZ = 7.0;

gluLookAt(10 , 2 , 7,

0,0,0,

0,1,0);

draw_a_sphere();

glFlush();

}

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:

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

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);

draw_sphere();

glFlush();

}

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

main (){

...other init stuff

glutDisplayFunc (displayIt);

glViewport(0, 0, 640, 480);

glutMainLoop();

}

void displayIt() {

glMatrixMode(GL_PROJECTION); //set the camera

glLoadIdentity(); //load the identity matrix

glOrtho (-50 , 50 , -25 , 50 , -40 , 400);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

GLdouble eyeX = 10.0; GLdouble eyeY = 2.0;

GLdouble eyeZ = 7.0;

gluLookAt(10 , 2 , 7,

0,0,0,

0,1,0);

draw_a_sphere();

glFlush();

}

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:

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

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);

draw_sphere();

glFlush();

}

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