【发布时间】:2014-02-13 09:43:03
【问题描述】:
我正在尝试将我从 Windows 编写的使用 SFML 和 OpenGL 的 c++ 程序移植到 Mac OS X。我正在使用 g++ 在两个平台上进行编译。
这是我当前计算投影矩阵的代码:
void perspectiveCalculate (int width, int height) {
// Prevent A Divide By Zero
if (height<1) height=1;
if (width<1) width=1;
glViewport(0, 0, width, height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
//field of vision , width , height , near clipping , far clipping
//and calculate The Aspect Ratio Of The Window
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 1000.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
但是,g++ 表示不推荐使用 gluPerspective,我应该改用 GLKMatrix4MakePerspective。我在函数上找到了the manual page,但我不确定如何将它与我的其余代码集成。我该怎么办?
【问题讨论】: