OSDN Git Service

don't try to clear non-existant buffers
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 Apr 2003 13:16:37 +0000 (13:16 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 Apr 2003 13:16:37 +0000 (13:16 +0000)
src/mesa/main/buffers.c

index ab579b3..f7e922e 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id: buffers.c,v 1.43 2003/03/01 01:50:20 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
  * Version:  5.1
@@ -118,13 +116,19 @@ _mesa_Clear( GLbitfield mask )
       if (!ctx->Depth.Mask)
          mask &= ~GL_DEPTH_BUFFER_BIT;
 
-      /* Build bitmask to send to driver Clear function */
-      ddMask = mask & (GL_DEPTH_BUFFER_BIT |
-                       GL_STENCIL_BUFFER_BIT |
-                       GL_ACCUM_BUFFER_BIT);
-      if (mask & GL_COLOR_BUFFER_BIT) {
+      /* Build the bitmask to send to device driver's Clear function.
+       * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
+       * of the FRONT/BACK_LEFT/RIGHT_BIT flags.
+       */
+      ddMask = 0;
+      if (mask & GL_COLOR_BUFFER_BIT)
          ddMask |= ctx->Color._DrawDestMask;
-      }
+      if ((mask & GL_DEPTH_BUFFER_BIT) && ctx->Visual.depthBits > 0)
+         ddMask |= GL_DEPTH_BUFFER_BIT;
+      if ((mask & GL_STENCIL_BUFFER_BIT) && ctx->Visual.stencilBits > 0)
+         ddMask |= GL_STENCIL_BUFFER_BIT;
+      if ((mask & GL_ACCUM_BUFFER_BIT) && ctx->Visual.accumRedBits > 0)
+         ddMask |= GL_ACCUM_BUFFER_BIT;
 
       ASSERT(ctx->Driver.Clear);
       ctx->Driver.Clear( ctx, ddMask, (GLboolean) !ctx->Scissor.Enabled,