The relationship between gluperspective function and Glfrustum function in OpenGL

Source: Internet
Author: User
Tags in degrees

With regard to these two functions, most of the books and the online double seldom have the information to introduce it. Share some of the things you've explored before today. gluperspective The function is a simple encapsulation of the glfrustum function, so how does the gluperspective parameter convert to the Glfrustum parameter?

We know that the Gluperspective function creates a visual body with a top-down and left-right symmetry. Fovy is the size of the angle of view, in degrees, the aspect is the aspect ratio of the scene body, and Znear and Zfar are the distance from the near-far clipping surface to the viewpoint. Then, as shown, the relationship between the two function parameter conversions can be explained.

from the point of view, the tangent of the fovy angle is multiplied by the znear to get the values of the upper and lower bounds, and the resulting values multiplied by the aspect to obtain the left and right borders of the scene. As a result, the program is not difficult to write. The functions that encapsulate themselves are as follows:

void Myperspective (  gldouble Fovy,   gldouble aspect,   gldouble znear,   gldouble zfar) {gldouble Dbfov = fovy*m_pi/180.0; Gldouble Dbtan = tan (DBFOV/2); Glfrustum (-znear*dbtan*aspect,znear*dbtan*aspect,-znear*dbtan,znear*dbtan,znear, Zfar);}


The relationship between gluperspective function and Glfrustum function in OpenGL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.