gluPerspective( near clipping )

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)


glVertex3f(10.0f, 20.0f, -5.1f);


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.

If you wanna see wanna see the mechanism of transforming a vertex, you can read

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.