gluPerspective

BlitzMax Forums/BlitzMax OpenGL Programming/gluPerspective

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

gluPerspective() takes the vertical fov, aspect, and near and far view ranges. I want the viewport to always use the same horizontal fov, and adjust the vertical fov so that it isn't stretched, regardless of the viewport height.

Viewport width=1024
Viewport height=768
desired horizontal fov=90 degrees

The aspect is the width divided by the height, which is 1024/768=1.33333333. I tried this:

gluPerspective 90.0/1.3333333,1.3333333,near,far

But this did not give me a little less than 90 degrees view in the horizontal direction. The only way I could get a perfect 90-degree view in the horizontal direction was like this:

gluPerspective 90.0/1.3333333,1.5,near,far

What's going on here? I noticed that 90.0/1.3333333/1.5=45.0, which might be significant.

Then I tried using glFrustum:
glfrustum -nearrange/zoom,nearrange/zoom,-nearrange/aspect/zoom,nearrange/aspect/zoom,nearrange,farrange

When zoom=1.0, I get a perfect 90-degree fov in the horizontal direction. However, when I try changing zoom to 2.0, for a 45-degree fov, I get a somewhat larger fov in the horizontal direction (approximately 50-60 degrees).