所以基本上,当我单击鼠标右键时,我需要开始翻译。在某些条件为true
的情况下,无论状态(向上还是向下),都需要继续制作动画。到目前为止,我有这个
double tbr, tyg;
void mouse(int button, int state, int x, int y) {
if (button == GLUT_RIGHT_BUTTON) {
if(tbr < 2.0 && tyg < 2.0) {
do {
tbr+=0.02;
tyg+=0.02;
}
while (0);
}
glutPostRedisplay();
}
}
但是,当我单击鼠标按钮时,它只执行一次,在条件为真时不会继续这样做。如何使用glutIdleFunc()
,glutMotionFunc()
,glutPassiveMotionFunc()
来实现呢?
do {
tbr+=0.02;
tyg+=0.02;
}
while (0); // 0 is false
条件永远不会为真。