]> git.cworth.org Git - apitrace/blobdiff - retrace/glretrace_main.cpp
retrace: Allow multiple dumpers to co-exist.
[apitrace] / retrace / glretrace_main.cpp
index 5ccb2e2d2a2955f6b83a03da4508cfbd8ad5d57c..1418ca3d0fcc9bd54326263af35763136dd656c8 100755 (executable)
@@ -391,9 +391,35 @@ debugOutputCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsi
 } /* namespace glretrace */
 
 
+class GLDumper : public retrace::Dumper {
+public:
+    image::Image *
+    getSnapshot(void) {
+        if (!glretrace::getCurrentContext()) {
+            return NULL;
+        }
+        return glstate::getDrawBufferImage();
+    }
+
+    bool
+    dumpState(std::ostream &os) {
+        glretrace::Context *currentContext = glretrace::getCurrentContext();
+        if (glretrace::insideGlBeginEnd ||
+            !currentContext) {
+            return false;
+        }
+        glstate::dumpCurrentContext(os);
+        return true;
+    }
+};
+
+static GLDumper glDumper;
+
+
 void
 retrace::setUp(void) {
     glws::init();
+    dumper = &glDumper;
 }
 
 
@@ -408,31 +434,6 @@ retrace::addCallbacks(retrace::Retracer &retracer)
 }
 
 
-image::Image *
-retrace::getSnapshot(void) {
-    if (!glretrace::getCurrentContext()) {
-        return NULL;
-    }
-
-    return glstate::getDrawBufferImage();
-}
-
-
-bool
-retrace::dumpState(std::ostream &os)
-{
-    glretrace::Context *currentContext = glretrace::getCurrentContext();
-
-    if (glretrace::insideGlBeginEnd ||
-        !currentContext) {
-        return false;
-    }
-
-    glstate::dumpCurrentContext(os);
-
-    return true;
-}
-
 void
 retrace::flushRendering(void) {
     glretrace::Context *currentContext = glretrace::getCurrentContext();