diff options
author | Eric Anholt <eric@anholt.net> | 2013-12-17 14:18:49 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-17 14:34:02 -0800 |
commit | 3ae4726cdbb0fccdb02bcdba07662fe6f6a15589 (patch) | |
tree | 944936c15ab0f18805dc49671378ab81c03b12e9 | |
parent | c4214a39f4ef941316042d48cabfbd826cc7a07f (diff) |
win32: Expose the dispatch table reset funtion in the public API.
Fixes #2.
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | include/epoxy/wgl.h | 1 | ||||
-rw-r--r-- | src/dispatch_wgl.c | 23 |
3 files changed, 28 insertions, 7 deletions
@@ -108,3 +108,14 @@ We had to solve some of GLEW's problems for piglit and solving them meant replacing every single piece of GLEW, so we built piglit-dispatch from scratch. And since we wanted to reuse it in other GL-related projects, this is the result. + +win32 issues +------------ + +The automatic per-context symbol resolution for win32 requires that +epoxy knows when ```wglMakeCurrent()``` is called, because +wglGetProcAddress() return values depend on the context's device and +pixel format. If ```wglMakeCurrent()``` is called from outside of +epoxy (in a way that might change the device or pixel format), then +epoxy needs to be notified of the change using +```epoxy_handle_external_wglMakeCurrent()```. diff --git a/include/epoxy/wgl.h b/include/epoxy/wgl.h index fe6a67e..8d0af5a 100644 --- a/include/epoxy/wgl.h +++ b/include/epoxy/wgl.h @@ -49,6 +49,7 @@ extern "C" { #include "epoxy/wgl_generated.h" bool epoxy_has_wgl_extension(HDC hdc, const char *extension); +void epoxy_handle_external_wglMakeCurrent(void); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/dispatch_wgl.c b/src/dispatch_wgl.c index 743136e..a0b7277 100644 --- a/src/dispatch_wgl.c +++ b/src/dispatch_wgl.c @@ -59,8 +59,17 @@ epoxy_has_wgl_extension(HDC hdc, const char *ext) return epoxy_extension_in_string(getext(hdc), ext); } -static void -reset_dispatch_table(void) +/** + * Does the work necessary to update the win32 per-thread dispatch + * tables when wglMakeCurrent() is called. + * + * Right now, we just reset everything to "do wglGetProcAddress() + * again". This could be improved in the future to track a resolved + * dispatch table per context and reuse it when the context is made + * current again. + */ +PUBLIC void +epoxy_handle_external_wglMakeCurrent(void) { gl_init_dispatch_table(); wgl_init_dispatch_table(); @@ -96,7 +105,7 @@ DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved) data = LocalAlloc(LPTR, wgl_tls_size); TlsSetValue(wgl_tls_index, data); - reset_dispatch_table(); + epoxy_handle_external_wglMakeCurrent(); break; case DLL_THREAD_DETACH: @@ -123,7 +132,7 @@ WRAPPER(epoxy_wglMakeCurrent)(HDC hdc, HGLRC hglrc) { BOOL ret = epoxy_wglMakeCurrent_unwrapped(hdc, hglrc); - reset_dispatch_table(); + epoxy_handle_external_wglMakeCurrent(); return ret; } @@ -137,7 +146,7 @@ WRAPPER(epoxy_wglMakeContextCurrentARB)(HDC hDrawDC, BOOL ret = epoxy_wglMakeContextCurrentARB_unwrapped(hDrawDC, hReadDC, hglrc); - reset_dispatch_table(); + epoxy_handle_external_wglMakeCurrent(); return ret; } @@ -151,7 +160,7 @@ WRAPPER(epoxy_wglMakeContextCurrentEXT)(HDC hDrawDC, BOOL ret = epoxy_wglMakeContextCurrentEXT_unwrapped(hDrawDC, hReadDC, hglrc); - reset_dispatch_table(); + epoxy_handle_external_wglMakeCurrent(); return ret; } @@ -162,7 +171,7 @@ WRAPPER(epoxy_wglMakeAssociatedContextCurrentAMD)(HGLRC hglrc) { BOOL ret = epoxy_wglMakeAssociatedContextCurrentAMD_unwrapped(hglrc); - reset_dispatch_table(); + epoxy_handle_external_wglMakeCurrent(); return ret; } |