鼠标单击开始动画OpenGL / GLUT C ++

问题描述 投票:0回答:1

所以基本上,当我单击鼠标右键时,我需要开始翻译。在某些条件为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()来实现呢?

c++ opengl glut
1个回答
0
投票
do {
    tbr+=0.02;
    tyg+=0.02;
}
while (0); // 0 is false

条件永远不会为真。

© www.soinside.com 2019 - 2024. All rights reserved.