Hello everyone.
I had some problems regarding the perspective projection.

Well this is what i tried:

glLoadIdentity (); 
gluLookAt (0.0, 0.0, 200 , 0.0, 0.0, 0.0,0.0,1.0,0.0);

glLoadIdentity (); 
glFrustum(-150.0 , 150 , -150.0 ,150.0 ,100.0 ,300.0);
glutWireCube (100);
glFlush ();

Now im not able to figure out as to how the near and far planes are specified.

Here, if i give near = 50 and far = 300, the cube appears smaller as compared to near = 100 and far = 300.

I am confused as to how exactly the near and far are specified it with respect to the camera position or something else?

Can anyone please explain?
Thanks in advance.

With glFrustum, the left/right/bottom/top extent values are specified on the near clip plane. If you move your near clip plane further away from you, it of course makes your frustum (the view of the world you see) from the eyepoint “narrower”. This has the effect of magnifying things within this narrow frustum.

Consider using gluPerspective instead for starters. I think you’ll find it more intuitive. Under the hood it just uses glFrustum, but it let’s you fix your X FOV and Y FOV to specific numbers, so that no matter where you set the near and far planes, you always see the same “angular slice” of the world – just at different start and end depths based on your near/far plane settings.

You can look at the Mesa3D code when you’re ready to see how the math for that works. It’s just a little trig problem. Or you can just figure it out yourself for fun.

Thanks a lot Dark Photon.

If you move your near clip plane further away from you,

By “you”, you mean the camera position specified by gluLookAt().Am i right?

No, you, Mukund, in real life :wink: Leave the virtual camera in the same position. We’re talking about the 5th argument to glFrustum here, which defines how far out in the world “away from the virtual eyepoint” that you establish with gluLookAt, the near face of your view frustum is.

Yeah got it…Thanks once again Dark Photon :slight_smile: