如果没有Glu,我怎么能像GluPerspective一样呢? 谢谢
例如:gluPerspective(45.0,(float)w /(float)h,1.0,200.0);
void gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar ) { GLdouble xmin, xmax, ymin, ymax; ymax = zNear * tan( fovy * M_PI / 360.0 ); ymin = -ymax; xmin = ymin * aspect; xmax = ymax * aspect; glFrustum( xmin, xmax, ymin, ymax, zNear, zFar ); }
它在gluPerspective
文档中相当清楚地解释了。 您只需构建适当的4×4转换矩阵并使用glMultMatrix
将其乘以当前转换:
void myGluPerspective(double fovy, double aspect, double zNear, double zFar) { double f = 1.0 / tan(fovy * M_PI / 360); // convert degrees to radians and divide by 2 double xform[16] = { f / aspect, 0, 0, 0, 0, f, 0, 0, 0, 0, (zFar + zNear)/(zNear - zFar), -1, 0, 0, 2*zFar*zNear/(zNear - zFar), 0 }; glMultMatrixd(xform); }
请注意,OpenGL以列为主的顺序存储矩阵,因此上面的数组元素的顺序是从gluPerspective
文档中的内容转换而来的。
以上就是c/c++开发分享GLUP的原始OpenGL等价物?相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/549670.html