Move _mesa_add_soft_renderbuffers() from framebuffer.c to renderbuffer.c
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 13 Sep 2005 23:37:50 +0000 (23:37 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 13 Sep 2005 23:37:50 +0000 (23:37 +0000)
Update some comments, code, etc.

src/mesa/main/framebuffer.c
src/mesa/main/framebuffer.h
src/mesa/main/renderbuffer.c
src/mesa/main/renderbuffer.h

index 0c620f7908d905070d901752fee91abee3a91656..6fab6eaa9f86348c4e1a65b92414c9b2b3605ad0 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
@@ -103,7 +103,6 @@ _mesa_new_framebuffer(GLcontext *ctx, GLuint name)
    if (fb) {
       fb->Name = name;
       fb->RefCount = 1;
-      fb->Delete = _mesa_destroy_framebuffer;
       fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT;
       fb->_ColorDrawBufferMask[0] = BUFFER_BIT_COLOR0;
       fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT;
@@ -115,7 +114,8 @@ _mesa_new_framebuffer(GLcontext *ctx, GLuint name)
 
 
 /**
- * Initialize a gl_framebuffer object.
+ * Initialize a gl_framebuffer object.  Typically used to initialize
+ * window system-created framebuffers, not user-created framebuffers.
  * \sa _mesa_create_framebuffer
  */
 void
@@ -149,99 +149,16 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual)
 }
 
 
-/**
- * Create/attach software-based renderbuffers to the given framebuffer.
- * This is a helper routine for device drivers.  Drivers can just as well
- * call the individual _mesa_add_*_renderbuffer() routines directly.
- */
-void
-_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
-                             GLboolean color,
-                             GLboolean depth,
-                             GLboolean stencil,
-                             GLboolean accum,
-                             GLboolean alpha,
-                             GLboolean aux)
-{
-   GLboolean frontLeft = GL_TRUE;
-   GLboolean backLeft = fb->Visual.doubleBufferMode;
-   GLboolean frontRight = fb->Visual.stereoMode;
-   GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode;
-
-   if (color) {
-      if (fb->Visual.rgbMode) {
-         assert(fb->Visual.redBits == fb->Visual.greenBits);
-         assert(fb->Visual.redBits == fb->Visual.blueBits);
-         _mesa_add_color_renderbuffers(NULL, fb,
-                                       fb->Visual.redBits,
-                                       fb->Visual.alphaBits,
-                                       frontLeft, backLeft,
-                                       frontRight, backRight);
-      }
-      else {
-         _mesa_add_color_index_renderbuffers(NULL, fb,
-                                             fb->Visual.indexBits,
-                                             frontLeft, backLeft,
-                                             frontRight, backRight);
-      }
-   }
-
-   if (depth) {
-      assert(fb->Visual.depthBits > 0);
-      _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits);
-   }
-
-   if (stencil) {
-      assert(fb->Visual.stencilBits > 0);
-      _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits);
-   }
-
-   if (accum) {
-      assert(fb->Visual.rgbMode);
-      assert(fb->Visual.accumRedBits > 0);
-      assert(fb->Visual.accumGreenBits > 0);
-      assert(fb->Visual.accumBlueBits > 0);
-      _mesa_add_accum_renderbuffer(NULL, fb,
-                                   fb->Visual.accumRedBits,
-                                   fb->Visual.accumGreenBits,
-                                   fb->Visual.accumBlueBits,
-                                   fb->Visual.accumAlphaBits);
-   }
-
-   if (aux) {
-      assert(fb->Visual.rgbMode);
-      assert(fb->Visual.numAuxBuffers > 0);
-      _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits,
-                                  fb->Visual.numAuxBuffers);
-   }
-
-#if 1
-   if (alpha) {
-      assert(fb->Visual.rgbMode);
-      assert(fb->Visual.alphaBits > 0);
-      _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits,
-                                    frontLeft, backLeft,
-                                    frontRight, backRight);
-   }
-#endif
-
-#if 0
-   if (multisample) {
-      /* maybe someday */
-   }
-#endif
-}
-
-
 /**
  * Deallocate buffer and everything attached to it.
+ * Typically called via the gl_framebuffer->Delete() method.
  */
 void
-_mesa_destroy_framebuffer(struct gl_framebuffer *buffer)
+_mesa_destroy_framebuffer(struct gl_framebuffer *fb)
 {
-   if (buffer) {
-      _mesa_free_framebuffer_data(buffer);
-      FREE(buffer);
+   if (fb) {
+      _mesa_free_framebuffer_data(fb);
+      FREE(fb);
    }
 }
 
@@ -398,7 +315,7 @@ _mesa_update_draw_buffer_bounds(GLcontext *ctx)
 /**
  * The glGet queries of the framebuffer red/green/blue size, stencil size,
  * etc. are satisfied by the fields of ctx->DrawBuffer->Visual.  These can
- * change depending on the renderbuffer bindings.  This function update's
+ * change depending on the renderbuffer bindings.  This function updates
  * the given framebuffer's Visual from the current renderbuffer bindings.
  * This is only intended for user-created framebuffers.
  */
@@ -481,8 +398,9 @@ _mesa_update_framebuffer(GLcontext *ctx)
    /*
     * Update the list of drawing renderbuffer pointers.
     * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers
-    * writing colors.  We have a loop because glDrawBuffer(GL_FRONT_AND_BACK)
-    * can specify writing to two or four color buffers.
+    * writing colors.  We need the inner loop here because
+    * glDrawBuffer(GL_FRONT_AND_BACK) can specify writing to two or four
+    * color buffers (for example).
     */
    for (output = 0; output < ctx->Const.MaxDrawBuffers; output++) {
       GLuint bufferMask = fb->_ColorDrawBufferMask[output];
index 11b002877c97faf95f1af73e55c0758590cbabdc..fcc493c1937dd3b16fd9f143bd2d263d07f2f27f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
@@ -36,15 +36,6 @@ _mesa_new_framebuffer(GLcontext *ctx, GLuint name);
 extern void
 _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual);
 
-extern void
-_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
-                             GLboolean color,
-                             GLboolean depth,
-                             GLboolean stencil,
-                             GLboolean accum,
-                             GLboolean alpha,
-                             GLboolean aux);
-
 extern void
 _mesa_destroy_framebuffer(struct gl_framebuffer *buffer);
 
index 480906533fdc5e65e6aaf418d76a286c7e651edf..d678f9c67493b687dcb83548006fa44cb1949ce6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
@@ -48,6 +48,7 @@
 #include "renderbuffer.h"
 
 
+/* 32-bit color index format.  Not a public format. */
 #define COLOR_INDEX32 0x424243
 
 
@@ -58,7 +59,7 @@
  */
 
 /**********************************************************************
- * Functions for buffers of 1 X GLushort values.
+ * Functions for buffers of 1 X GLubyte values.
  * Typically stencil.
  */
 
@@ -1835,6 +1836,87 @@ _mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
 }
 
 
+/**
+ * Create/attach software-based renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers.  Drivers can just as well
+ * call the individual _mesa_add_*_renderbuffer() routines directly.
+ */
+void
+_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
+                             GLboolean color,
+                             GLboolean depth,
+                             GLboolean stencil,
+                             GLboolean accum,
+                             GLboolean alpha,
+                             GLboolean aux)
+{
+   GLboolean frontLeft = GL_TRUE;
+   GLboolean backLeft = fb->Visual.doubleBufferMode;
+   GLboolean frontRight = fb->Visual.stereoMode;
+   GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode;
+
+   if (color) {
+      if (fb->Visual.rgbMode) {
+         assert(fb->Visual.redBits == fb->Visual.greenBits);
+         assert(fb->Visual.redBits == fb->Visual.blueBits);
+         _mesa_add_color_renderbuffers(NULL, fb,
+                                       fb->Visual.redBits,
+                                       fb->Visual.alphaBits,
+                                       frontLeft, backLeft,
+                                       frontRight, backRight);
+      }
+      else {
+         _mesa_add_color_index_renderbuffers(NULL, fb,
+                                             fb->Visual.indexBits,
+                                             frontLeft, backLeft,
+                                             frontRight, backRight);
+      }
+   }
+
+   if (depth) {
+      assert(fb->Visual.depthBits > 0);
+      _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits);
+   }
+
+   if (stencil) {
+      assert(fb->Visual.stencilBits > 0);
+      _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits);
+   }
+
+   if (accum) {
+      assert(fb->Visual.rgbMode);
+      assert(fb->Visual.accumRedBits > 0);
+      assert(fb->Visual.accumGreenBits > 0);
+      assert(fb->Visual.accumBlueBits > 0);
+      _mesa_add_accum_renderbuffer(NULL, fb,
+                                   fb->Visual.accumRedBits,
+                                   fb->Visual.accumGreenBits,
+                                   fb->Visual.accumBlueBits,
+                                   fb->Visual.accumAlphaBits);
+   }
+
+   if (aux) {
+      assert(fb->Visual.rgbMode);
+      assert(fb->Visual.numAuxBuffers > 0);
+      _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits,
+                                  fb->Visual.numAuxBuffers);
+   }
+
+   if (alpha) {
+      assert(fb->Visual.rgbMode);
+      assert(fb->Visual.alphaBits > 0);
+      _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits,
+                                    frontLeft, backLeft,
+                                    frontRight, backRight);
+   }
+
+#if 0
+   if (multisample) {
+      /* maybe someday */
+   }
+#endif
+}
+
 
 /**
  * Attach a renderbuffer to a framebuffer.
index 5c11de7c8a33bca243e786175e7e5bc196a4840b..fb3f3572f606edfd4b12663e50cbd2f77a1047ab 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
@@ -77,6 +77,15 @@ extern GLboolean
 _mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
                             GLuint bits, GLuint numBuffers);
 
+extern void
+_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
+                             GLboolean color,
+                             GLboolean depth,
+                             GLboolean stencil,
+                             GLboolean accum,
+                             GLboolean alpha,
+                             GLboolean aux);
+
 extern void
 _mesa_add_renderbuffer(struct gl_framebuffer *fb,
                        GLuint bufferName, struct gl_renderbuffer *rb);