]> git.cworth.org Git - apitrace/commitdiff
glstate: Cleanup the read buffer selection code slightly.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 1 Feb 2013 17:03:11 +0000 (17:03 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 1 Feb 2013 17:03:11 +0000 (17:03 +0000)
We were calling glReadBuffer(draw_buffer) before reading the GL_READ_BUFFER.

retrace/glstate_images.cpp

index f3949b51d2182d8437a192311649a3057a8b4214..598d56cceb8e2746bec9e22fc519609d33667b64 100644 (file)
@@ -746,6 +746,7 @@ getDrawBufferImage() {
                 return NULL;
             }
         } else {
+            // GL_COLOR_ATTACHMENT0 is implied
             draw_buffer = GL_COLOR_ATTACHMENT0;
         }
 
@@ -753,13 +754,17 @@ getDrawBufferImage() {
             return NULL;
         }
     } else {
-        if (!context.ES) {
+        if (context.ES) {
+            // XXX: Draw buffer is always FRONT for single buffer context, BACK
+            // for double buffered contexts. There is no way to know which (as
+            // GL_DOUBLEBUFFER state is also unavailable), so always assume
+            // double-buffering.
+            draw_buffer = GL_BACK;
+        } else {
             glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
             if (draw_buffer == GL_NONE) {
                 return NULL;
             }
-        } else {
-            draw_buffer = GL_COLOR_ATTACHMENT0;
         }
 
         if (!getDrawableBounds(&desc.width, &desc.height)) {
@@ -972,16 +977,21 @@ dumpDrawableImages(JSONWriter &json, Context &context)
 
     GLint draw_buffer = GL_NONE;
     if (context.ES) {
+        // XXX: Draw buffer is always FRONT for single buffer context, BACK for
+        // double buffered contexts. There is no way to know which (as
+        // GL_DOUBLEBUFFER state is also unavailable), so always assume
+        // double-buffering.
         draw_buffer = GL_BACK;
     } else {
         glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
-        glReadBuffer(draw_buffer);
     }
 
     if (draw_buffer != GL_NONE) {
+        // Read from current draw buffer
         GLint read_buffer = GL_NONE;
         if (!context.ES) {
             glGetIntegerv(GL_READ_BUFFER, &read_buffer);
+            glReadBuffer(draw_buffer);
         }
 
         GLint alpha_bits = 0;
@@ -994,6 +1004,7 @@ dumpDrawableImages(JSONWriter &json, Context &context)
         dumpReadBufferImage(json, width, height, format);
         json.endMember();
 
+        // Restore original read buffer
         if (!context.ES) {
             glReadBuffer(read_buffer);
         }