#### Archived

This topic is now archived and is closed to further replies.

# gluPerspective

This topic is 6064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

What should I set parameters of this function to? I keep getting zfighting, and things disapper to quickly when I get close to them. I''ve tried changing znear, but it doesn''t help much. What values do you all use???

##### Share on other sites
It''s the ratio between near and far that is the most important. I try to make sure that (far == 100 * near). That seems to be adequate in most cases.

##### Share on other sites
Here''s a part of my post in the Draw Distance thread, hope this helps.

gluPerspective( fov, ratio, near, far );

fov - this variable is the field of view (you probably know this) to either side of center, so it''s half of the total field of view. So if you wanted the fov to be 90 deg, then you would set this to 45.

ratio - the aspect ratio of the screen, this is just width/height, I would suggest using your resolution in that ratio, but 4/3 (1.3333f) should work for most standard resolutions.

near - the near clipping. This is how far from the camera an object must be to still be drawn on the screen. Set this to a very small value, I had it at 0.1f.

far - far clipping. This is how deep the depth buffer will be. If you''re going to use a skybox and you want each polygon to be 50 units away from the camera, you will need to set this at least to the square root of triple 50 squared (I''m assuming you know the pythagorean theorem and probably trigonometry too) to prevent the corners from being clipped. So, for a distance of 50, you''ll want to set this to at least 87.

##### Share on other sites
about the skybox its not important how big it is,
because the skybox doesnt contain depth info.
u are correct that the values have to be within near-far range though.

##### Share on other sites
Ummm if say your skybox is 50 units away from the camera at the center of each polygon, and your far distance is closer than 86.something, then you will get the skybox clipped, so yes, it does matter how far away things are clipped for your skybox.

• 47
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631374
• Total Posts
2999647
×