オブジェクトファイルをロードするOpenGLプロジェクトがあります.オブジェクトがロードされた後、キーボードでスムーズに移動できるようにしたいので、このコードブロックを書いて仕事をします:
while (remains) {
if (x_remains) {
refPosition[0] += speed.x;
if (refPosition[0] > nextPos[0]) {
x_remains = false;
}
}
if (y_remains) {
refPosition[1] += speed.y;
if (refPosition[1] > nextPos[1]) {
y_remains = false;
}
}
if (z_remains) {
refPosition[2] += speed.z;
if (refPosition[2] >= nextPos[2]) {
z_remains = false;
}
}
remains = x_remains || y_remains || z_remains;
glutPostRedisplay();
}
ご覧のとおり、その間にシーンを再表示したいのですが、これが実行されると、 glutpostredisplay() がフラグを設定するだけで、メインループの次の繰り返しでシーンが再描画されます。私の質問は、while の次のループの前と関数が戻る前にシーンを再描画する方法です。