I need to have uninterrupted display (with no drop) of frames for a psychophysical experiment. For that purpose, I need to spawn a thread dedicated to the display (and redisplay) of my screen. I know how to set the policy of and create and parameterize a new thread. My OpenGL code is also up and running (when I do not use multithreading). Can someone help me tell me (or preferrably give me an outline code) for how to make my OpenGL display function a thread.
I have tried to pass the pointer to my thread to the glutDisplayFunc() and glutIdleFunc(). It works but there are some minor problems (e.g. the program instead of going to the glutMainLoop(), exits after the first round of display.
Here is a simplified version of my main()
int main(int argc, char **argv)
if ( (status=pthread_attr_init(&pth_att)) != 0 )
if ( (status=pthread_attr_setdetachstate(&pth_att, PTHREAD_CREATE_DETACHED)) != 0 )
if ( (status=pthread_create(&p_th, &pth_att, pth_main, NULL)) != 0 )
window = glutCreateWindow("bla bla bla");
Thanks for any help.