viewing perspective

hi,
i have defined th following perspective as my view plane:

glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(45.0, (GLfloat) w/(GLfloat) h, 5.17, 10.7);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef (-0.1, -1.6, 7.9);
glRotatef(-90,1,0,0);
glRotatef(-30,0,0,1);
glRotatef(0,1,0,0);
glTranslatef(-0,-0,-0);
glScalef(1,1,-1);

then i try to output a sphere

glTranslatef(0,0,0.08);
glScalef(0.275,0.152,0.153);
qobj = gluNewQuadric();
gluSphere(qobj,1,10,10);

it just won’t show up on the screen.

any idea what’s wrong??

thank you

Hi !

Try to use some other values for near, far clipping planes first, like 0.5 and 1000.0 or something like that to make sure that the object is not clipped because of this.

Mikael

Originally posted by edwong:
[b]hi,
i have defined th following perspective as my view plane:

glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(45.0, (GLfloat) w/(GLfloat) h, 5.17, 10.7);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef (-0.1, -1.6, 7.9);
[/b]

Remember when gl initially starts up the eye is looking down the z axis. The glTranslatef(…,…,7.9) causes the object to be moved behind the eye. To get this object to appear in the frustum using the gluPerspective() parameters you have specified you need to make the z parameter of glTranslatef() negative and it must be at least -5.17 or smaller. Try this instead: glTranslatef(0.0, 0.0, -7.9).

I also note is that there is a lot of translating, rotating and scaling. To make sure things are simple and working start out with just the glTranslatef() I’ve specified above, then add the other stuff in, one by one, so you can monitor what it does. If it doesn’t do what you expect, then you can know the problem lies with the newly added function call and play with the parameters accordingly.