From: Imre Deak Date: Wed, 23 May 2012 07:57:12 +0000 (+0300) Subject: mt trace: wgl: track GL context on a per-thread basis X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=2f75bb4a8b8c9c7ae303e88671e5c233174208f4;p=apitrace 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 --- 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