在代码中复制GLM::透视图
Replicating GLM::perspective in code
我理解glm::透视有困难。我知道它的作用,但不明白它的原理。有人知道源代码/程序是什么吗?
这都是开源的,看看代码:
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> perspective
(
valType const & fovy,
valType const & aspect,
valType const & zNear,
valType const & zFar
)
{
assert(aspect != valType(0));
assert(zFar != zNear);
#ifdef GLM_FORCE_RADIANS
valType const rad = fovy;
#else
# pragma message("GLM: perspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
valType const rad = glm::radians(fovy);
#endif
valType tanHalfFovy = tan(rad / valType(2));
detail::tmat4x4<valType, defaultp> Result(valType(0));
Result[0][0] = valType(1) / (aspect * tanHalfFovy);
Result[1][1] = valType(1) / (tanHalfFovy);
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
Result[2][3] = - valType(1);
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
return Result;
}
…它根据gluPerspective()
文档创建一个矩阵。
相关文章:
- 了解 GLM- openGL 中的相机转换
- OpenGl glm rotate
- OpenGL 和 GLM 矩阵无法正确扩展,总是按比例缩小
- 发布旋转矩阵(openGL/glm)
- 如何在 glRotatef 中使用 glm::mat4
- OpenGL 转换无法使用 GLM 矩阵
- 将 glm.mat4 从 Python 传回 C++ (glm::mat4)
- OpenGL GLM 矩阵/向量未正确初始化
- 通过零参数构造函数创建的 glm::mat4 应该包含哪些值?
- 在OpenGL(GLM/C++)中使用四元数旋转时出现问题
- 将2个欧拉角与GLM相结合的问题
- GLM中的Java Matrix4.transform等价物
- 在 X 轴上移动摄像机 glm::lookat()
- GLM 角度轴错了?
- 给定方向和位置如何使用 GLM 计算旋转矩阵
- 带有"up-"和"center-vec3"参数的glm::rotate()的有效替代方案?
- GlM(OpenGl Mathematics)库阻止M_PI和其他定义的常量工作
- 尝试在构造函数中的"glm::cross"处初始化我的类段错误
- OpenGL/GLFW/GLM-键盘输入无反应
- 在代码中复制GLM::透视图