I was wondering if it was safe to make GL calls with multiple threads. Basically I’m using a GLUtesselator and was wondering if I could divide the objects to draw into 4 and assign a thread to each one.
I’m just wondering if this would cause trouble since the tesselator uses callback functions. Can 2 threads run the same callback at the same time as long as that callback does not access ant global variables?
Are there also other ways I could optimize OpenGL drawing using multithreading?
The answer to “Can 2 threads run the same callback at the same time as long as that callback does not access ant global variables?” is a clear YES.
However, you will get problems when you modify the state of OpenGL in your callback functions, especially when using glBegin / glEnd (eg if you generate a DisplayList). As long as you don’t use the GPU (eg if you use a mesh), you can do tesselation with multithreading.
If you want to optimize your drawing, you may want to use the geometry shader for tesselation instead. This requires Shader Model 4.