How would you convert a gluPerspective function to glFrustum? I have tried to use this equation, but have not had any luck as it did not generate the same image as it did with gluPerspective.
top = tan(fov*3.14159/360.0) * near bottom = -top
left = aspect * bottom right = aspect * top
I can't seem to convert my field of view correctly. Say, for example, if my FOV was 45, what would be the 'top' param in the Frustum call?
Here we go - you can use the following method as a replacement of the gluPerspective
:
void perspectiveGL( GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar )
{
const GLdouble pi = 3.1415926535897932384626433832795;
GLdouble fW, fH;
//fH = tan( (fovY / 2) / 180 * pi ) * zNear;
fH = tan( fovY / 360 * pi ) * zNear;
fW = fH * aspect;
glFrustum( -fW, fW, -fH, fH, zNear, zFar );
}
You can find some more explanation of the code on the nehe page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With