OpenGLのキャンバスに変数とポイントを含むテキスト行を一緒に印刷しようとしています。私のコードは次のとおりです:
void display()
{
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity();
char string[50];
sprintf(string, "Base Rotation: %d", numVertices);
renderMyText(-0.4, 0.35, string);
glPointSize(20);
glBegin(GL_POINTS);
glVertex2f(characterX, characterY);
dx = vertices[numVertices-1].x-ox;
dy = vertices[numVertices-1].y-oy;
dt = glutGet(GLUT_ELAPSED_TIME);
characterX = ox + dx / sqrt(dx*dx+dy*dy) * Velocity * dt;
characterY = oy + dy / sqrt(dx*dx+dy*dy) * Velocity * dt;
printf("%f %f", characterX, characterY);
glEnd();
glFlush();
}
マウスが動いたときにポイントの位置を更新する別の方法を使用しています。そのコードはすべて正常に機能し、正方形はその位置を更新し、テキスト行を追加するまで完全に移動しました。
プログラムを開始すると、正方形とテキストが表示されますが、ウィンドウ内でマウスを動かすと、正方形が消えてテキストのみが残ります。2つをウィンドウに残してください。誰かが何が悪いのかわかりますか?