🎉 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!

OpenGL loading in a second thread causing stutter in main thread?

Started by
20 comments, last by wintertime 3 years, 5 months ago

Afaik the method others use different from yours:

There at the beginning the contexts get sharing enabled, then the loading thread does glFinish, then signals the main thread it can use the buffers, then the next time the main thread starts the game loop it does the vertex settings and uses the buffers.

In your version, at the minimum you need to do a glFinish and deactivate the context after loading and only then signal your main thread. Then on main thread you would activate the different context (try with and without glFinish before changing it), then signal the second thread, which can then activate the other context. This is actually more complicated then never swapping contexts, so I'd expect more stuttering from OpenGL exchanging resources. I do not see from your code when you would call glFinish and if you are using correct signaling between the 2 threads, this is actually the important parts where you might generate the stuttering.

This topic is closed to new replies.

Advertisement