View Full Version : the right way to share contexts ?

09-28-2010, 01:49 AM
how do I share contexts of different threads correctly ?
I create a main render context in the main thread.
Where do I have to create the second thread? The second thread
does so loading stuff. Guess I should create the second one in
the second thread right ? But when sharing the context, in what
thread should I call wglShareLists ?


Rosario Leonardi
09-28-2010, 04:32 AM
it's not important you can even create both contexes at the beginnig an then call wglShareList. The important part is the wglMakeCurrent, each thread must have its current thread.

09-28-2010, 08:50 PM
Contexts are like global variables so you can create them all in your main thread. Then use wglShareLists with each context in your main thread. After that, you can call wglMakeCurrent from a thread and it will will bind the context to that thread.

I don't think it matters what thread you call wglShareList from, but it only works with contexts that are not currently bound so it should be called first.