Hi OpenGLers,
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)
{
pthread_t p_th;
pthread_attr_t pth_att;
int status;

if ( (status=pthread_attr_init(&pth_att)) != 0 )
exit(1);
if ( (status=pthread_attr_setdetachstate(&pth_att, PTHREAD_CREATE_DETACHED)) != 0 )
exit(2);
if ( (status=pthread_create(&p_th, &pth_att, pth_main, NULL)) != 0 )
exit(3);

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE);
glutInitWindowSize(1024, 768);
glutInitWindowPosition(0, 0);
window = glutCreateWindow("bla bla bla");

InitGL();
glutDisplayFunc(&pth_main);
glutIdleFunc(&pth_main);
glutMainLoop();
return 1;
pthread_exit(NULL);
}

Thanks for any help.

Mehrdad