Bail on pointer arrays.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 20:22:39 +0000 (20:22 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 25 Nov 2010 20:22:39 +0000 (20:22 +0000)
glretrace.py
retrace.py

index 792bdd8..549a14e 100644 (file)
@@ -40,6 +40,16 @@ class GlRetracer(Retracer):
             "glBufferRegionEnabled",
         ]
 
+    def call_function(self, function):
+        if function.name in ("glDrawArrays", "glDrawElements", "glDrawRangeElements", "glMultiDrawElements"):
+            print '    GLint __array_buffer = 0;'
+            print '    glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);'
+            print '    if (!__array_buffer) {'
+            self.fail_function(function)
+            print '    }'
+
+        Retracer.call_function(self, function)
+
     def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
         if function.name in [
             "glColorPointer",
index 6dfd0a2..0c14855 100644 (file)
@@ -173,14 +173,8 @@ class Retracer:
                 success = False
                 print '    %s = 0; // FIXME' % arg.name
         if not success:
-            print '    std::cerr << "warning: unsupported call %s\\n";' % function.name
-            print '    return;'
-        arg_names = ", ".join([arg.name for arg in function.args])
-        if function.type is not stdapi.Void:
-            print '    %s __result;' % (function.type)
-            print '    __result = %s(%s);' % (function.name, arg_names)
-        else:
-            print '    %s(%s);' % (function.name, arg_names)
+            self.fail_function(function)
+        self.call_function(function)
         for arg in function.args:
             if arg.output:
                 arg_type = ConstRemover().visit(arg.type)
@@ -200,9 +194,21 @@ class Retracer:
         print '}'
         print
 
+    def fail_function(self, function):
+        print '    std::cerr << "warning: unsupported call %s\\n";' % function.name
+        print '    return;'
+
     def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
         ValueExtractor().visit(arg_type, lvalue, rvalue)
 
+    def call_function(self, function):
+        arg_names = ", ".join([arg.name for arg in function.args])
+        if function.type is not stdapi.Void:
+            print '    %s __result;' % (function.type)
+            print '    __result = %s(%s);' % (function.name, arg_names)
+        else:
+            print '    %s(%s);' % (function.name, arg_names)
+
     def filter_function(self, function):
         return True