]> git.cworth.org Git - apitrace/commitdiff
Guess the window size from glViewPort.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 29 Nov 2010 12:23:35 +0000 (12:23 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 29 Nov 2010 12:23:35 +0000 (12:23 +0000)
TODO
glretrace.py

diff --git a/TODO b/TODO
index 64d3f0263b623b9191659d5e5af6bc11283a7da2..a8567c71998937d68ca36447039a8283af07d025 100644 (file)
--- a/TODO
+++ b/TODO
@@ -28,3 +28,4 @@
     * https://github.com/antirez/linenoise/issues#issue/8
   * http://hg.youterm.com/radare/file/87579f8c5087/src/dietline.c 
 
+* Trace window sizes somehow
index 5442003ef51fc8198dbb994d1ffcb616a0fb8c9b..c5ec3aee463b8638b733e743a680707ef4d34873 100644 (file)
@@ -42,9 +42,21 @@ class GlRetracer(Retracer):
             self.fail_function(function)
             print '    }'
 
+        if function.name == "glViewport":
+            print '    if (x + width > __window_width) {'
+            print '        __window_width = x + width;'
+            print '        __reshape_window = true;'
+            print '    }'
+            print '    if (y + height > __window_height) {'
+            print '        __window_height = y + height;'
+            print '        __reshape_window = true;'
+            print '    }'
+
         if function.name == "glEnd":
             print '    insideGlBeginEnd = false;'
+        
         Retracer.call_function(self, function)
+
         if function.name == "glBegin":
             print '    insideGlBeginEnd = true;'
         else:
@@ -86,6 +98,8 @@ if __name__ == '__main__':
     print
     print 'static bool double_buffer = false;'
     print 'static bool insideGlBeginEnd = false;'
+    print 'static int __window_width = 256, __window_height = 256;'
+    print 'bool __reshape_window = false;'
     print
     print '''
 static void
@@ -165,6 +179,11 @@ static void display(void) {
 }
 
 static void idle(void) {
+    if (__reshape_window) {
+        // XXX: doesn't quite work
+        glutReshapeWindow(__window_width, __window_height);
+        __reshape_window = false;
+    }
     glutPostRedisplay();
 }
 
@@ -194,7 +213,7 @@ int main(int argc, char **argv)
 
     glutInit(&argc, argv);
     glutInitWindowPosition(0, 0);
-    glutInitWindowSize(800, 600);
+    glutInitWindowSize(__window_width, __window_height);
     glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | (double_buffer ? GLUT_DOUBLE : GLUT_SINGLE));
     glutCreateWindow(argv[0]);