我正在尝试使用 gluLookAt() 函数来控制放大和缩小。现在它根本没有改变矩阵,我不知道为什么。
以下是相关代码:
// Basic Opengl display function
void onDisplay()
{
// Clear the initial buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Set up viewing transformation, looking down -Z axis
glLoadIdentity();
gluLookAt(0, 0, zPosition, 0, 0, -1, 0, 1, 0);
// Draw the complete Mandelbrot set picture
glDrawPixels(520, 520, GL_RGB, GL_FLOAT, pixels);
//glLoadIdentity();
glutSwapBuffers();
}
void keyPressed (unsigned char key, int x, int y)
{
if(key == 'w')
{
printf("pressed %a", key);
printf("\n");
zPosition -= 1.0;
glutPostRedisplay();
}
}
它与 glLoadIdentity() 调用有关吗?我对openGL中的不同身份不太熟悉。
那么如何更改此代码以在 w 放大时进行按键操作?