由于高版本的Opengl移除了gluPerspective函数,故需要自行编写该函数。
这里是一个由Copilot自动补全的gluPerspective函数,亲测可用。
void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
GLdouble xmin, xmax, ymin, ymax;
ymax = zNear * tan(fovy * 3.14159265 / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}