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
헤더 파일에 '정적 Camera * Cam;'으로 선언하십시오. – Adrian
죄송합니다. 실수를했습니다. 완벽하게 작동합니다. 나는이 포럼에서 질문 할 때 항상 완벽한 답을 얻습니다. 고맙습니다 !! – Athanase