Changeset 3597 for trunk/src/opengl/mesa/linetemp.h
- Timestamp:
- May 23, 2000, 10:35:01 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/linetemp.h
r2938 r3597 1 /* $Id: linetemp.h,v 1. 1 2000-02-29 00:48:32 sandervlExp $ */1 /* $Id: linetemp.h,v 1.2 2000-05-23 20:34:52 jeroen Exp $ */ 2 2 3 3 /* … … 53 53 * Y==0 at bottom of screen and increases upward. 54 54 * 55 * Similarly, for direct depth buffer access, this type is used for depth 56 * buffer addressing: 57 * DEPTH_TYPE - either GLushort or GLuint 58 * 55 59 * Optionally, one may provide one-time setup code 56 60 * SETUP_CODE - code which is to be executed once per line … … 82 86 GLint y1 = (GLint) VB->Win.data[vert1][1]; 83 87 GLint dx, dy; 84 #if INTERP_XY88 #ifdef INTERP_XY 85 89 GLint xstep, ystep; 86 90 #endif 87 #if INTERP_Z 88 GLint z0, z1, dz, zPtrXstep, zPtrYstep; 89 GLdepth *zPtr; 90 #endif 91 #if INTERP_RGB 91 #ifdef INTERP_Z 92 GLint z0, z1, dz; 93 const GLint depthBits = ctx->Visual->DepthBits; 94 const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0; 95 # define FixedToDepth(F) ((F) >> fixedToDepthShift) 96 # ifdef DEPTH_TYPE 97 GLint zPtrXstep, zPtrYstep; 98 DEPTH_TYPE *zPtr; 99 # endif 100 #endif 101 #ifdef INTERP_RGB 92 102 GLfixed r0 = IntToFixed(VB->ColorPtr->data[vert0][0]); 93 103 GLfixed dr = IntToFixed(VB->ColorPtr->data[vert1][0]) - r0; … … 97 107 GLfixed db = IntToFixed(VB->ColorPtr->data[vert1][2]) - b0; 98 108 #endif 99 #if INTERP_SPEC109 #ifdef INTERP_SPEC 100 110 GLfixed sr0 = VB->Specular ? IntToFixed(VB->Specular[vert0][0]) : 0; 101 111 GLfixed dsr = VB->Specular ? IntToFixed(VB->Specular[vert1][0]) - sr0 : 0; … … 105 115 GLfixed dsb = VB->Specular ? IntToFixed(VB->Specular[vert1][2]) - sb0 : 0; 106 116 #endif 107 #if INTERP_ALPHA117 #ifdef INTERP_ALPHA 108 118 GLfixed a0 = IntToFixed(VB->ColorPtr->data[vert0][3]); 109 119 GLfixed da = IntToFixed(VB->ColorPtr->data[vert1][3]) - a0; 110 120 #endif 111 #if INTERP_INDEX121 #ifdef INTERP_INDEX 112 122 GLint i0 = VB->IndexPtr->data[vert0] << 8; 113 GLint di = (GLint) (VB->IndexPtr->data[vert1] << 8) -i0;114 #endif 115 #if INTERP_ST123 GLint di = (GLint) (VB->IndexPtr->data[vert1] << 8) - i0; 124 #endif 125 #ifdef INTERP_ST 116 126 GLfixed s0 = FloatToFixed(VB->TexCoord[vert0][0] * S_SCALE); 117 127 GLfixed ds = FloatToFixed(VB->TexCoord[vert1][0] * S_SCALE) - s0; … … 119 129 GLfixed dt = FloatToFixed(VB->TexCoord[vert1][1] * T_SCALE) - t0; 120 130 #endif 121 #if INTERP_STUV0 || INTERP_STUV1131 #if defined(INTERP_STUV0) || defined(INTERP_STUV1) 122 132 GLfloat invw0 = VB->Win.data[vert0][3]; 123 133 GLfloat invw1 = VB->Win.data[vert1][3]; 124 134 #endif 125 #if INTERP_STUV0135 #ifdef INTERP_STUV0 126 136 /* h denotes hyperbolic */ 127 137 GLfloat hs0 = invw0 * VB->TexCoordPtr[0]->data[vert0][0]; … … 132 142 GLfloat hv0 = invw0, dhv = invw1 - invw0; 133 143 #endif 134 #if INTERP_STUV1144 #ifdef INTERP_STUV1 135 145 GLfloat hs01 = invw0 * VB->TexCoordPtr[1]->data[vert0][0]; 136 146 GLfloat dhs1 = invw1 * VB->TexCoordPtr[1]->data[vert1][0] - hs01; … … 144 154 GLint pixelXstep, pixelYstep; 145 155 #endif 146 #if WIDE156 #ifdef WIDE 147 157 /* for wide lines, draw all X in [x+min, x+max] or Y in [y+min, y+max] */ 148 158 GLint width, min, max; … … 151 161 max = min + width - 1; 152 162 #endif 153 #if INTERP_STUV0163 #ifdef INTERP_STUV0 154 164 if (VB->TexCoordPtr[0]->size > 2) { 155 165 hu0 = invw0 * VB->TexCoordPtr[0]->data[vert0][2]; 156 166 dhu = invw1 * VB->TexCoordPtr[0]->data[vert1][2] - hu0; 157 167 if (VB->TexCoordPtr[0]->size > 3) { 158 159 160 } 161 } 162 #endif 163 #if INTERP_STUV1168 hv0 = invw0 * VB->TexCoordPtr[0]->data[vert0][3]; 169 dhv = invw1 * VB->TexCoordPtr[0]->data[vert1][3] - hv0; 170 } 171 } 172 #endif 173 #ifdef INTERP_STUV1 164 174 if (VB->TexCoordPtr[1]->size > 2) { 165 175 hu01 = invw0 * VB->TexCoordPtr[1]->data[vert0][2]; 166 176 dhu1 = invw1 * VB->TexCoordPtr[1]->data[vert1][2] - hu01; 167 177 if (VB->TexCoordPtr[1]->size > 3) { 168 169 178 hv01 = invw0 * VB->TexCoordPtr[1]->data[vert0][3]; 179 dhv1 = invw1 * VB->TexCoordPtr[1]->data[vert1][3] - hv01; 170 180 } 171 181 } … … 179 189 * necessary. 180 190 */ 181 #if CLIP_HACK191 #ifdef CLIP_HACK 182 192 { 183 GLint w = ctx-> Buffer->Width;184 GLint h = ctx-> Buffer->Height;193 GLint w = ctx->DrawBuffer->Width; 194 GLint h = ctx->DrawBuffer->Height; 185 195 if ((x0==w) | (x1==w)) { 186 196 if ((x0==w) & (x1==w)) … … 210 220 #endif 211 221 212 #if INTERP_Z 213 zPtr = Z_ADDRESS(ctx,x0,y0); 214 # if DEPTH_BITS==16 222 #ifdef INTERP_Z 223 # ifdef DEPTH_TYPE 224 zPtr = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, x0, y0); 225 # endif 226 if (depthBits <= 16) { 215 227 z0 = FloatToFixed(VB->Win.data[vert0][2]); 216 228 z1 = FloatToFixed(VB->Win.data[vert1][2]); 217 # else 229 } 230 else { 218 231 z0 = (int) VB->Win.data[vert0][2]; 219 232 z1 = (int) VB->Win.data[vert1][2]; 220 # endif 233 } 221 234 #endif 222 235 #ifdef PIXEL_ADDRESS … … 225 238 226 239 if (dx<0) { 227 dx = -dx; /* make positive*/228 #if INTERP_XY240 dx = -dx; /* make positive*/ 241 #ifdef INTERP_XY 229 242 xstep = -1; 230 243 #endif 231 #if def INTERP_Z232 zPtrXstep = -((GLint)sizeof( GLdepth));244 #if defined(INTERP_Z) && defined(DEPTH_TYPE) 245 zPtrXstep = -((GLint)sizeof(DEPTH_TYPE)); 233 246 #endif 234 247 #ifdef PIXEL_ADDRESS … … 237 250 } 238 251 else { 239 #if INTERP_XY252 #ifdef INTERP_XY 240 253 xstep = 1; 241 254 #endif 242 #if INTERP_Z243 zPtrXstep = ((GLint)sizeof( GLdepth));255 #if defined(INTERP_Z) && defined(DEPTH_TYPE) 256 zPtrXstep = ((GLint)sizeof(DEPTH_TYPE)); 244 257 #endif 245 258 #ifdef PIXEL_ADDRESS … … 249 262 250 263 if (dy<0) { 251 dy = -dy; /* make positive*/252 #if INTERP_XY264 dy = -dy; /* make positive*/ 265 #ifdef INTERP_XY 253 266 ystep = -1; 254 267 #endif 255 #if INTERP_Z256 zPtrYstep = -ctx-> Buffer->Width * ((GLint)sizeof(GLdepth));268 #if defined(INTERP_Z) && defined(DEPTH_TYPE) 269 zPtrYstep = -ctx->DrawBuffer->Width * ((GLint)sizeof(DEPTH_TYPE)); 257 270 #endif 258 271 #ifdef PIXEL_ADDRESS … … 261 274 } 262 275 else { 263 #if INTERP_XY276 #ifdef INTERP_XY 264 277 ystep = 1; 265 278 #endif 266 #if INTERP_Z267 zPtrYstep = ctx-> Buffer->Width * ((GLint)sizeof(GLdepth));279 #if defined(INTERP_Z) && defined(DEPTH_TYPE) 280 zPtrYstep = ctx->DrawBuffer->Width * ((GLint)sizeof(DEPTH_TYPE)); 268 281 #endif 269 282 #ifdef PIXEL_ADDRESS … … 282 295 GLint error = errorInc-dx; 283 296 GLint errorDec = error-dx; 284 #if INTERP_Z297 #ifdef INTERP_Z 285 298 dz = (z1-z0) / dx; 286 299 #endif 287 #if INTERP_RGB288 dr /= dx; /* convert from whole line delta to per-pixel delta*/300 #ifdef INTERP_RGB 301 dr /= dx; /* convert from whole line delta to per-pixel delta*/ 289 302 dg /= dx; 290 303 db /= dx; 291 304 #endif 292 #if INTERP_SPEC293 dsr /= dx; /* convert from whole line delta to per-pixel delta*/305 #ifdef INTERP_SPEC 306 dsr /= dx; /* convert from whole line delta to per-pixel delta*/ 294 307 dsg /= dx; 295 308 dsb /= dx; 296 309 #endif 297 #if INTERP_ALPHA310 #ifdef INTERP_ALPHA 298 311 da /= dx; 299 312 #endif 300 #if INTERP_INDEX313 #ifdef INTERP_INDEX 301 314 di /= dx; 302 315 #endif 303 #if INTERP_ST316 #ifdef INTERP_ST 304 317 ds /= dx; 305 318 dt /= dx; 306 319 #endif 307 #if INTERP_STUV0320 #ifdef INTERP_STUV0 308 321 { 309 322 GLfloat invDx = 1.0F / (GLfloat) dx; … … 314 327 } 315 328 #endif 316 #if INTERP_STUV1329 #ifdef INTERP_STUV1 317 330 { 318 331 GLfloat invDx = 1.0F / (GLfloat) dx; … … 324 337 #endif 325 338 for (i=0;i<dx;i++) { 326 #if STIPPLE339 #ifdef STIPPLE 327 340 GLushort m; 328 341 m = 1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf); 329 342 if (ctx->Line.StipplePattern & m) { 330 343 #endif 331 #if INTERP_Z 332 # if DEPTH_BITS==16 333 GLdepth Z = FixedToInt(z0); 334 # else 335 GLdepth Z = z0; 336 # endif 337 #endif 338 #if INTERP_INDEX 344 #ifdef INTERP_Z 345 GLdepth Z = FixedToDepth(z0); 346 #endif 347 #ifdef INTERP_INDEX 339 348 GLint I = i0 >> 8; 340 349 #endif 341 #if INTERP_STUV0350 #ifdef INTERP_STUV0 342 351 GLfloat invQ = 1.0F / hv0; 343 352 GLfloat s = hs0 * invQ; … … 345 354 GLfloat u = hu0 * invQ; 346 355 #endif 347 #if INTERP_STUV1356 #ifdef INTERP_STUV1 348 357 GLfloat invQ1 = 1.0F / hv01; 349 358 GLfloat s1 = hs01 * invQ1; … … 351 360 GLfloat u1 = hu01 * invQ1; 352 361 #endif 353 #if WIDE362 #ifdef WIDE 354 363 GLint yy; 355 364 GLint ymin = y0 + min; … … 364 373 PLOT( x0, y0 ); 365 374 # endif 366 #endif /*WIDE*/367 #if STIPPLE375 #endif /* WIDE */ 376 #ifdef STIPPLE 368 377 } 369 370 #endif 371 #if INTERP_XY378 ctx->StippleCounter++; 379 #endif 380 #ifdef INTERP_XY 372 381 x0 += xstep; 373 382 #endif 374 #if INTERP_Z 375 zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrXstep); 383 #ifdef INTERP_Z 384 # ifdef DEPTH_TYPE 385 zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep); 386 # endif 376 387 z0 += dz; 377 388 #endif 378 #if INTERP_RGB389 #ifdef INTERP_RGB 379 390 r0 += dr; 380 391 g0 += dg; 381 392 b0 += db; 382 393 #endif 383 #if INTERP_SPEC394 #ifdef INTERP_SPEC 384 395 sr0 += dsr; 385 396 sg0 += dsg; 386 397 sb0 += dsb; 387 398 #endif 388 #if INTERP_ALPHA399 #ifdef INTERP_ALPHA 389 400 a0 += da; 390 401 #endif 391 #if INTERP_INDEX402 #ifdef INTERP_INDEX 392 403 i0 += di; 393 404 #endif 394 #if INTERP_ST405 #ifdef INTERP_ST 395 406 s0 += ds; 396 407 t0 += dt; 397 408 #endif 398 #if INTERP_STUV0409 #ifdef INTERP_STUV0 399 410 hs0 += dhs; 400 411 ht0 += dht; … … 402 413 hv0 += dhv; 403 414 #endif 404 #if INTERP_STUV1415 #ifdef INTERP_STUV1 405 416 hs01 += dhs1; 406 417 ht01 += dht1; … … 416 427 else { 417 428 error += errorDec; 418 #if INTERP_XY429 #ifdef INTERP_XY 419 430 y0 += ystep; 420 431 #endif 421 #if INTERP_Z422 zPtr = ( GLdepth*) ((GLubyte*) zPtr + zPtrYstep);432 #if defined(INTERP_Z) && defined(DEPTH_TYPE) 433 zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep); 423 434 #endif 424 435 #ifdef PIXEL_ADDRESS … … 434 445 GLint error = errorInc-dy; 435 446 GLint errorDec = error-dy; 436 #if INTERP_Z447 #ifdef INTERP_Z 437 448 dz = (z1-z0) / dy; 438 449 #endif 439 #if INTERP_RGB440 dr /= dy; /* convert from whole line delta to per-pixel delta*/450 #ifdef INTERP_RGB 451 dr /= dy; /* convert from whole line delta to per-pixel delta*/ 441 452 dg /= dy; 442 453 db /= dy; 443 454 #endif 444 #if INTERP_SPEC445 dsr /= dy; /* convert from whole line delta to per-pixel delta*/455 #ifdef INTERP_SPEC 456 dsr /= dy; /* convert from whole line delta to per-pixel delta*/ 446 457 dsg /= dy; 447 458 dsb /= dy; 448 459 #endif 449 #if INTERP_ALPHA460 #ifdef INTERP_ALPHA 450 461 da /= dy; 451 462 #endif 452 #if INTERP_INDEX463 #ifdef INTERP_INDEX 453 464 di /= dy; 454 465 #endif 455 #if INTERP_ST466 #ifdef INTERP_ST 456 467 ds /= dy; 457 468 dt /= dy; 458 469 #endif 459 #if INTERP_STUV0470 #ifdef INTERP_STUV0 460 471 { 461 472 GLfloat invDy = 1.0F / (GLfloat) dy; … … 466 477 } 467 478 #endif 468 #if INTERP_STUV1479 #ifdef INTERP_STUV1 469 480 { 470 481 GLfloat invDy = 1.0F / (GLfloat) dy; … … 476 487 #endif 477 488 for (i=0;i<dy;i++) { 478 #if STIPPLE489 #ifdef STIPPLE 479 490 GLushort m; 480 491 m = 1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf); 481 492 if (ctx->Line.StipplePattern & m) { 482 493 #endif 483 #if INTERP_Z 484 # if DEPTH_BITS==16 485 GLdepth Z = FixedToInt(z0); 486 # else 487 GLdepth Z = z0; 488 # endif 489 #endif 490 #if INTERP_INDEX 494 #ifdef INTERP_Z 495 GLdepth Z = FixedToDepth(z0); 496 #endif 497 #ifdef INTERP_INDEX 491 498 GLint I = i0 >> 8; 492 499 #endif 493 #if INTERP_STUV0500 #ifdef INTERP_STUV0 494 501 GLfloat invQ = 1.0F / hv0; 495 502 GLfloat s = hs0 * invQ; … … 497 504 GLfloat u = hu0 * invQ; 498 505 #endif 499 #if INTERP_STUV1506 #ifdef INTERP_STUV1 500 507 GLfloat invQ1 = 1.0F / hv01; 501 508 GLfloat s1 = hs01 * invQ1; … … 503 510 GLfloat u1 = hu01 * invQ1; 504 511 #endif 505 #if WIDE512 #ifdef WIDE 506 513 GLint xx; 507 514 GLint xmin = x0 + min; … … 516 523 PLOT( x0, y0 ); 517 524 # endif 518 #endif /*WIDE*/519 #if STIPPLE525 #endif /* WIDE */ 526 #ifdef STIPPLE 520 527 } 521 522 #endif 523 #if INTERP_XY528 ctx->StippleCounter++; 529 #endif 530 #ifdef INTERP_XY 524 531 y0 += ystep; 525 532 #endif 526 #if INTERP_Z 527 zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrYstep); 533 #ifdef INTERP_Z 534 # ifdef DEPTH_TYPE 535 zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep); 536 # endif 528 537 z0 += dz; 529 538 #endif 530 #if INTERP_RGB539 #ifdef INTERP_RGB 531 540 r0 += dr; 532 541 g0 += dg; 533 542 b0 += db; 534 543 #endif 535 #if INTERP_SPEC544 #ifdef INTERP_SPEC 536 545 sr0 += dsr; 537 546 sg0 += dsg; 538 547 sb0 += dsb; 539 548 #endif 540 #if INTERP_ALPHA549 #ifdef INTERP_ALPHA 541 550 a0 += da; 542 551 #endif 543 #if INTERP_INDEX552 #ifdef INTERP_INDEX 544 553 i0 += di; 545 554 #endif 546 #if INTERP_ST555 #ifdef INTERP_ST 547 556 s0 += ds; 548 557 t0 += dt; 549 558 #endif 550 #if INTERP_STUV0559 #ifdef INTERP_STUV0 551 560 hs0 += dhs; 552 561 ht0 += dht; … … 554 563 hv0 += dhv; 555 564 #endif 556 #if INTERP_STUV1565 #ifdef INTERP_STUV1 557 566 hs01 += dhs1; 558 567 ht01 += dht1; … … 568 577 else { 569 578 error += errorDec; 570 #if INTERP_XY579 #ifdef INTERP_XY 571 580 x0 += xstep; 572 581 #endif 573 #if INTERP_Z574 zPtr = ( GLdepth*) ((GLubyte*) zPtr + zPtrXstep);582 #if defined(INTERP_Z) && defined(DEPTH_TYPE) 583 zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep); 575 584 #endif 576 585 #ifdef PIXEL_ADDRESS … … 594 603 #undef PIXEL_ADDRESS 595 604 #undef PIXEL_TYPE 605 #undef DEPTH_TYPE 596 606 #undef BYTES_PER_ROW 597 607 #undef SETUP_CODE … … 602 612 #undef STIPPLE 603 613 #undef WIDE 614 #undef FixedToDepth
Note:
See TracChangeset
for help on using the changeset viewer.