JoeJ said:
May be worth to try.
seems not worth it: https://stackoverflow.com/questions/11097170/multithreaded-rendering-on-opengl
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
JoeJ said:
May be worth to try.
seems not worth it: https://stackoverflow.com/questions/11097170/multithreaded-rendering-on-opengl
After experimenting with serveral cards, the correct prseudo-code (IMO) is
void DrawGL( QOpenGLWindow * win )
{
theDrawMutex.lock();
QOpenGLContext * ctx = GetContextForCurrentThread(win);
ctx->makeCurrent(win);
... // setup shaders etc
glDrawElements(...);
...
win->swapBuffers();
theDrawMutex.unlock();
}
For drawing in main thread the GetContextForCurrentThread can return just win->context() that was created in main thread. For drawing from other thread need a context shared with win→>context() but created in this thread
Thx
Doesn't locking undermine the whole point of rendering in a background thread? With the underlying shared context you shouldn't need explicit locking in your code.