st: if st_swapbuffers() is called for single-buffered visual don't crash
authorBrian Paul <brianp@vmware.com>
Fri, 1 May 2009 22:44:04 +0000 (16:44 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 1 May 2009 22:44:04 +0000 (16:44 -0600)
Furthermore, return pointer(s) to the front color buffer(s).

src/mesa/state_tracker/st_framebuffer.c

index 639373fff7ef30f4344f127e56b30b8269f8200a..ef800291ccdd2dd0865d4e29ad926764b1ba9363 100644 (file)
@@ -297,7 +297,10 @@ st_notify_swapbuffers(struct st_framebuffer *stfb)
  * Swap the front/back color buffers.  Exchange the front/back pointers
  * and update some derived state.
  * No need to call st_notify_swapbuffers() first.
- * This is effectively a no-op for single-buffered framebuffers.
+ *
+ * For a single-buffered framebuffer, no swap occurs, but we still return
+ * the pointer(s) to the front color buffer(s).
+ *
  * \param front_left  returns pointer to front-left renderbuffer after swap
  * \param front_right  returns pointer to front-right renderbuffer after swap
  */
@@ -318,6 +321,21 @@ st_swapbuffers(struct st_framebuffer *stfb,
                 NULL );
    }
 
+   if (!fb->Visual.doubleBufferMode) {
+      /* single buffer mode - return pointers to front surfaces */
+      if (front_left) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+         *front_left = strb->surface;
+      }
+      if (front_right) {
+         struct st_renderbuffer *strb =
+            st_renderbuffer(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer);
+         *front_right = strb ? strb->surface : NULL;
+      }
+      return;
+   }
+
    /* swap left buffers */
    if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer &&
        fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) {