Hi all,

I writed a opengl program and i want to use perspective projection, but i can’t show my scence correct, how can i understand what is best value for gluprespective and glulookat?!
if anyone wants also i can send my code in private message, but i can’t puted here because it’s my homework!

If it is a homework, you should learn how to do it by yourself.
Maybe I’m boring with my proposals to read something firs, but I think it is essential to have a firm understanding of basic concepts before going any further.
So, please take a look at Chapter 3 of the old red book.

Hey man, i read this part two times! i know all conceptions, but i can’t understand just for example in that chapter in example 3.1 how we can understand that we should set near and far parameter in glfrustum in reshape function to 1.5 and 20!!! i think someone should explain for me so simple like some materials for dummies!!!

Near and far clip-planes should frame all objects in the scene.
Values 1.5 and 20.0 for near and far clip-planes mean: “only objects at distance from 1.5 to 20.0 “units” from the camera will be rendered”.
You are free to choose whatever values you like as long as near clip-plane is not 0.0 and far/near ratio is less than 10e5 (or so).
Value 0.0 will produce a singularity in a perspective projection matrix, while the ratio greater than 10e5 will probably make artifacts caused by z-fighting.

As a rule of thumb, half of the range of depth values will be mapped to the Z range [zNear,2zNear] and the other half to [2zNear,zFar]. Similarly, 90% of the depth range will be mapped to [zNear,10zNear] versus 10% for [10zNear,zFar], and more generally [N*zNear,zFar] gets roughly 1/N of the range.

E.g. if zNear is 1 and zFar is 1000, the Z range [1,10] (the closest 1% to the near plane) gets 90% of the depth range and the range [10,1000] (the other 99%) gets the other 10%.

IOW, the greater the ratio zFar/zNear, the greater the non-linearity in the depth values, i.e. the more they’ll be clustered close to the near plane, resulting in poor depth resolution in the rest of the scene.