There is no difference between threads, a thread is a thread. As long as you call glutMainLoop from the _same_ thread that creates the window and context, you should be fine.
 
Freeglut is no more or less thread sage than OpenGL. You have one context per thread.
 
Freeglut should work fine as long as all your freeglut calls and OpenGL calls are issued from one thread. In your post below, you say you want one thread to "handle all of the windowing and user interaction"; not a lot of detail but if I understand you correctly, that's also the thread that will call OpenGL and freeglut, so freeglut will work for you in that case.
 
If you have one thread loading memory and another thread reading that memory and making OpenGL calls with the data, then you'll need to access that data block in a thread-safe way. This is not a freeglut issue, and is the same issue you would encounter with any OpenGL app (or any rendering app at all).
 
If I've misunderstood your post, please clarify.
 
Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466
 


From: Adam O'Donovan [mailto:adamod@gmail.com]
Sent: Wednesday, April 29, 2009 11:38 AM
To: freeglut-developer@lists.sourceforge.net
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. 

Thanks,
Adam