From 2f75bb4a8b8c9c7ae303e88671e5c233174208f4 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Wed, 23 May 2012 10:57:12 +0300 Subject: [PATCH] mt trace: wgl: track GL context on a per-thread basis Wrap WGL context handling calls and keep our own per-thread basis track of the context object. Signed-off-by: Imre Deak --- wrappers/wgltrace.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py index f345869..f7625c6 100644 --- a/wrappers/wgltrace.py +++ b/wrappers/wgltrace.py @@ -39,6 +39,29 @@ class WglTracer(GlTracer): "wglGetProcAddress", ] + def traceFunctionImplBody(self, function): + GlTracer.traceFunctionImplBody(self, function) + + if function.name == 'wglCreateContext': + print ' if (_result)' + print ' gltrace::createContext((uintptr_t)_result);' + + if function.name == 'wglMakeCurrent': + print ' if (_result) {' + print ' if (hglrc != NULL)' + print ' gltrace::setContext((uintptr_t)hglrc);' + print ' else' + print ' gltrace::clearContext();' + print ' }' + + if function.name == 'wglDeleteContext': + print ' gltrace::Context *current_ctx = gltrace::getContext();' + # Unlike other GL APIs like EGL or GLX, WGL will make the context + # inactive if it's currently the active context. + print ' if (current_ctx == (uintptr_t)hglrc)' + print ' gltrace::clearContext();' + print ' gltrace::destroyContext((uintptr_t)ctx);' + if __name__ == '__main__': print -- 2.45.2