]> git.cworth.org Git - apitrace/blobdiff - glretrace_main.cpp
TODO: Add some notes on additions we want to the command-line interface
[apitrace] / glretrace_main.cpp
index dc022762fc35d439eb358cbff18eed2b77cdc2cc..c23f66473a8efa30a12fa55f0c13a31108b8cd1a 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <string.h>
 
+#include "os_path.hpp"
 #include "image.hpp"
 #include "retrace.hpp"
 #include "glproc.hpp"
@@ -37,7 +38,7 @@ namespace glretrace {
 
 bool double_buffer = true;
 bool insideGlBeginEnd = false;
-Trace::Parser parser;
+trace::Parser parser;
 glws::Visual *visual = NULL;
 glws::Drawable *drawable = NULL;
 glws::Context *context = NULL;
@@ -54,7 +55,7 @@ enum frequency snapshot_frequency = FREQUENCY_NEVER;
 unsigned dump_state = ~0;
 
 void
-checkGlError(Trace::Call &call) {
+checkGlError(trace::Call &call) {
     GLenum error = glGetError();
     if (error == GL_NO_ERROR) {
         return;
@@ -110,8 +111,9 @@ updateDrawable(int width, int height) {
         return;
     }
 
-    if (width  <= glretrace::drawable->width &&
-        height <= glretrace::drawable->height) {
+    if (drawable->visible &&
+        width  <= drawable->width &&
+        height <= drawable->height) {
         return;
     }
 
@@ -122,10 +124,9 @@ updateDrawable(int width, int height) {
         return;
     }
 
-    glretrace::drawable->resize(width, height);
-    if (!drawable->visible) {
-        drawable->show();
-    }
+    drawable->resize(width, height);
+    drawable->show();
+
     glScissor(0, 0, width, height);
 }
 
@@ -136,12 +137,11 @@ void snapshot(unsigned call_no) {
         return;
     }
 
-    Image::Image *ref = NULL;
+    image::Image *ref = NULL;
 
     if (compare_prefix) {
-        char filename[PATH_MAX];
-        snprintf(filename, sizeof filename, "%s%010u.png", compare_prefix, call_no);
-        ref = Image::readPNG(filename);
+        os::Path filename = os::Path::format("%s%010u.png", compare_prefix, call_no);
+        ref = image::readPNG(filename);
         if (!ref) {
             return;
         }
@@ -150,7 +150,7 @@ void snapshot(unsigned call_no) {
         }
     }
 
-    Image::Image *src = glstate::getDrawBufferImage(GL_RGBA);
+    image::Image *src = glstate::getDrawBufferImage(GL_RGBA);
     if (!src) {
         return;
     }
@@ -161,8 +161,7 @@ void snapshot(unsigned call_no) {
             snprintf(comment, sizeof comment, "%u", call_no);
             src->writePNM(std::cout, comment);
         } else {
-            char filename[PATH_MAX];
-            snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no);
+            os::Path filename = os::Path::format("%s%010u.png", snapshot_prefix, call_no);
             if (src->writePNG(filename) && retrace::verbosity >= 0) {
                 std::cout << "Wrote " << filename << "\n";
             }
@@ -178,12 +177,20 @@ void snapshot(unsigned call_no) {
 }
 
 
-void frame_complete(unsigned call_no) {
+void frame_complete(trace::Call &call) {
     ++frame;
 
+    if (!drawable) {
+        return;
+    }
+
+    if (!drawable->visible) {
+        retrace::warning(call) << "could not infer drawable size (glViewport never called)\n";
+    }
+
     if (snapshot_frequency == FREQUENCY_FRAME ||
         snapshot_frequency == FREQUENCY_FRAMEBUFFER) {
-        snapshot(call_no);
+        snapshot(call.no);
     }
 }
 
@@ -196,8 +203,8 @@ static void display(void) {
     retracer.addCallbacks(wgl_callbacks);
     retracer.addCallbacks(cgl_callbacks);
 
-    startTime = OS::GetTime();
-    Trace::Call *call;
+    startTime = os::getTime();
+    trace::Call *call;
 
     while ((call = parser.parse_call())) {
         retracer.retrace(*call);
@@ -215,7 +222,7 @@ static void display(void) {
     // Reached the end of trace
     glFlush();
 
-    long long endTime = OS::GetTime();
+    long long endTime = os::getTime();
     float timeInterval = (endTime - startTime) * 1.0E-6;
 
     if (retrace::verbosity >= -1) { 
@@ -266,6 +273,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(arg, "-b")) {
             benchmark = true;
             retrace::verbosity = -1;
+            glws::debug = false;
         } else if (!strcmp(arg, "-c")) {
             compare_prefix = argv[++i];
             if (snapshot_frequency == FREQUENCY_NEVER) {