Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenclear.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.1 00004 * 00005 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00025 00033 #include "glheader.h" 00034 #include "clear.h" 00035 #include "context.h" 00036 #include "colormac.h" 00037 #include "state.h" 00038 00039 00040 00041 #if _HAVE_FULL_GL 00042 void GLAPIENTRY 00043 _mesa_ClearIndex( GLfloat c ) 00044 { 00045 GET_CURRENT_CONTEXT(ctx); 00046 ASSERT_OUTSIDE_BEGIN_END(ctx); 00047 00048 if (ctx->Color.ClearIndex == (GLuint) c) 00049 return; 00050 00051 FLUSH_VERTICES(ctx, _NEW_COLOR); 00052 ctx->Color.ClearIndex = (GLuint) c; 00053 00054 if (!ctx->Visual.rgbMode && ctx->Driver.ClearIndex) { 00055 /* it's OK to call glClearIndex in RGBA mode but it should be a NOP */ 00056 (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex ); 00057 } 00058 } 00059 #endif 00060 00061 00076 void GLAPIENTRY 00077 _mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) 00078 { 00079 GLfloat tmp[4]; 00080 GET_CURRENT_CONTEXT(ctx); 00081 ASSERT_OUTSIDE_BEGIN_END(ctx); 00082 00083 tmp[0] = CLAMP(red, 0.0F, 1.0F); 00084 tmp[1] = CLAMP(green, 0.0F, 1.0F); 00085 tmp[2] = CLAMP(blue, 0.0F, 1.0F); 00086 tmp[3] = CLAMP(alpha, 0.0F, 1.0F); 00087 00088 if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) 00089 return; /* no change */ 00090 00091 FLUSH_VERTICES(ctx, _NEW_COLOR); 00092 COPY_4V(ctx->Color.ClearColor, tmp); 00093 00094 if (ctx->Visual.rgbMode && ctx->Driver.ClearColor) { 00095 /* it's OK to call glClearColor in CI mode but it should be a NOP */ 00096 (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor); 00097 } 00098 } 00099 00100 00111 void GLAPIENTRY 00112 _mesa_Clear( GLbitfield mask ) 00113 { 00114 GET_CURRENT_CONTEXT(ctx); 00115 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00116 00117 FLUSH_CURRENT(ctx, 0); 00118 00119 if (MESA_VERBOSE & VERBOSE_API) 00120 _mesa_debug(ctx, "glClear 0x%x\n", mask); 00121 00122 if (mask & ~(GL_COLOR_BUFFER_BIT | 00123 GL_DEPTH_BUFFER_BIT | 00124 GL_STENCIL_BUFFER_BIT | 00125 GL_ACCUM_BUFFER_BIT)) { 00126 /* invalid bit set */ 00127 _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask); 00128 return; 00129 } 00130 00131 if (ctx->NewState) { 00132 _mesa_update_state( ctx ); /* update _Xmin, etc */ 00133 } 00134 00135 if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { 00136 _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, 00137 "glClear(incomplete framebuffer)"); 00138 return; 00139 } 00140 00141 if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 || 00142 ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax || 00143 ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax) 00144 return; 00145 00146 if (ctx->RenderMode == GL_RENDER) { 00147 GLbitfield bufferMask; 00148 00149 /* don't clear depth buffer if depth writing disabled */ 00150 if (!ctx->Depth.Mask) 00151 mask &= ~GL_DEPTH_BUFFER_BIT; 00152 00153 /* Build the bitmask to send to device driver's Clear function. 00154 * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4 00155 * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the 00156 * BUFFER_BIT_COLORn flags. 00157 */ 00158 bufferMask = 0; 00159 if (mask & GL_COLOR_BUFFER_BIT) { 00160 GLuint i; 00161 for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { 00162 bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]); 00163 } 00164 } 00165 00166 if ((mask & GL_DEPTH_BUFFER_BIT) 00167 && ctx->DrawBuffer->Visual.haveDepthBuffer) { 00168 bufferMask |= BUFFER_BIT_DEPTH; 00169 } 00170 00171 if ((mask & GL_STENCIL_BUFFER_BIT) 00172 && ctx->DrawBuffer->Visual.haveStencilBuffer) { 00173 bufferMask |= BUFFER_BIT_STENCIL; 00174 } 00175 00176 if ((mask & GL_ACCUM_BUFFER_BIT) 00177 && ctx->DrawBuffer->Visual.haveAccumBuffer) { 00178 bufferMask |= BUFFER_BIT_ACCUM; 00179 } 00180 00181 ASSERT(ctx->Driver.Clear); 00182 ctx->Driver.Clear(ctx, bufferMask); 00183 } 00184 } Generated on Sun May 27 2012 04:20:10 for ReactOS by
1.7.6.1
|