OpenGL Rendering in a secondary thread OpenGL Rendering in a secondary thread multithreading multithreading

OpenGL Rendering in a secondary thread


As long as the OpenGL context is touched from only one thread at a time, you should not run into any problems. You said even your single threaded program made your system sluggish. Does that mean the whole system or only your own application? The worst that should happen in a single threaded OpenGL program is, that processing user inputs for that one program gets laggy but the rest of the system is not affected.

If you use some compositing window manager (Compiz, KDE4 kwin), please try out what happens if you disable all compositing effects.

When you say X errors do you mean client side errors, or errors reported in the X server log? The latter case should not happen, because any kind of kind of malformed X command stream the X server must be able to cope with and at most emit a warning. If it (the X server) crashes this is a bug and should reported to X.org.

If your program crashes, then there's something wrong in its interaction with X; in that case please provide us with the error output in its variations.


What I did in a similar situation was to keep my OpenGL calls in the main thread but move the vertex arrays preparation to a separate thread (or threads).

Basically, if you manage to separate the cpu intensive stuff from the OpenGL calls you don't have to worry about the unfortunately dubious OpenGL multithreading.

It worked out beautifully for me.


Just in case - the X-Server has its' own sync subsystem.Try following while drawing: man XInitThreads - for initialization
man XLockDisplay/XUnlockDisplay -- for drawing (not sure for events processing);