🎉 Celebrating 25 Years of GameDev.net! 🎉

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!

Render in other thread

Started by
12 comments, last by swiftcoder 2 years, 12 months ago

JoeJ said:
May be worth to try.

seems not worth it: https://stackoverflow.com/questions/11097170/multithreaded-rendering-on-opengl

Advertisement

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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement