]> git.cworth.org Git - apitrace/commitdiff
mt trace: wgl: track GL context on a per-thread basis
authorImre Deak <imre.deak@intel.com>
Wed, 23 May 2012 07:57:12 +0000 (10:57 +0300)
committerImre Deak <imre.deak@intel.com>
Wed, 23 May 2012 08:30:01 +0000 (11:30 +0300)
Wrap WGL context handling calls and keep our own per-thread basis track
of the context object.

Signed-off-by: Imre Deak <imre.deak@intel.com>
wrappers/wgltrace.py

index f345869b684f4e6090ad5c169d02f2699a272903..f7625c6d895622a98d4470f4d35f1aac01376d7e 100644 (file)
@@ -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