]> git.cworth.org Git - apitrace/blobdiff - glretrace_main.cpp
Synchronize X and GL on windows resizes.
[apitrace] / glretrace_main.cpp
index 1f3e594c0cbc96f75b072abeea525d71b84f2cc7..d0fb5789ca314b0a22495e81bc4d2139e92e2d6c 100644 (file)
@@ -43,7 +43,6 @@ glws::Drawable *drawable = NULL;
 glws::Context *context = NULL;
 
 int window_width = 256, window_height = 256;
-bool reshape_window = false;
 
 unsigned frame = 0;
 long long startTime = 0;
@@ -103,7 +102,7 @@ checkGlError(void) {
 static void snapshot(Image::Image &image) {
     GLint drawbuffer = double_buffer ? GL_BACK : GL_FRONT;
     GLint readbuffer = double_buffer ? GL_BACK : GL_FRONT;
-    glGetIntegerv(GL_READ_BUFFER, &drawbuffer);
+    glGetIntegerv(GL_DRAW_BUFFER, &drawbuffer);
     glGetIntegerv(GL_READ_BUFFER, &readbuffer);
     glReadBuffer(drawbuffer);
     glReadPixels(0, 0, image.width, image.height, GL_RGBA, GL_UNSIGNED_BYTE, image.pixels);
@@ -112,14 +111,14 @@ static void snapshot(Image::Image &image) {
 }
 
 
-static void frame_complete(void) {
+static void frame_complete(unsigned call_no) {
     ++frame;
     
-    if (!reshape_window && (snapshot_prefix || compare_prefix)) {
+    if (snapshot_prefix || compare_prefix) {
         Image::Image *ref = NULL;
         if (compare_prefix) {
             char filename[PATH_MAX];
-            snprintf(filename, sizeof filename, "%s%04u.png", compare_prefix, frame);
+            snprintf(filename, sizeof filename, "%s%010u.png", compare_prefix, call_no);
             ref = Image::readPNG(filename);
             if (!ref) {
                 return;
@@ -133,25 +132,18 @@ static void frame_complete(void) {
 
         if (snapshot_prefix) {
             char filename[PATH_MAX];
-            snprintf(filename, sizeof filename, "%s%04u.png", snapshot_prefix, frame);
+            snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no);
             if (src.writePNG(filename) && retrace::verbosity >= 0) {
                 std::cout << "Wrote " << filename << "\n";
             }
         }
 
         if (ref) {
-            std::cout << "Frame " << frame << " average precision of " << src.compare(*ref) << " bits\n";
+            std::cout << "Snapshot " << call_no << " average precision of " << src.compare(*ref) << " bits\n";
             delete ref;
         }
     }
-    
-    if (reshape_window) {
-        // XXX: doesn't quite work
-        drawable->resize(window_width, window_height);
-        reshape_window = false;
-    }
 
-    ws->processEvents();
 }
 
 
@@ -170,7 +162,7 @@ static void display(void) {
                     std::cout << *call;
                     std::cout.flush();
                 };
-                frame_complete();
+                frame_complete(call->no);
                 if (double_buffer)
                     drawable->swapBuffers();
                 else
@@ -179,7 +171,7 @@ static void display(void) {
                        name == "wglMakeCurrent") {
                 glFlush();
                 if (!double_buffer) {
-                    frame_complete();
+                    frame_complete(call->no);
                 }
             } else {
                 continue;
@@ -189,7 +181,7 @@ static void display(void) {
         if (name == "glFlush") {
             glFlush();
             if (!double_buffer) {
-                frame_complete();
+                frame_complete(call->no);
             }
         }