I have a little problem in my current project because i do want tu use an objects method when creating my thread. i red that it is impossible without declare this method as static.
Any idea ?
public:
CModelisation (int argc, char **argv, char[]);
~CModelisation ();
void Init ();
void *RunMainLoop (void* args);
};
CModelisation.cpp
void *CModelisation::RunMainLoop (void* args)
{
glutDisplayFunc(Display);
glutIdleFunc(Display);
glutReshapeFunc(Redisplay);
glutMotionFunc(Mouse);
glutKeyboardFunc(Keyboard);
glutMainLoop();
return args;
}
Main
threads[1] = new CThread();
threads[1]->exec(Model->RunMainLoop,(void*)1);
THX !
I believe it’s common practice to create a wrapper function for any thread-method:
Passing additional parameters needs a bit more effort, but that’s the general idea.
Fortunately,
std::threadfrom the next standard makes our life much easier… but that’s still in the future.