the right way to share contexts ?

Hello,
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 ?

thanks,
lobbel

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.

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.