glut DisplayFunctionでオブジェクトを使用する際に問題があります。オブジェクトをglut表示関数に使用
class Modelisation
{
private:
int hauteur, largeur, x, y;
Camera *Cam;
void DisplayFunction();
static void RedisplayFunction (int, int);
public:
Modelisation (int argc, char **argv, char[]);
~Modelisation();
void StartMainLoop();
};
Modelisation.cpp
Modelisation::Modelisation (int argc, char **argv, char windowName [])
{
Cam = new Camera;
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE);
glutCreateWindow (windowName);
};
void Modelisation::StartMainLoop()
{
glutDisplayFunc(DisplayFunction);
glutIdleFunc(DisplayFunction);
glutReshapeFunc(RedisplayFunction);
glutMainLoop();
}
void Modelisation::DisplayFunction()
{
glClearDepth (1);
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
Cam->Render();
glFlush();
glutSwapBuffers();
}
glutDisplayFunc(は、DisplayFunction)。 glutIdleFunc(DisplayFunction);
これは機能しません。 私はDisplayFunctionを静的メンバーとして宣言できますが、これはCamオブジェクトを使用することを許可しません。
Thx !!!
申し訳ありませんが、ヘッダーファイルに静的オブジェクトCamを宣言するにはどうすればよいですか? – Athanase
ヘッダファイルに 'static Camera * Cam;'と宣言します。 – Adrian
申し訳ありませんが、私は間違いを犯しました。これは完全に機能します。私はこのフォーラムで質問をすると、いつも完璧な答えを得る。ありがとうございました !! – Athanase