Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpolygon.c
Go to the documentation of this file.
00001 00006 /* 00007 * Mesa 3-D graphics library 00008 * Version: 6.5.1 00009 * 00010 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 00011 * 00012 * Permission is hereby granted, free of charge, to any person obtaining a 00013 * copy of this software and associated documentation files (the "Software"), 00014 * to deal in the Software without restriction, including without limitation 00015 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00016 * and/or sell copies of the Software, and to permit persons to whom the 00017 * Software is furnished to do so, subject to the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be included 00020 * in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00023 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00025 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00026 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00027 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00028 */ 00029 00030 00031 #include "glheader.h" 00032 #include "imports.h" 00033 #include "bufferobj.h" 00034 #include "context.h" 00035 #include "image.h" 00036 #include "enums.h" 00037 #include "macros.h" 00038 #include "polygon.h" 00039 #include "mtypes.h" 00040 00041 00053 void GLAPIENTRY 00054 _mesa_CullFace( GLenum mode ) 00055 { 00056 GET_CURRENT_CONTEXT(ctx); 00057 ASSERT_OUTSIDE_BEGIN_END(ctx); 00058 00059 if (MESA_VERBOSE&VERBOSE_API) 00060 _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode)); 00061 00062 if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { 00063 _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" ); 00064 return; 00065 } 00066 00067 if (ctx->Polygon.CullFaceMode == mode) 00068 return; 00069 00070 FLUSH_VERTICES(ctx, _NEW_POLYGON); 00071 ctx->Polygon.CullFaceMode = mode; 00072 00073 if (ctx->Driver.CullFace) 00074 ctx->Driver.CullFace( ctx, mode ); 00075 } 00076 00077 00089 void GLAPIENTRY 00090 _mesa_FrontFace( GLenum mode ) 00091 { 00092 GET_CURRENT_CONTEXT(ctx); 00093 ASSERT_OUTSIDE_BEGIN_END(ctx); 00094 00095 if (MESA_VERBOSE&VERBOSE_API) 00096 _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode)); 00097 00098 if (mode!=GL_CW && mode!=GL_CCW) { 00099 _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); 00100 return; 00101 } 00102 00103 if (ctx->Polygon.FrontFace == mode) 00104 return; 00105 00106 FLUSH_VERTICES(ctx, _NEW_POLYGON); 00107 ctx->Polygon.FrontFace = mode; 00108 00109 ctx->Polygon._FrontBit = (GLboolean) (mode == GL_CW); 00110 00111 if (ctx->Driver.FrontFace) 00112 ctx->Driver.FrontFace( ctx, mode ); 00113 } 00114 00115 00128 void GLAPIENTRY 00129 _mesa_PolygonMode( GLenum face, GLenum mode ) 00130 { 00131 GET_CURRENT_CONTEXT(ctx); 00132 ASSERT_OUTSIDE_BEGIN_END(ctx); 00133 00134 if (MESA_VERBOSE&VERBOSE_API) 00135 _mesa_debug(ctx, "glPolygonMode %s %s\n", 00136 _mesa_lookup_enum_by_nr(face), 00137 _mesa_lookup_enum_by_nr(mode)); 00138 00139 if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { 00140 _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); 00141 return; 00142 } 00143 00144 switch (face) { 00145 case GL_FRONT: 00146 if (ctx->Polygon.FrontMode == mode) 00147 return; 00148 FLUSH_VERTICES(ctx, _NEW_POLYGON); 00149 ctx->Polygon.FrontMode = mode; 00150 break; 00151 case GL_FRONT_AND_BACK: 00152 if (ctx->Polygon.FrontMode == mode && 00153 ctx->Polygon.BackMode == mode) 00154 return; 00155 FLUSH_VERTICES(ctx, _NEW_POLYGON); 00156 ctx->Polygon.FrontMode = mode; 00157 ctx->Polygon.BackMode = mode; 00158 break; 00159 case GL_BACK: 00160 if (ctx->Polygon.BackMode == mode) 00161 return; 00162 FLUSH_VERTICES(ctx, _NEW_POLYGON); 00163 ctx->Polygon.BackMode = mode; 00164 break; 00165 default: 00166 _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); 00167 return; 00168 } 00169 00170 if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) 00171 ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; 00172 else 00173 ctx->_TriangleCaps |= DD_TRI_UNFILLED; 00174 00175 if (ctx->Driver.PolygonMode) 00176 ctx->Driver.PolygonMode(ctx, face, mode); 00177 } 00178 00179 #if _HAVE_FULL_GL 00180 00181 00193 void 00194 _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) 00195 { 00196 if (ctx->Unpack.BufferObj->Name) { 00197 /* Get/unpack the stipple pattern from a PBO */ 00198 GLubyte *buf; 00199 if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, 00200 GL_COLOR_INDEX, GL_BITMAP, pattern)) { 00201 _mesa_error(ctx, GL_INVALID_OPERATION, 00202 "glPolygonStipple(bad PBO access)"); 00203 return; 00204 } 00205 buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, 00206 GL_READ_ONLY_ARB, 00207 ctx->Unpack.BufferObj); 00208 if (!buf) { 00209 _mesa_error(ctx, GL_INVALID_OPERATION, 00210 "glPolygonStipple(PBO mapped)"); 00211 return; 00212 } 00213 buf = ADD_POINTERS(buf, pattern); 00214 _mesa_unpack_polygon_stipple(buf, ctx->PolygonStipple, &ctx->Unpack); 00215 ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, 00216 ctx->Unpack.BufferObj); 00217 } 00218 else { 00219 /* Get/unpack the stipple pattern from user memory */ 00220 _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); 00221 } 00222 } 00223 00224 00228 void GLAPIENTRY 00229 _mesa_PolygonStipple( const GLubyte *pattern ) 00230 { 00231 GET_CURRENT_CONTEXT(ctx); 00232 ASSERT_OUTSIDE_BEGIN_END(ctx); 00233 00234 if (MESA_VERBOSE&VERBOSE_API) 00235 _mesa_debug(ctx, "glPolygonStipple\n"); 00236 00237 FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE); 00238 00239 _mesa_polygon_stipple(ctx, pattern); 00240 00241 if (ctx->Driver.PolygonStipple) 00242 ctx->Driver.PolygonStipple(ctx, pattern); 00243 } 00244 00245 00249 void GLAPIENTRY 00250 _mesa_GetPolygonStipple( GLubyte *dest ) 00251 { 00252 GET_CURRENT_CONTEXT(ctx); 00253 ASSERT_OUTSIDE_BEGIN_END(ctx); 00254 00255 if (MESA_VERBOSE&VERBOSE_API) 00256 _mesa_debug(ctx, "glGetPolygonStipple\n"); 00257 00258 /* XXX someday we may put this code into a separate function and call 00259 * it with ctx->Driver.GetPolygonStipple(). 00260 */ 00261 if (ctx->Pack.BufferObj->Name) { 00262 /* Put/pack the stipple pattern into a PBO */ 00263 GLubyte *buf; 00264 if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1, 00265 GL_COLOR_INDEX, GL_BITMAP, dest)) { 00266 _mesa_error(ctx, GL_INVALID_OPERATION, 00267 "glGetPolygonStipple(bad PBO access)"); 00268 return; 00269 } 00270 buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, 00271 GL_WRITE_ONLY_ARB, 00272 ctx->Pack.BufferObj); 00273 if (!buf) { 00274 _mesa_error(ctx, GL_INVALID_OPERATION, 00275 "glGetPolygonStipple(PBO mapped)"); 00276 return; 00277 } 00278 buf = ADD_POINTERS(buf, dest); 00279 _mesa_pack_polygon_stipple(ctx->PolygonStipple, buf, &ctx->Pack); 00280 ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, 00281 ctx->Pack.BufferObj); 00282 } 00283 else { 00284 /* Put/pack the stipple pattern into user memory */ 00285 _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); 00286 } 00287 } 00288 00289 00290 void GLAPIENTRY 00291 _mesa_PolygonOffset( GLfloat factor, GLfloat units ) 00292 { 00293 GET_CURRENT_CONTEXT(ctx); 00294 ASSERT_OUTSIDE_BEGIN_END(ctx); 00295 00296 if (MESA_VERBOSE&VERBOSE_API) 00297 _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units); 00298 00299 if (ctx->Polygon.OffsetFactor == factor && 00300 ctx->Polygon.OffsetUnits == units) 00301 return; 00302 00303 FLUSH_VERTICES(ctx, _NEW_POLYGON); 00304 ctx->Polygon.OffsetFactor = factor; 00305 ctx->Polygon.OffsetUnits = units; 00306 00307 if (ctx->Driver.PolygonOffset) 00308 ctx->Driver.PolygonOffset( ctx, factor, units ); 00309 } 00310 00311 00312 void GLAPIENTRY 00313 _mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) 00314 { 00315 GET_CURRENT_CONTEXT(ctx); 00316 /* XXX mult by DepthMaxF here??? */ 00317 _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF ); 00318 } 00319 00320 #endif 00321 00322 00323 /**********************************************************************/ 00326 00335 void _mesa_init_polygon( GLcontext * ctx ) 00336 { 00337 /* Polygon group */ 00338 ctx->Polygon.CullFlag = GL_FALSE; 00339 ctx->Polygon.CullFaceMode = GL_BACK; 00340 ctx->Polygon.FrontFace = GL_CCW; 00341 ctx->Polygon._FrontBit = 0; 00342 ctx->Polygon.FrontMode = GL_FILL; 00343 ctx->Polygon.BackMode = GL_FILL; 00344 ctx->Polygon.SmoothFlag = GL_FALSE; 00345 ctx->Polygon.StippleFlag = GL_FALSE; 00346 ctx->Polygon.OffsetFactor = 0.0F; 00347 ctx->Polygon.OffsetUnits = 0.0F; 00348 ctx->Polygon.OffsetPoint = GL_FALSE; 00349 ctx->Polygon.OffsetLine = GL_FALSE; 00350 ctx->Polygon.OffsetFill = GL_FALSE; 00351 00352 00353 /* Polygon Stipple group */ 00354 MEMSET( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); 00355 } 00356 Generated on Sun May 27 2012 04:20:25 for ReactOS by
1.7.6.1
|