wglMakeCurrent in threads

Hi !

Is it important to call to “wglMakeCurrent (NULL,NULL)” in a thread before another thread will make its own context current ?

I mean:

wglMakeCurrent (hdc,hglrc1);
… do stuff
wglMakeCurrent (NULL,NULL);

wglMakeCurrent (hdc,hglrc2);
… do stuff
wglMakeCurrent (NULL,NULL);

Or are the calls to wglMakeCurrent (hdc,hglrc1) and wglMakeCurrent (hdc,hglrc2) enough ?

Thanks in advance.

wglMakeCurrent() can be called concurrently from any thread, as long as you don’t attempt to make a context current in thread2 that is already current in thread1. A context can only be current to one thread at any time.

Apart from this, your scenario (rendering into the same HDC concurrently via two threads) is most probably not possible and will result in an error.

How do you know that he is using same hdc? Maybe this is local var…

I use the same hdc. Since I use the function getDC to get the hdc, i thought there was no need to create 2 hdc, one per thread.
Actually, this works nice… How would you create the second hdc ? Calling getDC in the second thread ?

ps: i’m really new in opengl under windows…

You may use the same HDC in both threads, but not at the same time.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.