OSDN Git Service

update comments, etc related to Read/DrawBuffer state
authorBrian <brian.paul@tungstengraphics.com>
Thu, 16 Aug 2007 15:49:35 +0000 (16:49 +0100)
committerBrian <brian.paul@tungstengraphics.com>
Thu, 16 Aug 2007 15:49:35 +0000 (16:49 +0100)
src/mesa/main/buffers.c
src/mesa/main/framebuffer.c

index 0e6ca8e..82dd059 100644 (file)
@@ -479,9 +479,12 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer,
    /* not really needed, will be set later */
    fb->_NumColorDrawBuffers[output] = 0;
 
-   if (fb->Name == 0)
-   /* Set traditional state var */
+   if (fb->Name == 0) {
+      /* Only set the per-context DrawBuffer state if we're currently
+       * drawing to a window system framebuffer.
+       */
       ctx->Color.DrawBuffer[output] = buffer;
+   }
 }
 
 
index 0a6de12..72d85f6 100644 (file)
@@ -138,7 +138,7 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual)
    /* save the visual */
    fb->Visual = *visual;
 
-   /* Init glRead/DrawBuffer state */
+   /* Init read/draw renderbuffer state */
    if (visual->doubleBufferMode) {
       fb->ColorDrawBuffer[0] = GL_BACK;
       fb->_ColorDrawBufferMask[0] = BUFFER_BIT_BACK_LEFT;
@@ -649,6 +649,22 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
 }
 
 
+/**
+ * Update a gl_framebuffer's derived state.
+ *
+ * Specifically, update these framebuffer fields:
+ *    _ColorDrawBuffers
+ *    _NumColorDrawBuffers
+ *    _ColorReadBuffer
+ *    _DepthBuffer
+ *    _StencilBuffer
+ *
+ * If the framebuffer is user-created, make sure it's complete.
+ *
+ * The following functions (at least) can effect framebuffer state:
+ * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT,
+ * glRenderbufferStorageEXT.
+ */
 static void
 update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
 {
@@ -660,8 +676,11 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
       _mesa_update_framebuffer_visual(fb);
    }
 
-   /* update_color_draw/read_buffers not needed for
-      read/draw only fb, but shouldn't hurt ??? */
+   /* Strictly speaking, we don't need to update the draw-state
+    * if this FB is bound as ctx->ReadBuffer (and conversely, the
+    * read-state if this FB is bound as ctx->DrawBuffer), but no
+    * harm.
+    */
    update_color_draw_buffers(ctx, fb);
    update_color_read_buffer(ctx, fb);
    _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH);
@@ -670,28 +689,19 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
    compute_depth_max(fb);
 }
 
+
 /**
  * Update state related to the current draw/read framebuffers.
- * Specifically, update these framebuffer fields:
- *    _ColorDrawBuffers
- *    _NumColorDrawBuffers
- *    _ColorReadBuffer
- *    _DepthBuffer
- *    _StencilBuffer
- * If the current framebuffer is user-created, make sure it's complete.
- * The following functions can effect this state:  glReadBuffer,
- * glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT,
- * glRenderbufferStorageEXT.
  */
 void
 _mesa_update_framebuffer(GLcontext *ctx)
 {
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-   struct gl_framebuffer *fbread = ctx->ReadBuffer;
+   struct gl_framebuffer *drawFb = ctx->DrawBuffer;
+   struct gl_framebuffer *readFb = ctx->ReadBuffer;
 
-   update_framebuffer(ctx, fb);
-   if (fbread != fb)
-      update_framebuffer(ctx, fbread);
+   update_framebuffer(ctx, drawFb);
+   if (readFb != drawFb)
+      update_framebuffer(ctx, readFb);
 }