PDA

View Full Version : threaded application in opengl



strattonbrazil
07-23-2007, 08:18 AM
I'm using an application that renders several visualization widgets in OpenGL using GLSL. The application is heavily threaded and we started to see crashed when things using the shaders appeared in multiple windows.

Right now there is no context controls in the code, and was wondering if these crashes were because of it. If so, it there a good place to find more information on threaded OpenGL calls? I've tried a mutex lock on binding the GLSL calls and flushing the buffer with glFlush, but still get the crash.

dimensionX
07-23-2007, 09:50 AM
Read the MSDN docs for OpenGL context with multiple threads.

You cannot make the same context current for different threads. To use OpenGL with multiple threads simultaneously.

loicm
07-24-2007, 06:55 AM
One of the solution used by some canvases using OpenGL is to create a thread dedicated to the rendering with all the calls to OpenGL, and an internal API to push rendering tasks in a queue from other threads. The queue being flushed before the rendering pass.

k_szczech
07-24-2007, 07:44 AM
What loicm described is in my opinion the best solution. No matter how good your threading solutions are, there is still only one physical GPU in the system - you should avoid accessing this resource at random from different threads.

Hampel
07-25-2007, 02:17 AM
A bit OT, but Intel released their C++ threading library TBB (threading building blocks) as open source: Intel TBB homepage (http://www.threadingbuildingblocks.org/)