替换以下代码:void specialKeyboard(int key, int x, int y) { switch (key) { case GLUT_KEY_PLUS; circleGrayScale += 0.1f; if (circleGrayScale > 1.0f) circleGrayScale = 1.0f; break; case GLUT_KEY_MINUS: circleGrayScale -= 0.1f; if (circleGrayScale < 0.0f) circleGrayScale = 0.0f; break;
时间: 2023-12-27 12:03:23 浏览: 66
openGL.management.files.rar_GLUT_glut.h pudn_glut.lib_glut32.lib
void specialKeyboard(int key, int x, int y) {
switch (key) {
case GLUT_KEY_PLUS:
circleGrayScale += 0.1f;
if (circleGrayScale > 1.0f)
circleGrayScale = 1.0f;
break;
case GLUT_KEY_MINUS:
circleGrayScale -= 0.1f;
if (circleGrayScale < 0.0f)
circleGrayScale = 0.0f;
break;
default:
break;
}
}
我只是将分号替换为冒号,这是因为在 switch 语句中,每个 case 语句的最后都应该使用一个冒号。此外,我添加了一个默认情况,以处理任何未匹配到的键盘事件。
阅读全文