Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygent_dd_tritmp.h
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 6.3 00004 * 00005 * Copyright (C) 1999-2005 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 * Authors: 00025 * Keith Whitwell <keith@tungstengraphics.com> 00026 */ 00027 00028 00029 /* Template for building functions to plug into the driver interface 00030 * of t_vb_render.c: 00031 * ctx->Driver.QuadFunc 00032 * ctx->Driver.TriangleFunc 00033 * ctx->Driver.LineFunc 00034 * ctx->Driver.PointsFunc 00035 * 00036 * DO_TWOSIDE: Plug back-color values from the VB into backfacing triangles, 00037 * and restore vertices afterwards. 00038 * DO_OFFSET: Calculate offset for triangles and adjust vertices. Restore 00039 * vertices after rendering. 00040 * DO_FLAT: For hardware without native flatshading, copy provoking colors 00041 * into the other vertices. Restore after rendering. 00042 * DO_UNFILLED: Decompose triangles to lines and points where appropriate. 00043 * DO_TWOSTENCIL:Gross hack for two-sided stencil. 00044 * 00045 * HAVE_RGBA: Vertices have rgba values (otherwise index values). 00046 * HAVE_SPEC: Vertices have secondary rgba values. 00047 * 00048 * VERT_X(v): Alias for vertex x value. 00049 * VERT_Y(v): Alias for vertex y value. 00050 * VERT_Z(v): Alias for vertex z value. 00051 * DEPTH_SCALE: Scale for constant offset. 00052 * REVERSE_DEPTH: Viewport depth range reversed. 00053 * 00054 * VERTEX: Hardware vertex type. 00055 * GET_VERTEX(n): Retreive vertex with index n. 00056 * AREA_IS_CCW(a): Return true if triangle with signed area a is ccw. 00057 * 00058 * VERT_SET_RGBA: Assign vertex rgba from VB color. 00059 * VERT_COPY_RGBA: Copy vertex rgba another vertex. 00060 * VERT_SAVE_RGBA: Save vertex rgba to a local variable. 00061 * VERT_RESTORE_RGBA: Restore vertex rgba from a local variable. 00062 * --> Similar for IND and SPEC. 00063 * 00064 * LOCAL_VARS(n): (At least) define local vars for save/restore rgba. 00065 * 00066 */ 00067 00068 #if HAVE_RGBA 00069 #define VERT_SET_IND( v, c ) (void) c 00070 #define VERT_COPY_IND( v0, v1 ) 00071 #define VERT_SAVE_IND( idx ) 00072 #define VERT_RESTORE_IND( idx ) 00073 #if HAVE_BACK_COLORS 00074 #define VERT_SET_RGBA( v, c ) 00075 #endif 00076 #else 00077 #define VERT_SET_RGBA( v, c ) (void) c 00078 #define VERT_COPY_RGBA( v0, v1 ) 00079 #define VERT_SAVE_RGBA( idx ) 00080 #define VERT_RESTORE_RGBA( idx ) 00081 #if HAVE_BACK_COLORS 00082 #define VERT_SET_IND( v, c ) 00083 #endif 00084 #endif 00085 00086 #if !HAVE_SPEC 00087 #define VERT_SET_SPEC( v, c ) (void) c 00088 #define VERT_COPY_SPEC( v0, v1 ) 00089 #define VERT_SAVE_SPEC( idx ) 00090 #define VERT_RESTORE_SPEC( idx ) 00091 #if HAVE_BACK_COLORS 00092 #define VERT_COPY_SPEC1( v ) 00093 #endif 00094 #else 00095 #if HAVE_BACK_COLORS 00096 #define VERT_SET_SPEC( v, c ) 00097 #endif 00098 #endif 00099 00100 #if !HAVE_BACK_COLORS 00101 #define VERT_COPY_SPEC1( v ) 00102 #define VERT_COPY_IND1( v ) 00103 #define VERT_COPY_RGBA1( v ) 00104 #endif 00105 00106 #ifndef INSANE_VERTICES 00107 #define VERT_SET_Z(v,val) VERT_Z(v) = val 00108 #define VERT_Z_ADD(v,val) VERT_Z(v) += val 00109 #endif 00110 00111 #ifndef REVERSE_DEPTH 00112 #define REVERSE_DEPTH 0 00113 #endif 00114 00115 /* disable twostencil for un-aware drivers */ 00116 #ifndef HAVE_STENCIL_TWOSIDE 00117 #define HAVE_STENCIL_TWOSIDE 0 00118 #endif 00119 #ifndef DO_TWOSTENCIL 00120 #define DO_TWOSTENCIL 0 00121 #endif 00122 #ifndef SETUP_STENCIL 00123 #define SETUP_STENCIL(f) 00124 #endif 00125 #ifndef UNSET_STENCIL 00126 #define UNSET_STENCIL(f) 00127 #endif 00128 00129 #if DO_TRI 00130 static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) 00131 { 00132 struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb; 00133 VERTEX *v[3]; 00134 GLfloat offset = 0; 00135 GLfloat z[3]; 00136 GLenum mode = GL_FILL; 00137 GLuint facing = 0; 00138 LOCAL_VARS(3); 00139 00140 /* fprintf(stderr, "%s\n", __FUNCTION__); */ 00141 00142 v[0] = (VERTEX *)GET_VERTEX(e0); 00143 v[1] = (VERTEX *)GET_VERTEX(e1); 00144 v[2] = (VERTEX *)GET_VERTEX(e2); 00145 00146 if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL) 00147 { 00148 GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]); 00149 GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]); 00150 GLfloat fx = VERT_X(v[1]) - VERT_X(v[2]); 00151 GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]); 00152 GLfloat cc = ex*fy - ey*fx; 00153 00154 if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL) 00155 { 00156 facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit; 00157 00158 if (DO_UNFILLED) { 00159 if (facing) { 00160 mode = ctx->Polygon.BackMode; 00161 if (ctx->Polygon.CullFlag && 00162 ctx->Polygon.CullFaceMode != GL_FRONT) { 00163 return; 00164 } 00165 } else { 00166 mode = ctx->Polygon.FrontMode; 00167 if (ctx->Polygon.CullFlag && 00168 ctx->Polygon.CullFaceMode != GL_BACK) { 00169 return; 00170 } 00171 } 00172 } 00173 00174 if (DO_TWOSIDE && facing == 1) 00175 { 00176 if (HAVE_RGBA) { 00177 if (HAVE_BACK_COLORS) { 00178 if (!DO_FLAT) { 00179 VERT_SAVE_RGBA( 0 ); 00180 VERT_SAVE_RGBA( 1 ); 00181 VERT_COPY_RGBA1( v[0] ); 00182 VERT_COPY_RGBA1( v[1] ); 00183 } 00184 VERT_SAVE_RGBA( 2 ); 00185 VERT_COPY_RGBA1( v[2] ); 00186 if (HAVE_SPEC) { 00187 if (!DO_FLAT) { 00188 VERT_SAVE_SPEC( 0 ); 00189 VERT_SAVE_SPEC( 1 ); 00190 VERT_COPY_SPEC1( v[0] ); 00191 VERT_COPY_SPEC1( v[1] ); 00192 } 00193 VERT_SAVE_SPEC( 2 ); 00194 VERT_COPY_SPEC1( v[2] ); 00195 } 00196 } 00197 else { 00198 GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; 00199 (void) vbcolor; 00200 00201 if (!DO_FLAT) { 00202 VERT_SAVE_RGBA( 0 ); 00203 VERT_SAVE_RGBA( 1 ); 00204 } 00205 VERT_SAVE_RGBA( 2 ); 00206 00207 if (VB->ColorPtr[1]->stride) { 00208 ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLfloat)); 00209 00210 if (!DO_FLAT) { 00211 VERT_SET_RGBA( v[0], vbcolor[e0] ); 00212 VERT_SET_RGBA( v[1], vbcolor[e1] ); 00213 } 00214 VERT_SET_RGBA( v[2], vbcolor[e2] ); 00215 } 00216 else { 00217 if (!DO_FLAT) { 00218 VERT_SET_RGBA( v[0], vbcolor[0] ); 00219 VERT_SET_RGBA( v[1], vbcolor[0] ); 00220 } 00221 VERT_SET_RGBA( v[2], vbcolor[0] ); 00222 } 00223 00224 if (HAVE_SPEC && VB->SecondaryColorPtr[1]) { 00225 GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; 00226 ASSERT(VB->SecondaryColorPtr[1]->stride == 4*sizeof(GLfloat)); 00227 00228 if (!DO_FLAT) { 00229 VERT_SAVE_SPEC( 0 ); 00230 VERT_SAVE_SPEC( 1 ); 00231 VERT_SET_SPEC( v[0], vbspec[e0] ); 00232 VERT_SET_SPEC( v[1], vbspec[e1] ); 00233 } 00234 VERT_SAVE_SPEC( 2 ); 00235 VERT_SET_SPEC( v[2], vbspec[e2] ); 00236 } 00237 } 00238 } 00239 else { 00240 GLfloat (*vbindex) = (GLfloat *)VB->IndexPtr[1]->data; 00241 if (!DO_FLAT) { 00242 VERT_SAVE_IND( 0 ); 00243 VERT_SAVE_IND( 1 ); 00244 VERT_SET_IND( v[0], vbindex[e0] ); 00245 VERT_SET_IND( v[1], vbindex[e1] ); 00246 } 00247 VERT_SAVE_IND( 2 ); 00248 VERT_SET_IND( v[2], vbindex[e2] ); 00249 } 00250 } 00251 } 00252 00253 00254 if (DO_OFFSET) 00255 { 00256 offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE; 00257 z[0] = VERT_Z(v[0]); 00258 z[1] = VERT_Z(v[1]); 00259 z[2] = VERT_Z(v[2]); 00260 if (cc * cc > 1e-16) { 00261 GLfloat ic = 1.0 / cc; 00262 GLfloat ez = z[0] - z[2]; 00263 GLfloat fz = z[1] - z[2]; 00264 GLfloat a = ey*fz - ez*fy; 00265 GLfloat b = ez*fx - ex*fz; 00266 GLfloat ac = a * ic; 00267 GLfloat bc = b * ic; 00268 if ( ac < 0.0f ) ac = -ac; 00269 if ( bc < 0.0f ) bc = -bc; 00270 offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor / ctx->DrawBuffer->_MRD; 00271 } 00272 offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0); 00273 } 00274 } 00275 00276 if (DO_FLAT) { 00277 if (HAVE_RGBA) { 00278 VERT_SAVE_RGBA( 0 ); 00279 VERT_SAVE_RGBA( 1 ); 00280 VERT_COPY_RGBA( v[0], v[2] ); 00281 VERT_COPY_RGBA( v[1], v[2] ); 00282 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { 00283 VERT_SAVE_SPEC( 0 ); 00284 VERT_SAVE_SPEC( 1 ); 00285 VERT_COPY_SPEC( v[0], v[2] ); 00286 VERT_COPY_SPEC( v[1], v[2] ); 00287 } 00288 } 00289 else { 00290 VERT_SAVE_IND( 0 ); 00291 VERT_SAVE_IND( 1 ); 00292 VERT_COPY_IND( v[0], v[2] ); 00293 VERT_COPY_IND( v[1], v[2] ); 00294 } 00295 } 00296 00297 if (mode == GL_POINT) { 00298 if (DO_OFFSET && ctx->Polygon.OffsetPoint) { 00299 VERT_Z_ADD(v[0], offset); 00300 VERT_Z_ADD(v[1], offset); 00301 VERT_Z_ADD(v[2], offset); 00302 } 00303 if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) { 00304 SETUP_STENCIL(facing); 00305 UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 ); 00306 UNSET_STENCIL(facing); 00307 } else { 00308 UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 ); 00309 } 00310 } else if (mode == GL_LINE) { 00311 if (DO_OFFSET && ctx->Polygon.OffsetLine) { 00312 VERT_Z_ADD(v[0], offset); 00313 VERT_Z_ADD(v[1], offset); 00314 VERT_Z_ADD(v[2], offset); 00315 } 00316 if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) { 00317 SETUP_STENCIL(facing); 00318 UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 ); 00319 UNSET_STENCIL(facing); 00320 } else { 00321 UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 ); 00322 } 00323 } else { 00324 if (DO_OFFSET && ctx->Polygon.OffsetFill) { 00325 VERT_Z_ADD(v[0], offset); 00326 VERT_Z_ADD(v[1], offset); 00327 VERT_Z_ADD(v[2], offset); 00328 } 00329 if (DO_UNFILLED) 00330 RASTERIZE( GL_TRIANGLES ); 00331 if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) { 00332 SETUP_STENCIL(facing); 00333 TRI( v[0], v[1], v[2] ); 00334 UNSET_STENCIL(facing); 00335 } else { 00336 TRI( v[0], v[1], v[2] ); 00337 } 00338 } 00339 00340 if (DO_OFFSET) 00341 { 00342 VERT_SET_Z(v[0], z[0]); 00343 VERT_SET_Z(v[1], z[1]); 00344 VERT_SET_Z(v[2], z[2]); 00345 } 00346 00347 if (DO_TWOSIDE && facing == 1) 00348 { 00349 if (HAVE_RGBA) { 00350 if (!DO_FLAT) { 00351 VERT_RESTORE_RGBA( 0 ); 00352 VERT_RESTORE_RGBA( 1 ); 00353 } 00354 VERT_RESTORE_RGBA( 2 ); 00355 if (HAVE_SPEC) { 00356 if (!DO_FLAT) { 00357 VERT_RESTORE_SPEC( 0 ); 00358 VERT_RESTORE_SPEC( 1 ); 00359 } 00360 VERT_RESTORE_SPEC( 2 ); 00361 } 00362 } 00363 else { 00364 if (!DO_FLAT) { 00365 VERT_RESTORE_IND( 0 ); 00366 VERT_RESTORE_IND( 1 ); 00367 } 00368 VERT_RESTORE_IND( 2 ); 00369 } 00370 } 00371 00372 00373 if (DO_FLAT) { 00374 if (HAVE_RGBA) { 00375 VERT_RESTORE_RGBA( 0 ); 00376 VERT_RESTORE_RGBA( 1 ); 00377 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { 00378 VERT_RESTORE_SPEC( 0 ); 00379 VERT_RESTORE_SPEC( 1 ); 00380 } 00381 } 00382 else { 00383 VERT_RESTORE_IND( 0 ); 00384 VERT_RESTORE_IND( 1 ); 00385 } 00386 } 00387 } 00388 #endif 00389 00390 #if DO_QUAD 00391 #if DO_FULL_QUAD 00392 static void TAG(quadr)( GLcontext *ctx, 00393 GLuint e0, GLuint e1, GLuint e2, GLuint e3 ) 00394 { 00395 struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb; 00396 VERTEX *v[4]; 00397 GLfloat offset = 0; 00398 GLfloat z[4]; 00399 GLenum mode = GL_FILL; 00400 GLuint facing = 0; 00401 LOCAL_VARS(4); 00402 00403 v[0] = (VERTEX *)GET_VERTEX(e0); 00404 v[1] = (VERTEX *)GET_VERTEX(e1); 00405 v[2] = (VERTEX *)GET_VERTEX(e2); 00406 v[3] = (VERTEX *)GET_VERTEX(e3); 00407 00408 if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL) 00409 { 00410 GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]); 00411 GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]); 00412 GLfloat fx = VERT_X(v[3]) - VERT_X(v[1]); 00413 GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]); 00414 GLfloat cc = ex*fy - ey*fx; 00415 00416 if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL) 00417 { 00418 facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit; 00419 00420 if (DO_UNFILLED) { 00421 if (facing) { 00422 mode = ctx->Polygon.BackMode; 00423 if (ctx->Polygon.CullFlag && 00424 ctx->Polygon.CullFaceMode != GL_FRONT) { 00425 return; 00426 } 00427 } else { 00428 mode = ctx->Polygon.FrontMode; 00429 if (ctx->Polygon.CullFlag && 00430 ctx->Polygon.CullFaceMode != GL_BACK) { 00431 return; 00432 } 00433 } 00434 } 00435 00436 if (DO_TWOSIDE && facing == 1) 00437 { 00438 if (HAVE_RGBA) { 00439 GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; 00440 (void)vbcolor; 00441 00442 if (HAVE_BACK_COLORS) { 00443 if (!DO_FLAT) { 00444 VERT_SAVE_RGBA( 0 ); 00445 VERT_SAVE_RGBA( 1 ); 00446 VERT_SAVE_RGBA( 2 ); 00447 VERT_COPY_RGBA1( v[0] ); 00448 VERT_COPY_RGBA1( v[1] ); 00449 VERT_COPY_RGBA1( v[2] ); 00450 } 00451 VERT_SAVE_RGBA( 3 ); 00452 VERT_COPY_RGBA1( v[3] ); 00453 if (HAVE_SPEC) { 00454 if (!DO_FLAT) { 00455 VERT_SAVE_SPEC( 0 ); 00456 VERT_SAVE_SPEC( 1 ); 00457 VERT_SAVE_SPEC( 2 ); 00458 VERT_COPY_SPEC1( v[0] ); 00459 VERT_COPY_SPEC1( v[1] ); 00460 VERT_COPY_SPEC1( v[2] ); 00461 } 00462 VERT_SAVE_SPEC( 3 ); 00463 VERT_COPY_SPEC1( v[3] ); 00464 } 00465 } 00466 else { 00467 if (!DO_FLAT) { 00468 VERT_SAVE_RGBA( 0 ); 00469 VERT_SAVE_RGBA( 1 ); 00470 VERT_SAVE_RGBA( 2 ); 00471 } 00472 VERT_SAVE_RGBA( 3 ); 00473 00474 if (VB->ColorPtr[1]->stride) { 00475 if (!DO_FLAT) { 00476 VERT_SET_RGBA( v[0], vbcolor[e0] ); 00477 VERT_SET_RGBA( v[1], vbcolor[e1] ); 00478 VERT_SET_RGBA( v[2], vbcolor[e2] ); 00479 } 00480 VERT_SET_RGBA( v[3], vbcolor[e3] ); 00481 } 00482 else { 00483 if (!DO_FLAT) { 00484 VERT_SET_RGBA( v[0], vbcolor[0] ); 00485 VERT_SET_RGBA( v[1], vbcolor[0] ); 00486 VERT_SET_RGBA( v[2], vbcolor[0] ); 00487 } 00488 VERT_SET_RGBA( v[3], vbcolor[0] ); 00489 } 00490 00491 if (HAVE_SPEC && VB->SecondaryColorPtr[1]) { 00492 GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; 00493 ASSERT(VB->SecondaryColorPtr[1]->stride==4*sizeof(GLfloat)); 00494 00495 if (!DO_FLAT) { 00496 VERT_SAVE_SPEC( 0 ); 00497 VERT_SAVE_SPEC( 1 ); 00498 VERT_SAVE_SPEC( 2 ); 00499 VERT_SET_SPEC( v[0], vbspec[e0] ); 00500 VERT_SET_SPEC( v[1], vbspec[e1] ); 00501 VERT_SET_SPEC( v[2], vbspec[e2] ); 00502 } 00503 VERT_SAVE_SPEC( 3 ); 00504 VERT_SET_SPEC( v[3], vbspec[e3] ); 00505 } 00506 } 00507 } 00508 else { 00509 GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data; 00510 if (!DO_FLAT) { 00511 VERT_SAVE_IND( 0 ); 00512 VERT_SAVE_IND( 1 ); 00513 VERT_SAVE_IND( 2 ); 00514 VERT_SET_IND( v[0], vbindex[e0] ); 00515 VERT_SET_IND( v[1], vbindex[e1] ); 00516 VERT_SET_IND( v[2], vbindex[e2] ); 00517 } 00518 VERT_SAVE_IND( 3 ); 00519 VERT_SET_IND( v[3], vbindex[e3] ); 00520 } 00521 } 00522 } 00523 00524 00525 if (DO_OFFSET) 00526 { 00527 offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE; 00528 z[0] = VERT_Z(v[0]); 00529 z[1] = VERT_Z(v[1]); 00530 z[2] = VERT_Z(v[2]); 00531 z[3] = VERT_Z(v[3]); 00532 if (cc * cc > 1e-16) { 00533 GLfloat ez = z[2] - z[0]; 00534 GLfloat fz = z[3] - z[1]; 00535 GLfloat a = ey*fz - ez*fy; 00536 GLfloat b = ez*fx - ex*fz; 00537 GLfloat ic = 1.0 / cc; 00538 GLfloat ac = a * ic; 00539 GLfloat bc = b * ic; 00540 if ( ac < 0.0f ) ac = -ac; 00541 if ( bc < 0.0f ) bc = -bc; 00542 offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor / ctx->DrawBuffer->_MRD; 00543 } 00544 offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0); 00545 } 00546 } 00547 00548 if (DO_FLAT) { 00549 if (HAVE_RGBA) { 00550 VERT_SAVE_RGBA( 0 ); 00551 VERT_SAVE_RGBA( 1 ); 00552 VERT_SAVE_RGBA( 2 ); 00553 VERT_COPY_RGBA( v[0], v[3] ); 00554 VERT_COPY_RGBA( v[1], v[3] ); 00555 VERT_COPY_RGBA( v[2], v[3] ); 00556 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { 00557 VERT_SAVE_SPEC( 0 ); 00558 VERT_SAVE_SPEC( 1 ); 00559 VERT_SAVE_SPEC( 2 ); 00560 VERT_COPY_SPEC( v[0], v[3] ); 00561 VERT_COPY_SPEC( v[1], v[3] ); 00562 VERT_COPY_SPEC( v[2], v[3] ); 00563 } 00564 } 00565 else { 00566 VERT_SAVE_IND( 0 ); 00567 VERT_SAVE_IND( 1 ); 00568 VERT_SAVE_IND( 2 ); 00569 VERT_COPY_IND( v[0], v[3] ); 00570 VERT_COPY_IND( v[1], v[3] ); 00571 VERT_COPY_IND( v[2], v[3] ); 00572 } 00573 } 00574 00575 if (mode == GL_POINT) { 00576 if (( DO_OFFSET) && ctx->Polygon.OffsetPoint) { 00577 VERT_Z_ADD(v[0], offset); 00578 VERT_Z_ADD(v[1], offset); 00579 VERT_Z_ADD(v[2], offset); 00580 VERT_Z_ADD(v[3], offset); 00581 } 00582 if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) { 00583 SETUP_STENCIL(facing); 00584 UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 ); 00585 UNSET_STENCIL(facing); 00586 } else { 00587 UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 ); 00588 } 00589 } else if (mode == GL_LINE) { 00590 if (DO_OFFSET && ctx->Polygon.OffsetLine) { 00591 VERT_Z_ADD(v[0], offset); 00592 VERT_Z_ADD(v[1], offset); 00593 VERT_Z_ADD(v[2], offset); 00594 VERT_Z_ADD(v[3], offset); 00595 } 00596 if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) { 00597 SETUP_STENCIL(facing); 00598 UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 ); 00599 UNSET_STENCIL(facing); 00600 } else { 00601 UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 ); 00602 } 00603 } else { 00604 if (DO_OFFSET && ctx->Polygon.OffsetFill) { 00605 VERT_Z_ADD(v[0], offset); 00606 VERT_Z_ADD(v[1], offset); 00607 VERT_Z_ADD(v[2], offset); 00608 VERT_Z_ADD(v[3], offset); 00609 } 00610 RASTERIZE( GL_QUADS ); 00611 if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) { 00612 SETUP_STENCIL(facing); 00613 QUAD( (v[0]), (v[1]), (v[2]), (v[3]) ); 00614 UNSET_STENCIL(facing); 00615 } else { 00616 QUAD( (v[0]), (v[1]), (v[2]), (v[3]) ); 00617 } 00618 } 00619 00620 if (DO_OFFSET) 00621 { 00622 VERT_SET_Z(v[0], z[0]); 00623 VERT_SET_Z(v[1], z[1]); 00624 VERT_SET_Z(v[2], z[2]); 00625 VERT_SET_Z(v[3], z[3]); 00626 } 00627 00628 if (DO_TWOSIDE && facing == 1) 00629 { 00630 if (HAVE_RGBA) { 00631 if (!DO_FLAT) { 00632 VERT_RESTORE_RGBA( 0 ); 00633 VERT_RESTORE_RGBA( 1 ); 00634 VERT_RESTORE_RGBA( 2 ); 00635 } 00636 VERT_RESTORE_RGBA( 3 ); 00637 if (HAVE_SPEC) { 00638 if (!DO_FLAT) { 00639 VERT_RESTORE_SPEC( 0 ); 00640 VERT_RESTORE_SPEC( 1 ); 00641 VERT_RESTORE_SPEC( 2 ); 00642 } 00643 VERT_RESTORE_SPEC( 3 ); 00644 } 00645 } 00646 else { 00647 if (!DO_FLAT) { 00648 VERT_RESTORE_IND( 0 ); 00649 VERT_RESTORE_IND( 1 ); 00650 VERT_RESTORE_IND( 2 ); 00651 } 00652 VERT_RESTORE_IND( 3 ); 00653 } 00654 } 00655 00656 00657 if (DO_FLAT) { 00658 if (HAVE_RGBA) { 00659 VERT_RESTORE_RGBA( 0 ); 00660 VERT_RESTORE_RGBA( 1 ); 00661 VERT_RESTORE_RGBA( 2 ); 00662 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { 00663 VERT_RESTORE_SPEC( 0 ); 00664 VERT_RESTORE_SPEC( 1 ); 00665 VERT_RESTORE_SPEC( 2 ); 00666 } 00667 } 00668 else { 00669 VERT_RESTORE_IND( 0 ); 00670 VERT_RESTORE_IND( 1 ); 00671 VERT_RESTORE_IND( 2 ); 00672 } 00673 } 00674 } 00675 #else 00676 static void TAG(quadr)( GLcontext *ctx, GLuint e0, 00677 GLuint e1, GLuint e2, GLuint e3 ) 00678 { 00679 if (DO_UNFILLED) { 00680 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 00681 GLubyte ef1 = VB->EdgeFlag[e1]; 00682 GLubyte ef3 = VB->EdgeFlag[e3]; 00683 VB->EdgeFlag[e1] = 0; 00684 TAG(triangle)( ctx, e0, e1, e3 ); 00685 VB->EdgeFlag[e1] = ef1; 00686 VB->EdgeFlag[e3] = 0; 00687 TAG(triangle)( ctx, e1, e2, e3 ); 00688 VB->EdgeFlag[e3] = ef3; 00689 } else { 00690 TAG(triangle)( ctx, e0, e1, e3 ); 00691 TAG(triangle)( ctx, e1, e2, e3 ); 00692 } 00693 } 00694 #endif 00695 #endif 00696 00697 #if DO_LINE 00698 static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 ) 00699 { 00700 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 00701 VERTEX *v[2]; 00702 LOCAL_VARS(2); 00703 00704 v[0] = (VERTEX *)GET_VERTEX(e0); 00705 v[1] = (VERTEX *)GET_VERTEX(e1); 00706 00707 if (DO_FLAT) { 00708 if (HAVE_RGBA) { 00709 VERT_SAVE_RGBA( 0 ); 00710 VERT_COPY_RGBA( v[0], v[1] ); 00711 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { 00712 VERT_SAVE_SPEC( 0 ); 00713 VERT_COPY_SPEC( v[0], v[1] ); 00714 } 00715 } 00716 else { 00717 VERT_SAVE_IND( 0 ); 00718 VERT_COPY_IND( v[0], v[1] ); 00719 } 00720 } 00721 00722 LINE( v[0], v[1] ); 00723 00724 if (DO_FLAT) { 00725 if (HAVE_RGBA) { 00726 VERT_RESTORE_RGBA( 0 ); 00727 00728 if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { 00729 VERT_RESTORE_SPEC( 0 ); 00730 } 00731 } 00732 else { 00733 VERT_RESTORE_IND( 0 ); 00734 } 00735 } 00736 } 00737 #endif 00738 00739 #if DO_POINTS 00740 static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last ) 00741 { 00742 struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb; 00743 GLuint i; 00744 LOCAL_VARS(1); 00745 00746 if (VB->Elts == 0) { 00747 for ( i = first ; i < last ; i++ ) { 00748 if ( VB->ClipMask[i] == 0 ) { 00749 VERTEX *v = (VERTEX *)GET_VERTEX(i); 00750 POINT( v ); 00751 } 00752 } 00753 } else { 00754 for ( i = first ; i < last ; i++ ) { 00755 GLuint e = VB->Elts[i]; 00756 if ( VB->ClipMask[e] == 0 ) { 00757 VERTEX *v = (VERTEX *)GET_VERTEX(e); 00758 POINT( v ); 00759 } 00760 } 00761 } 00762 } 00763 #endif 00764 00765 static void TAG(init)( void ) 00766 { 00767 #if DO_QUAD 00768 TAB[IND].quad = TAG(quadr); 00769 #endif 00770 #if DO_TRI 00771 TAB[IND].triangle = TAG(triangle); 00772 #endif 00773 #if DO_LINE 00774 TAB[IND].line = TAG(line); 00775 #endif 00776 #if DO_POINTS 00777 TAB[IND].points = TAG(points); 00778 #endif 00779 } 00780 00781 #undef IND 00782 #undef TAG 00783 00784 #if HAVE_RGBA 00785 #undef VERT_SET_IND 00786 #undef VERT_COPY_IND 00787 #undef VERT_SAVE_IND 00788 #undef VERT_RESTORE_IND 00789 #if HAVE_BACK_COLORS 00790 #undef VERT_SET_RGBA 00791 #endif 00792 #else 00793 #undef VERT_SET_RGBA 00794 #undef VERT_COPY_RGBA 00795 #undef VERT_SAVE_RGBA 00796 #undef VERT_RESTORE_RGBA 00797 #if HAVE_BACK_COLORS 00798 #undef VERT_SET_IND 00799 #endif 00800 #endif 00801 00802 #if !HAVE_SPEC 00803 #undef VERT_SET_SPEC 00804 #undef VERT_COPY_SPEC 00805 #undef VERT_SAVE_SPEC 00806 #undef VERT_RESTORE_SPEC 00807 #if HAVE_BACK_COLORS 00808 #undef VERT_COPY_SPEC1 00809 #endif 00810 #else 00811 #if HAVE_BACK_COLORS 00812 #undef VERT_SET_SPEC 00813 #endif 00814 #endif 00815 00816 #if !HAVE_BACK_COLORS 00817 #undef VERT_COPY_SPEC1 00818 #undef VERT_COPY_IND1 00819 #undef VERT_COPY_RGBA1 00820 #endif 00821 00822 #ifndef INSANE_VERTICES 00823 #undef VERT_SET_Z 00824 #undef VERT_Z_ADD 00825 #endif Generated on Sun May 27 2012 04:20:47 for ReactOS by
1.7.6.1
|