glFrustum()和gluPerspective()详解

来源:互联网 发布:js日期格式化yyyymmdd 编辑:程序博客网 时间:2024/06/05 16:36

1、void glFrustum(GLdouble left,GLdouble Right,GLdouble bottom,GLdouble top,GLdouble zNear,GLdouble zFar);

left,right       表示近平面左右两边相对于垂直平面的位置
bottom,top   表示近平面顶和底相对于水平面的位置
zNear和zFar是表示视点到远近投影平面的距离
2、gluPerspective(GLdouble fovy,GLdouble aspect,GLdouble zNear,GLdouble zFar);
    fovy是视角的大小,以度为单位; aspect = w/h 是视景体的宽高比


gluPerspective函数是对glFrustum函数的一种简单封装,那么gluPerspective的参数如何转化为glFrustum的参数呢?

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);}


参照博客:

http://www.linuxidc.com/Linux/2014-03/98825.htm

http://www.2cto.com/kf/201504/389187.html

      

0 0