- GLfloat tmp[4];
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- tmp[0] = CLAMP(red, 0.0F, 1.0F);
- tmp[1] = CLAMP(green, 0.0F, 1.0F);
- tmp[2] = CLAMP(blue, 0.0F, 1.0F);
- tmp[3] = CLAMP(alpha, 0.0F, 1.0F);
-
- if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
- return; /* no change */
-
- FLUSH_VERTICES(ctx, _NEW_COLOR);
- COPY_4V(ctx->Color.ClearColor, tmp);
-
- if (ctx->Visual.rgbMode && ctx->Driver.ClearColor) {
- /* it's OK to call glClearColor in CI mode but it should be a NOP */
- (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor);
- }
-}
-
-
-/**
- * Clear buffers.
- *
- * \param mask bit-mask indicating the buffers to be cleared.
- *
- * Flushes the vertices and verifies the parameter. If __GLcontextRec::NewState
- * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin,
- * etc. If the rasterization mode is set to GL_RENDER then requests the driver
- * to clear the buffers, via the dd_function_table::Clear callback.
- */
-void GLAPIENTRY
-_mesa_Clear( GLbitfield mask )
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glClear 0x%x\n", mask);
-
- if (mask & ~(GL_COLOR_BUFFER_BIT |
- GL_DEPTH_BUFFER_BIT |
- GL_STENCIL_BUFFER_BIT |
- GL_ACCUM_BUFFER_BIT)) {
- /* invalid bit set */
- _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
- return;
- }
-
- if (ctx->NewState) {
- _mesa_update_state( ctx ); /* update _Xmin, etc */
- }
-
- if (ctx->RenderMode==GL_RENDER) {
- const GLint x = ctx->DrawBuffer->_Xmin;
- const GLint y = ctx->DrawBuffer->_Ymin;
- const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
- const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
- GLbitfield ddMask;
-
- /* don't clear depth buffer if depth writing disabled */
- if (!ctx->Depth.Mask)
- mask &= ~GL_DEPTH_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[0];
- 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,
- x, y, width, height );
- }
-}
-
-
-
-/**
- * Return bitmask of DD_* flags indicating which color buffers are
- * available to the rendering context;
- */
-static GLuint
-supported_buffer_bitmask(const GLcontext *ctx)
-{
- GLuint mask = DD_FRONT_LEFT_BIT; /* always have this */
- GLuint i;
-
- if (ctx->Visual.stereoMode) {
- mask |= DD_FRONT_RIGHT_BIT;
- if (ctx->Visual.doubleBufferMode) {
- mask |= DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT;