PDA

View Full Version : perspective question



jacksmash
12-11-2007, 03:57 PM
ok... if I have my viewing perspective defined as:

gluPerspective(40.0, 1.0, 1.0, 500.0);

and I draw a quad like this:


glEnable(GL_QUADS);
glVertex3f(-100.0, -100.0, 0.0);
glVertex3f(-100.0, 100.0, 0.0);
glVertex3f(100.0, 100.0, 0.0);
glVertex3f(100.0, -100.0, 0.0);
glEnd();


Then where does it get drawn? Is z=0.0 right where the camera is? If so, then the quad would not be viewable as drawn. Is this correct?

Xmas
12-11-2007, 04:21 PM
It depends on whether there are other matrix manipulation calls in your code, but if there's only this gluPerspective call then yes, this quad is in front of the near clipping plane and thus completely culled.

jacksmash
12-11-2007, 05:46 PM
There are no other matrix calls affecting this quad. I only have one other object being drawn, and although there are some matrix calls there - they are surrounded by glPushMatrix and glPopMatrix.

For some reason I can't get the quad to display at all. I'm guessing I'd have to post some code for someone to tell me why - but is there something that I may not be reasoning about correctly? For example, when you say 'completely culled' I'm assuming you mean the coordinates are in CCW direction?

Cheers.

jacksmash
12-11-2007, 09:14 PM
One of the weird things is that if I replace the above code with simply:

glTranslatef(0.0, 0.0, -20.0);
glRectf(-10.0,-10.0,10.0,10.0);

then it shows up.