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