]> git.cworth.org Git - apitrace/blobdiff - glretrace_main.cpp
Deep copy the blob data.
[apitrace] / glretrace_main.cpp
index 56ee763210b4e3848f4b359549cb9e72c8f42580..cd35889c9dff873303dd27d26274829d296e664d 100644 (file)
@@ -103,6 +103,37 @@ checkGlError(Trace::Call &call) {
     std::cerr << "\n";
 }
 
+/**
+ * Grow the current drawble.
+ *
+ * We need to infer the drawable size from GL calls because the drawable sizes
+ * are specified by OS specific calls which we do not trace.
+ */
+void
+updateDrawable(int width, int height) {
+    if (!drawable) {
+        return;
+    }
+
+    if (width  <= glretrace::drawable->width &&
+        height <= glretrace::drawable->height) {
+        return;
+    }
+
+    // Check for bound framebuffer last, as this may have a performance impact.
+    GLint draw_framebuffer = 0;
+    glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer);
+    if (draw_framebuffer != 0) {
+        return;
+    }
+
+    glretrace::drawable->resize(width, height);
+    if (!drawable->visible) {
+        drawable->show();
+    }
+    glScissor(0, 0, width, height);
+}
+
 
 void snapshot(unsigned call_no) {
     if (!drawable ||
@@ -131,7 +162,9 @@ void snapshot(unsigned call_no) {
 
     if (snapshot_prefix) {
         if (snapshot_prefix[0] == '-' && snapshot_prefix[1] == 0) {
-            src->writePNM(std::cout);
+            char comment[21];
+            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);