You will be fine as long as your glut init stuff is called from the same thread that you later call theglut loop stuff. As long as the GL context and the GL work is all in the same thread, you are fine. I've done this myself.

FreeGlut is NOT thread safe, but its not thread unsafe, its thread ignorant. You need to put locks around the free glut calls yourself so that you aren't mucking with stuff you are going to have free glut draw while freeglut is trying to draw.


From: Adam O'Donovan <>
Sent: Wednesday, April 29, 2009 11:37:58 AM
Subject: [Freeglut-developer] Question about thread safety.

I would like to know if freeglut is thread safe.  Specifically, I would like to have a child thread handle all of the windowing and user interaction. The reason for this is that I have a lot of existing scientific code that does not currently display any of the data that it computes.  What I would like to do is develope a library that would allow me to very easily plot data as computation proceeds.  I want the change to the existing code to be minimal,  for instance simply inserting a call like surface(data);  into the code should open a window and plot the matrix data held in "data" to the screen like matlab would for instance.  It seems that to do this I need to call the glutMainLoop in a secondary thread so that the scientific code can continue executing in the main thread.  However, I have found that glut is not thread safe and does not support calling the glutMainLoop function from any thread other than the main thread.  I would like to know if this is also the case with freeglut.  Or if you have any suggestions for how to impliment this type of graphics library.