gluPerspective

BlitzMax Forums/BlitzMax OpenGL Programming/gluPerspective

Well, after drawing it out on paper I saw that this takes a little trig to do. I have never seen a mention of precision zooming with the frustum, so I will post my solution here.

With zoom=1.0, the horizontal fov will be 90.0. With a zoom of 2.0, the horizontal fov will be 45.0 degrees. The vertical fov is dependent on viewport height. The aspect is the viewport width divided by the viewport height:

zoom#=2.0 // for a 45-degree fov. Use 1.0 for 90 degrees.
aspect#=width#/height#
theta#=Tan(45.0/zoom#) // temporary angle value
glfrustum -nearrange#*theta#,nearrange#*theta#,-nearrange#/aspect#*theta#,nearrange#/aspect#*theta#,nearrange#,farrange#