我的导师说他们可以互换使用来影响投影矩阵.他认为,gluLookAt()由于其"相对简单,因为它能够定义视角" ,因此最好使用它.这是真的?我已经看到了同时使用的代码示例gluLookAt(),并glFrustum()和我不知道为什么会在programmmer混合.
就像在cube.c中出现的红皮书示例:
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glLoadIdentity();
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
**//why isn't this a call to glFrustum?**
glScalef(1.0, 2.0, 1.0);
glutWireCube(1.0);
glFlush();
}
void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
//why isn't this a call a call to gluLookAt()?
glMatrixMode(GL_MODELVIEW);
}
Run Code Online (Sandbox Code Playgroud)