首页 > 其他 > 详细

OpenGL4.x不支持gluPerspective函数。故备份之

时间:2014-03-07 05:27:27      阅读:440      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
template <typename type>
inline mat4<type> mat4<type>::perspectiveProjection(type fovy, type aspect, type zNear, type zFar)
{
    type f = (type) 1 / tan(radians(fovy) / 2);
    return mat4<type>(f / aspect, 0, 0,                         0,
                      0,        f, 0,                         0,
                      0,        0, (zFar + zNear) / (zNear - zFar), (2*zFar*zNear) / (zNear - zFar),
                      0,        0, -1,                        0);
}

template <typename type>
inline mat4<type> mat4<type>::orthoProjection(type xRight, type xLeft, type yTop, type yBottom, type zNear, type zFar)
{
    type tx, ty, tz;
    tx = - (xRight + xLeft) / (xRight - xLeft);
    ty = - (yTop + yBottom) / (yTop - yBottom);
    tz = - (zFar + zNear) / (zFar - zNear);
    return mat4<type>(2 / (xRight - xLeft), 0,                  0,                tx,
                       0,                  2 / (yTop - yBottom), 0,                ty,
                       0,                  0,                 -2 / (zFar - zNear), tz,
                       0,                  0,                  0,                1);
}
bubuko.com,布布扣

OpenGL4.x不支持gluPerspective函数。故备份之,布布扣,bubuko.com

OpenGL4.x不支持gluPerspective函数。故备份之

原文:http://www.cnblogs.com/nmgxbc/p/3585315.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!