I am confused about perspective projection.
Here is the scenario that is confusing me. My frustrum\'s front plane is basically positioned at at positive z-axis and the b
Now, whenever I go through examples I see that the near and the far plane are all present in the -ive z axis.
Of course. Otherwise you would get something like this
:
All projection happens relative to the origin 0. near and far determine the distance of the clipping planes from the origin. left and right define the opening angle of the frustum together with the near plane. If you place a "near" and far plane in opposite directions of the origin, your projection space becomes shaped like an hourglass.
glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustrum(-xval,+xval,-yval,+yval,-10,+10); gluLookAt(); // some point lying on this axis of symmetry about the point glMatrixMode(GL_MODELVIEW);
The projection is not meant to place the view. The projection is sort of the "lens" of your virtual camera. You can use it to tilt and shift your lens and set the "focal length". But it's not meant to "place your camera". This should happen through the modelview matrix.
So, in the above case what is the behavior that I should expect for the glFrustum with a negative as well as positive value for z. i.e. in this case -10 to +10.
From the far to the "near" plane, objects will become larger as they approach 0, for Z=0 they're in a singularity and blow up infinitely, and then getting closer to near they will become smaller but will be inverted, i.e. rotated by 180° around the Z axis, and depth values being turned around, i.e. depth sorting by depth testing will reject fragments closer to near than to 0.