gluLookAt()和glFrustum()之间有区别吗?

and*_*and 11 opengl

我的导师说他们可以互换使用来影响投影矩阵.他认为,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)

Kos*_*Kos 12

二者glFrustumgluLookAt执行简单的矩阵乘法.查看手册页以获取这些矩阵的方程式:

gluLookAt

glFrustum

这两个都可以被glMultMatrix*呼叫取代.

最重要的区别在于glFrustum大部分时间用于建立透视投影矩阵(由内部使用gluPerspective),并且gluLookAt是用于指定模型 - 视图矩阵的便利方法(通常:实现摄像机).