Changeset 3598 for trunk/src/opengl/mesa/3dfx/fxtritmp.h
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/3dfx/fxtritmp.h
r2938 r3598 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 49 49 struct vertex_buffer *VB=ctx->VB; 50 50 fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; 51 GrVertex *v1 = (GrVertex *)gWin[e1].f; 51 GrVertex *v1 = (GrVertex *)gWin[e1].f; 52 52 GrVertex *v2 = (GrVertex *)gWin[e2].f; 53 53 GrVertex *v3 = (GrVertex *)gWin[e3].f; … … 55 55 (void) fxMesa; 56 56 57 if (IND & (FX_TWOSIDE|FX_OFFSET)) 57 if (IND & (FX_TWOSIDE|FX_OFFSET)) 58 58 { 59 59 GLfloat ex = v1->x - v3->x; … … 62 62 GLfloat fy = v2->y - v3->y; 63 63 GLfloat c = ex*fy-ey*fx; 64 64 65 65 if (IND & FX_TWOSIDE) { 66 67 68 69 70 71 GOURAUD2(v1,color[e1]); 72 GOURAUD2(v2,color[e2]); 73 GOURAUD2(v3,color[e3]); 74 75 } 76 66 GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit; 67 GLubyte (*color)[4] = VB->Color[facing]->data; 68 if (IND & FX_FLAT) { 69 FX_VB_COLOR(fxMesa, color[pv]); 70 } else { 71 GOURAUD2(v1,color[e1]); 72 GOURAUD2(v2,color[e2]); 73 GOURAUD2(v3,color[e3]); 74 } 75 } 76 77 77 /* Should apply a factor to ac to compensate for different x/y 78 78 * scaling introduced in the Viewport matrix. … … 81 81 */ 82 82 if (IND & FX_OFFSET) { 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 83 GLfloat offset = ctx->Polygon.OffsetUnits; 84 85 if (c * c > 1e-16) { 86 GLfloat factor = ctx->Polygon.OffsetFactor; 87 GLfloat ez = v1->ooz - v3->ooz; 88 GLfloat fz = v2->ooz - v3->ooz; 89 GLfloat a = ey*fz-ez*fy; 90 GLfloat b = ez*fx-ex*fz; 91 GLfloat ic = 1.0 / c; 92 GLfloat ac = a * ic; 93 GLfloat bc = b * ic; 94 if (ac<0.0F) ac = -ac; 95 if (bc<0.0F) bc = -bc; 96 offset += MAX2( ac, bc ) * factor; 97 } 98 /* Probably a lot quicker just to nudge the z values and put 99 * them back afterwards. 100 */ 101 FX_grDepthBiasLevel((int)offset); 102 102 } 103 103 } … … 109 109 if (IND & FX_FRONT_BACK) { 110 110 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 111 112 113 111 ctx->Color.ColorMask[GCOMP] || 112 ctx->Color.ColorMask[BCOMP], 113 FXFALSE); 114 114 115 115 FX_grDepthMask(FXFALSE); … … 117 117 } 118 118 119 if (IND & FX_ANTIALIAS) 119 if (IND & FX_ANTIALIAS) 120 120 FX_grAADrawTriangle(v1, v2, v3, FXTRUE, FXTRUE, FXTRUE); 121 else 121 else 122 122 FX_grDrawTriangle(v1, v2, v3); 123 123 … … 126 126 if (IND & FX_FRONT_BACK) { 127 127 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 128 129 130 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 128 ctx->Color.ColorMask[GCOMP] || 129 ctx->Color.ColorMask[BCOMP], 130 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 131 131 132 132 if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE); … … 135 135 136 136 if (IND & FX_ANTIALIAS) 137 137 FX_grAADrawTriangle(v1,v2,v3, FXTRUE,FXTRUE,FXTRUE); 138 138 else 139 140 } 139 FX_grDrawTriangle(v1, v2, v3); 140 } 141 141 } 142 142 … … 145 145 */ 146 146 static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, 147 147 GLuint e4, GLuint pv) 148 148 { 149 149 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; 150 150 struct vertex_buffer *VB=ctx->VB; 151 151 fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; 152 GrVertex *v1 = (GrVertex *)gWin[e1].f; 152 GrVertex *v1 = (GrVertex *)gWin[e1].f; 153 153 GrVertex *v2 = (GrVertex *)gWin[e2].f; 154 154 GrVertex *v3 = (GrVertex *)gWin[e3].f; … … 157 157 (void) fxMesa; 158 158 159 if (IND & (FX_TWOSIDE|FX_OFFSET)) 159 if (IND & (FX_TWOSIDE|FX_OFFSET)) 160 160 { 161 161 GLfloat ex = v3->x - v1->x; … … 164 164 GLfloat fy = v4->y - v2->y; 165 165 GLfloat c = ex*fy-ey*fx; 166 166 167 167 if (IND & FX_TWOSIDE) { 168 169 170 171 172 173 GOURAUD2(v1,color[e1]); 174 GOURAUD2(v2,color[e2]); 175 GOURAUD2(v3,color[e3]); 176 GOURAUD2(v4,color[e4]); 177 178 } 179 168 GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit; 169 GLubyte (*color)[4] = VB->Color[facing]->data; 170 if (IND & FX_FLAT) { 171 FX_VB_COLOR(fxMesa, color[pv]); 172 } else { 173 GOURAUD2(v1,color[e1]); 174 GOURAUD2(v2,color[e2]); 175 GOURAUD2(v3,color[e3]); 176 GOURAUD2(v4,color[e4]); 177 } 178 } 179 180 180 /* Should apply a factor to ac to compensate for different x/y 181 181 * scaling introduced in the Viewport matrix. … … 184 184 */ 185 185 if (IND & FX_OFFSET) { 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 186 GLfloat offset = ctx->Polygon.OffsetUnits; 187 188 if (c * c > 1e-16) { 189 GLfloat factor = ctx->Polygon.OffsetFactor; 190 GLfloat ez = v3->ooz - v1->ooz; 191 GLfloat fz = v4->ooz - v2->ooz; 192 GLfloat a = ey*fz-ez*fy; 193 GLfloat b = ez*fx-ex*fz; 194 GLfloat ic = 1.0 / c; 195 GLfloat ac = a * ic; 196 GLfloat bc = b * ic; 197 if (ac<0.0F) ac = -ac; 198 if (bc<0.0F) bc = -bc; 199 offset += MAX2( ac, bc ) * factor; 200 } 201 /* Probably a lot quicker just to nudge the z values and put 202 * them back afterwards. 203 */ 204 FX_grDepthBiasLevel((int)offset); 205 205 } 206 206 } … … 212 212 if (IND & FX_FRONT_BACK) { 213 213 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 214 215 216 214 ctx->Color.ColorMask[GCOMP] || 215 ctx->Color.ColorMask[BCOMP], 216 FXFALSE); 217 217 218 218 FX_grDepthMask(FXFALSE); … … 232 232 if (IND & FX_FRONT_BACK) { 233 233 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 234 235 236 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 234 ctx->Color.ColorMask[GCOMP] || 235 ctx->Color.ColorMask[BCOMP], 236 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 237 237 238 238 if(ctx->Depth.Mask) FX_grDepthMask(FXTRUE); … … 241 241 242 242 if (IND & FX_ANTIALIAS) { 243 244 243 FX_grAADrawTriangle(v1, v2, v4, FXTRUE, FXTRUE, FXTRUE); 244 FX_grAADrawTriangle(v2, v3, v4, FXTRUE, FXTRUE, FXTRUE); 245 245 } else { 246 247 248 } 249 } 246 FX_grDrawTriangle(v1, v2, v4); 247 FX_grDrawTriangle(v2, v3, v4); 248 } 249 } 250 250 } 251 251 252 253 252 #define DRAW_LINE(tmp0, tmp1, width) \ 253 do { \ 254 GrVertex verts[4]; \ 255 float dx, dy, wx, wy; \ 256 \ 257 dx = tmp0->x - tmp1->x; \ 258 dy = tmp0->y - tmp1->y; \ 259 \ 260 if (dx * dx > dy * dy) { \ 261 wx = 0; \ 262 wy = width; \ 263 } else { \ 264 wx = width; \ 265 wy = 0; \ 266 } \ 267 \ 268 verts[0] = *tmp0; \ 269 verts[1] = *tmp0; \ 270 verts[2] = *tmp1; \ 271 verts[3] = *tmp1; \ 272 \ 273 verts[0].x = tmp0->x - wx; \ 274 verts[0].y = tmp0->y - wy; \ 275 \ 276 verts[1].x = tmp0->x + wx; \ 277 verts[1].y = tmp0->y + wy; \ 278 \ 279 verts[2].x = tmp1->x + wx; \ 280 verts[2].y = tmp1->y + wy; \ 281 \ 282 verts[3].x = tmp1->x - wx; \ 283 verts[3].y = tmp1->y - wy; \ 284 \ 285 FX_grDrawPolygonVertexList(4, verts); \ 286 } while (0) 254 287 255 288 #if (IND & FX_OFFSET) == 0 … … 260 293 fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; 261 294 GLubyte (* const color)[4] = VB->Color[0]->data; 262 GrVertex *v1 = (GrVertex *)gWin[e1].f; 295 GrVertex *v1 = (GrVertex *)gWin[e1].f; 263 296 GrVertex *v2 = (GrVertex *)gWin[e2].f; 264 265 if (IND & FX_FLAT) 297 GLfloat w = ctx->Line.Width*.5; 298 299 if (IND & FX_FLAT) 266 300 { 267 301 FX_VB_COLOR(fxMesa, color[pv]); … … 271 305 GLuint v1argb = v1->argb; 272 306 GLuint v2argb = v2->argb; 273 274 307 v1->argb = (color[pv][ACOMP] << 24) | (v1argb & 0x00FFFFFF); 308 v2->argb = (color[pv][ACOMP] << 24) | (v2argb & 0x00FFFFFF); 275 309 } 276 310 #else 277 278 #endif 279 } 280 else if (IND & FX_TWOSIDE) 311 v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]); 312 #endif 313 } 314 else if (IND & FX_TWOSIDE) 281 315 { 282 GOURAUD2(v1,color[e1]); 283 GOURAUD2(v2,color[e2]); 284 } 285 286 if (IND & FX_FRONT_BACK) { 287 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 288 289 290 316 GOURAUD2(v1,color[e1]); 317 GOURAUD2(v2,color[e2]); 318 } 319 320 if (IND & FX_FRONT_BACK) { 321 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 322 ctx->Color.ColorMask[GCOMP] || 323 ctx->Color.ColorMask[BCOMP], 324 FXFALSE); 291 325 FX_grDepthMask(FXFALSE); 292 326 FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); … … 296 330 FX_grAADrawLine(v1,v2); 297 331 else 298 FX_grDrawLine(v1,v2);299 300 if (IND & FX_FRONT_BACK) 332 DRAW_LINE(v1,v2,w); 333 334 if (IND & FX_FRONT_BACK) 301 335 { 302 336 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 303 304 305 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 337 ctx->Color.ColorMask[GCOMP] || 338 ctx->Color.ColorMask[BCOMP], 339 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 306 340 307 341 if(ctx->Depth.Mask) 308 342 FX_grDepthMask(FXTRUE); 309 343 310 344 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 311 345 312 346 if (IND & FX_ANTIALIAS) 313 347 FX_grAADrawLine(v1,v2); 314 348 else 315 FX_grDrawLine(v1,v2);349 DRAW_LINE(v1,v2,w); 316 350 } 317 351 } … … 336 370 #endif 337 371 338 #if IND & FX_ANTIALIAS 339 #define DRAW_POINT(i) FX_grAADrawPoint((GrVertex *)gWin[i].f); 340 #else 341 #define DRAW_POINT(i) FX_grDrawPoint((GrVertex *)gWin[i].f); 342 #endif 343 372 373 #define DRAW_POINT(i, sz) \ 374 do { \ 375 GrVertex verts[4], *tmp; \ 376 \ 377 tmp = (GrVertex*)gWin[i].f; \ 378 verts[0] = *tmp; \ 379 verts[1] = *tmp; \ 380 verts[2] = *tmp; \ 381 verts[3] = *tmp; \ 382 verts[0].x = verts[3].x = tmp->x + sz; \ 383 verts[0].y = verts[1].y = tmp->y + sz; \ 384 verts[2].x = verts[1].x = tmp->x - sz; \ 385 verts[2].y = verts[3].y = tmp->y - sz; \ 386 \ 387 FX_grDrawPolygonVertexList(4, verts); \ 388 } while (0) 344 389 345 390 static void TAG(fx_points)(GLcontext *ctx, GLuint first, GLuint last) … … 350 395 GLubyte (*color)[4] = VB->ColorPtr->data; 351 396 GLuint i; 397 GLfloat sz = ctx->Point.Size * .5; 352 398 353 399 (void) color; (void) fxMesa; … … 355 401 if (IND & FX_FRONT_BACK) { 356 402 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 357 358 359 403 ctx->Color.ColorMask[GCOMP] || 404 ctx->Color.ColorMask[BCOMP], 405 FXFALSE); 360 406 361 407 FX_grDepthMask(FXFALSE); … … 365 411 if(!VB->ClipOrMask) { 366 412 for(i=first;i<=last;i++) { 367 368 DRAW_POINT(i);413 FLAT_COLOR(fxMesa, color[i]); 414 DRAW_POINT(i, sz); 369 415 } 370 416 } else { 371 417 for(i=first;i<=last;i++) { 372 373 374 DRAW_POINT(i);375 376 } 377 } 378 379 if (IND & FX_FRONT_BACK) { 380 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 381 382 383 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 418 if(VB->ClipMask[i]==0) { 419 FLAT_COLOR(fxMesa, color[i]); 420 DRAW_POINT(i, sz); 421 } 422 } 423 } 424 425 if (IND & FX_FRONT_BACK) { 426 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 427 ctx->Color.ColorMask[GCOMP] || 428 ctx->Color.ColorMask[BCOMP], 429 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 384 430 if(ctx->Depth.Mask) 385 431 FX_grDepthMask(FXTRUE); 386 432 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 387 433 388 434 389 435 if(!VB->ClipOrMask) { 390 391 392 DRAW_POINT(i);393 436 for(i=first;i<=last;i++) { 437 FLAT_COLOR(fxMesa, color[i]); 438 DRAW_POINT(i, sz); 439 } 394 440 } else { 395 396 397 398 DRAW_POINT(i);399 400 441 for(i=first;i<=last;i++) { 442 if(VB->ClipMask[i]==0) { 443 FLAT_COLOR(fxMesa, color[i]); 444 DRAW_POINT(i, sz); 445 } 446 } 401 447 } 402 448 } … … 412 458 quad_tab[IND] = TAG(fx_quad); 413 459 414 #if ((IND & FX_OFFSET) == 0) 460 #if ((IND & FX_OFFSET) == 0) 415 461 line_tab[IND] = TAG(fx_line); 416 462 points_tab[IND] = TAG(fx_points); 417 #else 463 #else 418 464 line_tab[IND] = line_tab[IND & ~FX_OFFSET]; 419 465 points_tab[IND] = points_tab[IND & ~FX_OFFSET];
Note:
See TracChangeset
for help on using the changeset viewer.