]> git.cworth.org Git - apitrace/blobdiff - glretrace.py
Merge branch 'master' into noglut
[apitrace] / glretrace.py
index 31058a2f2e0ce883287f9a53131234eac5407516..450ce7dd19d215648daddaf860321013455f8989 100644 (file)
@@ -169,8 +169,7 @@ if __name__ == '__main__':
 
 #include "glproc.hpp"
 #include "glstate.hpp"
-
-#include <GL/glut.h>
+#include "glws.hpp"
 
 static bool double_buffer = false;
 static bool insideGlBeginEnd = false;
@@ -239,9 +238,10 @@ checkGlError(void) {
     print r'''
 
 static Trace::Parser parser;
-
-static void display_noop(void) {
-}
+static glws::WindowSystem *__ws = NULL;
+static glws::Visual *__visual = NULL;
+static glws::Drawable *__drawable = NULL;
+static glws::Context *__context = NULL;
 
 #include "image.hpp"
 
@@ -288,7 +288,14 @@ static void frame_complete(void) {
             delete ref;
         }
     }
+    
+    if (__reshape_window) {
+        // XXX: doesn't quite work
+        __drawable->resize(__window_width, __window_height);
+        __reshape_window = false;
+    }
 
+    __ws->processEvents();
 }
 
 static void display(void) {
@@ -313,21 +320,14 @@ static void display(void) {
                 };
                 frame_complete();
                 if (double_buffer)
-                    glutSwapBuffers();
+                    __drawable->swapBuffers();
                 else
                     glFlush();
-
-                // Return now to allow GLUT to resize the window.
-                delete call;
-                return;
             } else if (name == "glXMakeCurrent" ||
                        name == "wglMakeCurrent") {
                 glFlush();
                 if (!double_buffer) {
                     frame_complete();
-                    // Return now to allow GLUT to resize window.
-                    delete call;
-                    return;
                 }
             } else {
                 continue;
@@ -360,22 +360,12 @@ static void display(void) {
     }
 
     if (__wait) {
-        glutDisplayFunc(&display_noop);
-        glutIdleFunc(NULL);
+        while (__ws->processEvents()) {}
     } else {
         exit(0);
     }
 }
 
-static void idle(void) {
-    if (__reshape_window) {
-        // XXX: doesn't quite work
-        glutReshapeWindow(__window_width, __window_height);
-        __reshape_window = false;
-    }
-    glutPostRedisplay();
-}
-
 static void usage(void) {
     std::cout << 
         "Usage: glretrace [OPTION] TRACE\n"
@@ -429,19 +419,17 @@ int main(int argc, char **argv)
         }
     }
 
-    glutInit(&argc, argv);
-    glutInitWindowPosition(0, 0);
-    glutInitWindowSize(__window_width, __window_height);
-    glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | (double_buffer ? GLUT_DOUBLE : GLUT_SINGLE));
-    glutCreateWindow(argv[0]);
-
-    glutDisplayFunc(&display);
-    glutIdleFunc(&idle);
+    __ws = glws::createNativeWindowSystem();
+    __visual = __ws->createVisual(double_buffer);
+    __drawable = __ws->createDrawable(__visual);
+    __drawable->resize(__window_width, __window_height);
+    __context = __ws->createContext(__visual);
+    __ws->makeCurrent(__drawable, __context);
 
     for ( ; i < argc; ++i) {
         if (parser.open(argv[i])) {
             __startTime = OS::GetTime();
-            glutMainLoop();
+            display();
             parser.close();
         }
     }