[wxGLCanvas] GL commands don't work
David Donaldson
comejoinus1 at gmail.com
Tue Jul 24 11:28:47 PDT 2007
>Can you please give reference about this? Afaik, it is sufficient to
make the context
current in
>the current thread; as it can only be current in one thread anyway,
this automatically
makes it
>"uncurrent" in the previous thread.
>Making contexts current is possible with regular wxWidgets API.
>Best,
>Carsten
Unfortunately the MSDN page is a big vague on the subject:
http://msdn2.microsoft.com/en-us/library/ms537558.aspx
"A rendering context can be current to only one thread at a time. You
cannot make a rendering context current to multiple threads. "
This implies that you can't call wglMakeCurrent on a context that is
already current in another thread. Also, I think it would be poor
design to allow one thread to steal the context out from under
another.
More importantly, I've tested this. Try creating a couple threads and
have each run this code (one at a time). With the lines commented out,
the program fails when the second thread calls wglMakeCurrent (mine
actually crashes).
bool makeGLCalls( HDC hdc, HGLRC hglrc, float draw_angle )
{
bool result = true;
result = result && wglGetCurrentContext() == NULL;
result = result && wglMakeCurrent( hdc, hglrc );
result = result && wglGetCurrentContext() == hglrc;
//result = result && wglMakeCurrent( NULL, NULL );
//result = result && wglGetCurrentContext() == NULL;
return result;
}
The code from SetCurrent is a thin wrapper for wglMakeCurrent, and it
doesn't allow you to specify the HGLRC argument to wglMakeCurrent as
NULL, so it is not possible to release the context from wxWidgets (on
Windows, at least).
Hope this helps,
David
More information about the wx-users
mailing list