]> git.cworth.org Git - apitrace/blobdiff - glretrace.py
Tweaks.
[apitrace] / glretrace.py
index 0724cff5aeb9078c543921228e0a9a29bd0b0c6d..20e48752f937c39e033451a5a198aca83a972830 100644 (file)
 
 import stdapi
 import glapi
-import retrace
-
-
-class GlRetracer(retrace.Retracer):
-
-    pass
+from retrace import Retracer
+
+
+class GlRetracer(Retracer):
+
+    def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
+        if function.name in [
+            "glColorPointer",
+            "glEdgeFlagPointer",
+            "glIndexPointer",
+            "glNormalPointer",
+            "glTexCoordPointer",
+            "glVertexPointer",
+            "glFogCoordPointer",
+            "glSecondaryColorPointer",
+            "glVertexAttribPointer",
+        ] and arg.name == 'pointer':
+            self.extract_pointer(function, arg, arg_type, lvalue, rvalue)
+        else:
+            Retracer.extract_arg(self, function, arg, arg_type, lvalue, rvalue)
+
+    def extract_pointer(self, function, arg, arg_type, lvalue, rvalue):
+        print '    if (dynamic_cast<Trace::Null *>(&%s)) {' % rvalue
+        print '        %s = 0;' % (lvalue)
+        print '    } else {'
+        print '        %s = (%s)(uintptr_t)(%s);' % (lvalue, arg_type, rvalue)
+        print '    }'
 
 
 if __name__ == '__main__':