即使我已经调用了 glOrtho(),这个函数也不会改变任何东西。代码有什么问题?我错过了什么?
void glKeyCallback(unsigned char key, int x, int y){
if (key == 'z'){
width -= 10; height -= 10;
cout << "Z" << endl;
cout << width << " " << height << endl;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
}else if (key == 'x'){
width += 10; height += 10;
cout << "X" << endl;
cout << width << " " << height << endl;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 100, 100, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
}
}
当我按下 z 或 x 时,我预计场景会放大/缩小。但这并没有改变任何东西。作为记录,我已经在glutKeyboardFunc