PDA

View Full Version : gluPerspective( near clipping )



Chayan Vinayak
07-17-2011, 06:55 PM
gluPerspective(45.0,(double)w / (double)h,1.0,200.0);

In gluPersepective() function we define near clipping. In most of the cases we define near clipping as 1.0 which means anything which is beyond 1.0 or which has Z co-ordinate value less than 1.0 will not be drawn then why are the primitives or points are drawn or visible in the screen which have -5.0( or any other negative value for Z-axis)

eg.

glBegin(GL_POINTS);
glVertex3f(10.0f, 20.0f, -5.1f);
glEnd();


Thanks

Alfonse Reinheart
07-17-2011, 07:59 PM
Because the near/far clipping distances are in eye-space, not model space. The perspective matrix never sees what glVertex gets; it sees those vertices only after they have been transformed by the GL_MODELVIEW matrix. So all of the transforms you set on the modelview matrix happen before the perspective projection.

V-man
07-18-2011, 12:31 PM
If you wanna see wanna see the mechanism of transforming a vertex, you can read
http://www.opengl.org/wiki/Vertex_Transformation

The bottom line is that glFrustum and gluPerspective generate a right-handed coordinate system. That means that positive z points to you. If you wanna see objects on your screen with your

gluPerspective(45.0,(double)w / (double)h,1.0,200.0);

then you need z to be from -1.0 to -200.0 for your points, lines and whatever.