]> git.cworth.org Git - apitrace/blobdiff - wrappers/wgltrace.py
Use compiler TLS for GL tracing.
[apitrace] / wrappers / wgltrace.py
index 52fd05182f62c3a664d68b378b4ea360591ceaad..317c5422a7d5400e17c9d791c084c630b1ee9d7f 100644 (file)
@@ -39,14 +39,38 @@ class WglTracer(GlTracer):
         "wglGetProcAddress",
     ]
 
+    createContextFunctionNames = [
+        'wglCreateContext',
+        'wglCreateContextAttribsARB',
+        'wglCreateLayerContext',
+    ]
+
+    destroyContextFunctionNames = [
+        'wglDeleteContext',
+    ]
+
+    makeCurrentFunctionNames = [
+        'wglMakeCurrent',
+        'wglMakeContextCurrentARB',
+        'wglMakeContextCurrentEXT',
+    ]
+
     def traceFunctionImplBody(self, function):
+        if function.name in self.destroyContextFunctionNames:
+            # Unlike other GL APIs like EGL or GLX, WGL will make the context
+            # inactive if it's currently the active context.
+            print '    if (_wglGetCurrentContext() == hglrc) {'
+            print '        gltrace::clearContext();'
+            print '    }'
+            print '    gltrace::releaseContext((uintptr_t)hglrc);'
+
         GlTracer.traceFunctionImplBody(self, function)
 
-        if function.name == 'wglCreateContext':
+        if function.name in self.createContextFunctionNames:
             print '    if (_result)'
             print '        gltrace::createContext((uintptr_t)_result);'
 
-        if function.name == 'wglMakeCurrent':
+        if function.name in self.makeCurrentFunctionNames:
             print '    if (_result) {'
             print '        if (hglrc != NULL)'
             print '            gltrace::setContext((uintptr_t)hglrc);'
@@ -54,14 +78,6 @@ class WglTracer(GlTracer):
             print '            gltrace::clearContext();'
             print '    }'
 
-        if function.name == 'wglDeleteContext':
-            # Unlike other GL APIs like EGL or GLX, WGL will make the context
-            # inactive if it's currently the active context.
-            print '    if (_wglGetCurrentContext() == hglrc) {'
-            print '        gltrace::clearContext();'
-            print '    }'
-            print '    gltrace::destroyContext((uintptr_t)hglrc);'
-
 
 if __name__ == '__main__':
     print