From f34de59b3eb631f98db907aea04b055c87f77900 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Apr 2003 13:16:37 +0000 Subject: [PATCH] don't try to clear non-existant buffers --- src/mesa/main/buffers.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index ab579b3d334..f7e922e2a22 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -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, -- 2.30.2