🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Nice frustum?

Started by
1 comment, last by Demon Lord 23 years, 11 months ago
I don''t have any problem in my code, but I''d like some advice. When I display something (like a cube or whatever), it appears really distorted. The front face is like twice as large than the back one. Could someone tell me what is the relation between depth and (apparent) width with the different parameters of setting a frustum? I tried many values, and I know that the further away the near clipping plane is, the lesser the distorsion appear. I currently set my near plane to 100, having a front plane size of 640x480. It is not that important, and I probably can figure it out by trials and errors, but some advice would be nice. EL ---------------------------------------- "Inash neteia haeg joa kavari quilm..." SD4
----------------------------------------"Inash neteia haeg joa kavari quilm..." SD4
Advertisement
If you use gluPerspective, you can''t get it wrong, but sometimes the parameters can be fiddly with glFrustum.

Try this function - it takes the same parameters as gluPerspective, and if you use this you don''t have to include the glu library and so your EXE will be smaller:

    void SetPerspective(double fovy, double aspect, double zNear, double zFar){   double xmin, xmax, ymin, ymax;   ymax = zNear * tan(fovy * PI / 360.0f);   ymin = -ymax;   xmin = ymin * aspect;   xmax = ymax * aspect;   glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);   return;}    


I copied that straight out of the Quake source code...



========
Smidge
www.smidge-tech.co.uk
========
--Mr Smidge
use an orthographic projection so things dont get smaller in the distance, glOrtho(...)
or make the FOV smaller with a perspective projection

This topic is closed to new replies.

Advertisement