View Full Version : Synchronisation, threads and glFlush/glFinish

09-26-2005, 11:12 PM

I am trying to synchronize computation and rendering. The computation is done by a thread which calls the display method directly to update the display. Unfortunately glFlush and glFinish do not work to achieve a continuous update of the scene. If I resize the window or do something else that causes glut to call the display method the update takes place even without glFlush or glFinish. display ends with a call to glutSwapBuffers.

Any suggestions? Thanks for your help!

09-27-2005, 12:03 AM
You cannot make OpenGL calls from a secondary thread in GLUT (since you have no way to make the GLUT context current in the secondary thread), and in general, you have to be /very/ careful about ensuring that only one thread can make calls into a particular context at once.

I suggest doing ONLY your computation in the secondary thread, and doing all your rendering from the main thread.

09-27-2005, 12:26 AM
Thank you for the answer! I already thougt about contexts, but I was not really sure about this. What if I pass the window id I got form glut to the thread? Can I use glutSetWindow to make the context current? Will it help to use another GUI API for example Gtk with gtkglext? I will lock the context with a mutex to prevent that more than one thread renders to it.

09-28-2005, 10:36 PM
Search for some answers on multithreaded OpenGL programming from me in the "OpenGL under Windows" forum.