| 1 | /* $Id: lnaatemp.h,v 1.2 2000-05-23 20:34:52 jeroen Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Mesa 3-D graphics library
|
|---|
| 5 | * Version: 3.1
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
|---|
| 8 | *
|
|---|
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
|---|
| 10 | * copy of this software and associated documentation files (the "Software"),
|
|---|
| 11 | * to deal in the Software without restriction, including without limitation
|
|---|
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|---|
| 13 | * and/or sell copies of the Software, and to permit persons to whom the
|
|---|
| 14 | * Software is furnished to do so, subject to the following conditions:
|
|---|
| 15 | *
|
|---|
| 16 | * The above copyright notice and this permission notice shall be included
|
|---|
| 17 | * in all copies or substantial portions of the Software.
|
|---|
| 18 | *
|
|---|
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|---|
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|---|
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|---|
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|---|
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|---|
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | /*
|
|---|
| 29 | * Antialiased Line Rasterizer Template
|
|---|
| 30 | *
|
|---|
| 31 | * This file is #include'd to generate custom line rasterizers.
|
|---|
| 32 | *
|
|---|
| 33 | * The following macros may be defined to indicate what auxillary information
|
|---|
| 34 | * must be interplated along the line:
|
|---|
| 35 | * INTERP_RGBA - if defined, interpolate RGBA values
|
|---|
| 36 | * INTERP_SPEC - if defined, interpolate specular RGB values
|
|---|
| 37 | * INTERP_INDEX - if defined, interpolate color index values
|
|---|
| 38 | * INTERP_STUV0 - if defined, interpolate unit 0 STU texcoords with
|
|---|
| 39 | * perspective correction
|
|---|
| 40 | * NOTE: OpenGL STRQ = Mesa STUV (R was taken for red)
|
|---|
| 41 | * INTERP_STUV1 - if defined, interpolate unit 1 STU texcoords
|
|---|
| 42 | *
|
|---|
| 43 | * Optionally, one may provide one-time setup code
|
|---|
| 44 | * SETUP_CODE - code which is to be executed once per line
|
|---|
| 45 | *
|
|---|
| 46 | * To actually "plot" each pixel the PLOT macro must be defined.
|
|---|
| 47 | *
|
|---|
| 48 | * This code was designed for the origin to be in the lower-left corner.
|
|---|
| 49 | */
|
|---|
| 50 |
|
|---|
| 51 | /* void aa_line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert ) */
|
|---|
| 52 | {
|
|---|
| 53 | const struct vertex_buffer *VB = ctx->VB;
|
|---|
| 54 | struct pixel_buffer *pb = ctx->PB;
|
|---|
| 55 | GLfloat halfWidth = 0.5F * ctx->Line.Width; /* 0.5 is a bit of a hack */
|
|---|
| 56 | GLboolean solid = !ctx->Line.StippleFlag;
|
|---|
| 57 | GLint x0 = (GLint) VB->Win.data[vert0][0];
|
|---|
| 58 | GLint x1 = (GLint) VB->Win.data[vert1][0];
|
|---|
| 59 | GLint y0 = (GLint) VB->Win.data[vert0][1];
|
|---|
| 60 | GLint y1 = (GLint) VB->Win.data[vert1][1];
|
|---|
| 61 | GLint dx = x1 - x0;
|
|---|
| 62 | GLint dy = y1 - y0;
|
|---|
| 63 | GLint xStep, yStep;
|
|---|
| 64 | GLint z0, z1;
|
|---|
| 65 | const GLint depthBits = ctx->Visual->DepthBits;
|
|---|
| 66 | const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
|
|---|
| 67 | #define FixedToDepth(F) ((F) >> fixedToDepthShift)
|
|---|
| 68 | #if INTERP_RGBA
|
|---|
| 69 | GLfixed fr, fg, fb, fa; /* fixed-pt RGBA */
|
|---|
| 70 | GLfixed dfr, dfg, dfb, dfa; /* fixed-pt RGBA deltas */
|
|---|
| 71 | #endif
|
|---|
| 72 | #if INTERP_SPEC
|
|---|
| 73 | GLfixed fsr, fsg, fsb; /* fixed-pt specular RGBA */
|
|---|
| 74 | GLfixed dfsr, dfsg, dfsb; /* fixed-pt specular RGBA deltas */
|
|---|
| 75 | #endif
|
|---|
| 76 | #if INTERP_INDEX
|
|---|
| 77 | GLfixed fi, dfi;
|
|---|
| 78 | #endif
|
|---|
| 79 | #if INTERP_STUV0 || INTERP_STUV1
|
|---|
| 80 | GLfloat invw0 = VB->Win.data[vert0][3];
|
|---|
| 81 | GLfloat invw1 = VB->Win.data[vert1][3];
|
|---|
| 82 | #endif
|
|---|
| 83 | #if INTERP_STUV0
|
|---|
| 84 | /* h denotes hyperbolic */
|
|---|
| 85 | GLfloat hs0 = invw0 * VB->TexCoordPtr[0]->data[vert0][0];
|
|---|
| 86 | GLfloat dhs = invw1 * VB->TexCoordPtr[0]->data[vert1][0] - hs0;
|
|---|
| 87 | GLfloat ht0 = invw0 * VB->TexCoordPtr[0]->data[vert0][1];
|
|---|
| 88 | GLfloat dht = invw1 * VB->TexCoordPtr[0]->data[vert1][1] - ht0;
|
|---|
| 89 | GLfloat hu0 = 0, dhu = 0;
|
|---|
| 90 | GLfloat hv0 = invw0, dhv = invw1 - invw0;
|
|---|
| 91 | #endif
|
|---|
| 92 | #if INTERP_STUV1
|
|---|
| 93 | GLfloat hs01 = invw0 * VB->TexCoordPtr[1]->data[vert0][0];
|
|---|
| 94 | GLfloat dhs1 = invw1 * VB->TexCoordPtr[1]->data[vert1][0] - hs01;
|
|---|
| 95 | GLfloat ht01 = invw0 * VB->TexCoordPtr[1]->data[vert0][1];
|
|---|
| 96 | GLfloat dht1 = invw1 * VB->TexCoordPtr[1]->data[vert1][1] - ht01;
|
|---|
| 97 | GLfloat hu01 = 0, dhu1 = 0;
|
|---|
| 98 | GLfloat hv01 = invw0, dhv1 = invw1 - invw0;
|
|---|
| 99 | #endif
|
|---|
| 100 |
|
|---|
| 101 | if (dx == 0 && dy == 0)
|
|---|
| 102 | return;
|
|---|
| 103 |
|
|---|
| 104 | if (depthBits <= 16) {
|
|---|
| 105 | z0 = FloatToFixed(VB->Win.data[vert0][2]);
|
|---|
| 106 | z1 = FloatToFixed(VB->Win.data[vert1][2]);
|
|---|
| 107 | }
|
|---|
| 108 | else {
|
|---|
| 109 | z0 = (int) VB->Win.data[vert0][2];
|
|---|
| 110 | z1 = (int) VB->Win.data[vert1][2];
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | #if INTERP_STUV0
|
|---|
| 114 | if (VB->TexCoordPtr[0]->size > 2) {
|
|---|
| 115 | hu0 = invw0 * VB->TexCoordPtr[0]->data[vert0][2];
|
|---|
| 116 | dhu = invw1 * VB->TexCoordPtr[0]->data[vert1][2] - hu0;
|
|---|
| 117 | if (VB->TexCoordPtr[0]->size > 3) {
|
|---|
| 118 | hv0 = invw0 * VB->TexCoordPtr[0]->data[vert0][3];
|
|---|
| 119 | dhv = invw1 * VB->TexCoordPtr[0]->data[vert1][3] - hv0;
|
|---|
| 120 | }
|
|---|
| 121 | }
|
|---|
| 122 | #endif
|
|---|
| 123 |
|
|---|
| 124 | #if INTERP_STUV1
|
|---|
| 125 | if (VB->TexCoordPtr[1]->size > 2) {
|
|---|
| 126 | hu01 = invw0 * VB->TexCoordPtr[1]->data[vert0][2];
|
|---|
| 127 | dhu1 = invw1 * VB->TexCoordPtr[1]->data[vert1][2] - hu01;
|
|---|
| 128 | if (VB->TexCoordPtr[1]->size > 3) {
|
|---|
| 129 | hv01 = invw0 * VB->TexCoordPtr[1]->data[vert0][3];
|
|---|
| 130 | dhv1 = invw1 * VB->TexCoordPtr[1]->data[vert1][3] - hv01;
|
|---|
| 131 | }
|
|---|
| 132 | }
|
|---|
| 133 | #endif
|
|---|
| 134 |
|
|---|
| 135 | #if INTERP_RGBA
|
|---|
| 136 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 137 | fr = IntToFixed(VB->ColorPtr->data[vert0][0]);
|
|---|
| 138 | fg = IntToFixed(VB->ColorPtr->data[vert0][1]);
|
|---|
| 139 | fb = IntToFixed(VB->ColorPtr->data[vert0][2]);
|
|---|
| 140 | fa = IntToFixed(VB->ColorPtr->data[vert0][3]);
|
|---|
| 141 | }
|
|---|
| 142 | else {
|
|---|
| 143 | fr = IntToFixed(VB->ColorPtr->data[pvert][0]);
|
|---|
| 144 | fg = IntToFixed(VB->ColorPtr->data[pvert][1]);
|
|---|
| 145 | fb = IntToFixed(VB->ColorPtr->data[pvert][2]);
|
|---|
| 146 | fa = IntToFixed(VB->ColorPtr->data[pvert][3]);
|
|---|
| 147 | dfr = dfg = dfb = dfa = 0;
|
|---|
| 148 | }
|
|---|
| 149 | #endif
|
|---|
| 150 | #if INTERP_SPEC
|
|---|
| 151 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 152 | fsr = IntToFixed(VB->Specular[vert0][0]);
|
|---|
| 153 | fsg = IntToFixed(VB->Specular[vert0][1]);
|
|---|
| 154 | fsb = IntToFixed(VB->Specular[vert0][2]);
|
|---|
| 155 | }
|
|---|
| 156 | else {
|
|---|
| 157 | fsr = IntToFixed(VB->Specular[pvert][0]);
|
|---|
| 158 | fsg = IntToFixed(VB->Specular[pvert][1]);
|
|---|
| 159 | fsb = IntToFixed(VB->Specular[pvert][2]);
|
|---|
| 160 | dfsr = dfsg = dfsb = 0;
|
|---|
| 161 | }
|
|---|
| 162 | #endif
|
|---|
| 163 | #if INTERP_INDEX
|
|---|
| 164 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 165 | fi = IntToFixed(VB->IndexPtr->data[vert0]);
|
|---|
| 166 | }
|
|---|
| 167 | else {
|
|---|
| 168 | fi = IntToFixed(VB->IndexPtr->data[pvert]);
|
|---|
| 169 | dfi = 0;
|
|---|
| 170 | }
|
|---|
| 171 | #endif
|
|---|
| 172 |
|
|---|
| 173 | /*
|
|---|
| 174 | * Setup
|
|---|
| 175 | */
|
|---|
| 176 | #ifdef SETUP_CODE
|
|---|
| 177 | SETUP_CODE
|
|---|
| 178 | #endif
|
|---|
| 179 |
|
|---|
| 180 | if (dx < 0) {
|
|---|
| 181 | xStep = -1;
|
|---|
| 182 | dx = -dx;
|
|---|
| 183 | }
|
|---|
| 184 | else {
|
|---|
| 185 | xStep = 1;
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | if (dy < 0) {
|
|---|
| 189 | yStep = -1;
|
|---|
| 190 | dy = -dy;
|
|---|
| 191 | }
|
|---|
| 192 | else {
|
|---|
| 193 | yStep = 1;
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | if (dx > dy) {
|
|---|
| 197 | /*** X-major line ***/
|
|---|
| 198 | GLint i;
|
|---|
| 199 | GLint x = x0;
|
|---|
| 200 | GLfloat y = VB->Win.data[vert0][1];
|
|---|
| 201 | const GLfloat invDx = 1.0F / dx;
|
|---|
| 202 | GLfloat yStep = (VB->Win.data[vert1][1] - y) * invDx;
|
|---|
| 203 | GLint dz = (GLint) ((z1 - z0) * invDx);
|
|---|
| 204 | #if INTERP_RGBA
|
|---|
| 205 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 206 | dfr = (IntToFixed(VB->ColorPtr->data[vert1][0]) - fr) * invDx;
|
|---|
| 207 | dfg = (IntToFixed(VB->ColorPtr->data[vert1][1]) - fg) * invDx;
|
|---|
| 208 | dfb = (IntToFixed(VB->ColorPtr->data[vert1][2]) - fb) * invDx;
|
|---|
| 209 | dfa = (IntToFixed(VB->ColorPtr->data[vert1][3]) - fa) * invDx;
|
|---|
| 210 | }
|
|---|
| 211 | #endif
|
|---|
| 212 | #if INTERP_SPEC
|
|---|
| 213 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 214 | dfsr = (IntToFixed(VB->Specular[vert1][0]) - fsr) * invDx;
|
|---|
| 215 | dfsg = (IntToFixed(VB->Specular[vert1][1]) - fsg) * invDx;
|
|---|
| 216 | dfsb = (IntToFixed(VB->Specular[vert1][2]) - fsb) * invDx;
|
|---|
| 217 | }
|
|---|
| 218 | #endif
|
|---|
| 219 | #if INTERP_STUV0
|
|---|
| 220 | dhs *= invDx;
|
|---|
| 221 | dht *= invDx;
|
|---|
| 222 | dhu *= invDx;
|
|---|
| 223 | dhv *= invDx;
|
|---|
| 224 | #endif
|
|---|
| 225 | #if INTERP_STUV1
|
|---|
| 226 | dhs1 *= invDx;
|
|---|
| 227 | dht1 *= invDx;
|
|---|
| 228 | dhu1 *= invDx;
|
|---|
| 229 | dhv1 *= invDx;
|
|---|
| 230 | #endif
|
|---|
| 231 | #if INTERP_INDEX
|
|---|
| 232 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 233 | dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) * invDx;
|
|---|
| 234 | }
|
|---|
| 235 | #endif
|
|---|
| 236 |
|
|---|
| 237 | for (i = 0; i < dx; i++) {
|
|---|
| 238 | if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {
|
|---|
| 239 |
|
|---|
| 240 | GLfloat yTop = y + halfWidth;
|
|---|
| 241 | GLfloat yBot = y - halfWidth;
|
|---|
| 242 | GLint yTopi = (GLint) yTop;
|
|---|
| 243 | GLint yBoti = (GLint) yBot;
|
|---|
| 244 | GLint iy;
|
|---|
| 245 | #if INTERP_RGBA
|
|---|
| 246 | GLubyte red = FixedToInt(fr);
|
|---|
| 247 | GLubyte green = FixedToInt(fg);
|
|---|
| 248 | GLubyte blue = FixedToInt(fb);
|
|---|
| 249 | GLubyte alpha = FixedToInt(fa);
|
|---|
| 250 | GLint coverage;
|
|---|
| 251 | #endif
|
|---|
| 252 | #if INTERP_SPEC
|
|---|
| 253 | GLubyte specRed = FixedToInt(fsr);
|
|---|
| 254 | GLubyte specGreen = FixedToInt(fsg);
|
|---|
| 255 | GLubyte specBlue = FixedToInt(fsb);
|
|---|
| 256 | #endif
|
|---|
| 257 | #if INTERP_INDEX
|
|---|
| 258 | GLuint index = FixedToInt(fi) & 0xfffffff0;
|
|---|
| 259 | GLuint coverage;
|
|---|
| 260 | #endif
|
|---|
| 261 | GLdepth z = FixedToDepth(z0);
|
|---|
| 262 | ASSERT(yBoti <= yTopi);
|
|---|
| 263 |
|
|---|
| 264 | {
|
|---|
| 265 | #if INTERP_STUV0
|
|---|
| 266 | GLfloat invQ = 1.0F / hv0;
|
|---|
| 267 | GLfloat s = hs0 * invQ;
|
|---|
| 268 | GLfloat t = ht0 * invQ;
|
|---|
| 269 | GLfloat u = hu0 * invQ;
|
|---|
| 270 | #endif
|
|---|
| 271 | #if INTERP_STUV1
|
|---|
| 272 | GLfloat invQ1 = 1.0F / hv01;
|
|---|
| 273 | GLfloat s1 = hs01 * invQ1;
|
|---|
| 274 | GLfloat t1 = ht01 * invQ1;
|
|---|
| 275 | GLfloat u1 = hu01 * invQ1;
|
|---|
| 276 | #endif
|
|---|
| 277 |
|
|---|
| 278 | /* bottom pixel of swipe */
|
|---|
| 279 | #if INTERP_RGBA
|
|---|
| 280 | coverage = (GLint) (alpha * (1.0F - (yBot - yBoti)));
|
|---|
| 281 | #endif
|
|---|
| 282 | #if INTERP_INDEX
|
|---|
| 283 | coverage = (GLuint) (15.0F * (1.0F - (yBot - yBoti)));
|
|---|
| 284 | #endif
|
|---|
| 285 | PLOT(x, yBoti);
|
|---|
| 286 | yBoti++;
|
|---|
| 287 |
|
|---|
| 288 | /* top pixel of swipe */
|
|---|
| 289 | #if INTERP_RGBA
|
|---|
| 290 | coverage = (GLint) (alpha * (yTop - yTopi));
|
|---|
| 291 | #endif
|
|---|
| 292 | #if INTERP_INDEX
|
|---|
| 293 | coverage = (GLuint) (15.0F * (yTop - yTopi));
|
|---|
| 294 | #endif
|
|---|
| 295 | PLOT(x, yTopi);
|
|---|
| 296 | yTopi--;
|
|---|
| 297 |
|
|---|
| 298 | /* pixels between top and bottom with 100% coverage */
|
|---|
| 299 | #if INTERP_RGBA
|
|---|
| 300 | coverage = alpha;
|
|---|
| 301 | #endif
|
|---|
| 302 | #if INTERP_INDEX
|
|---|
| 303 | coverage = 15;
|
|---|
| 304 | #endif
|
|---|
| 305 | for (iy = yBoti; iy <= yTopi; iy++) {
|
|---|
| 306 | PLOT(x, iy);
|
|---|
| 307 | }
|
|---|
| 308 | }
|
|---|
| 309 | PB_CHECK_FLUSH( ctx, pb );
|
|---|
| 310 |
|
|---|
| 311 | } /* if stippling */
|
|---|
| 312 |
|
|---|
| 313 | x += xStep;
|
|---|
| 314 | y += yStep;
|
|---|
| 315 | z0 += dz;
|
|---|
| 316 | #if INTERP_RGBA
|
|---|
| 317 | fr += dfr;
|
|---|
| 318 | fg += dfg;
|
|---|
| 319 | fb += dfb;
|
|---|
| 320 | fa += dfa;
|
|---|
| 321 | #endif
|
|---|
| 322 | #if INTERP_SPEC
|
|---|
| 323 | fsr += dfsr;
|
|---|
| 324 | fsg += dfsg;
|
|---|
| 325 | fsb += dfsb;
|
|---|
| 326 | #endif
|
|---|
| 327 | #if INTERP_STUV0
|
|---|
| 328 | hs0 += dhs;
|
|---|
| 329 | ht0 += dht;
|
|---|
| 330 | hu0 += dhu;
|
|---|
| 331 | hv0 += dhv;
|
|---|
| 332 | #endif
|
|---|
| 333 | #if INTERP_STUV1
|
|---|
| 334 | hs01 += dhs1;
|
|---|
| 335 | ht01 += dht1;
|
|---|
| 336 | hu01 += dhu1;
|
|---|
| 337 | hv01 += dhv1;
|
|---|
| 338 | #endif
|
|---|
| 339 | #if INTERP_INDEX
|
|---|
| 340 | fi += dfi;
|
|---|
| 341 | #endif
|
|---|
| 342 |
|
|---|
| 343 | if (!solid)
|
|---|
| 344 | ctx->StippleCounter++;
|
|---|
| 345 | }
|
|---|
| 346 | }
|
|---|
| 347 | else {
|
|---|
| 348 | /*** Y-major line ***/
|
|---|
| 349 | GLint i;
|
|---|
| 350 | GLint y = y0;
|
|---|
| 351 | GLfloat x = VB->Win.data[vert0][0];
|
|---|
| 352 | const GLfloat invDy = 1.0F / dy;
|
|---|
| 353 | GLfloat xStep = (VB->Win.data[vert1][0] - x) * invDy;
|
|---|
| 354 | GLint dz = (GLint) ((z1 - z0) * invDy);
|
|---|
| 355 | #if INTERP_RGBA
|
|---|
| 356 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 357 | dfr = (IntToFixed(VB->ColorPtr->data[vert1][0]) - fr) * invDy;
|
|---|
| 358 | dfg = (IntToFixed(VB->ColorPtr->data[vert1][1]) - fg) * invDy;
|
|---|
| 359 | dfb = (IntToFixed(VB->ColorPtr->data[vert1][2]) - fb) * invDy;
|
|---|
| 360 | dfa = (IntToFixed(VB->ColorPtr->data[vert1][3]) - fa) * invDy;
|
|---|
| 361 | }
|
|---|
| 362 | #endif
|
|---|
| 363 | #if INTERP_SPEC
|
|---|
| 364 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 365 | dfsr = (IntToFixed(VB->Specular[vert1][0]) - fsr) * invDy;
|
|---|
| 366 | dfsg = (IntToFixed(VB->Specular[vert1][1]) - fsg) * invDy;
|
|---|
| 367 | dfsb = (IntToFixed(VB->Specular[vert1][2]) - fsb) * invDy;
|
|---|
| 368 | }
|
|---|
| 369 | #endif
|
|---|
| 370 | #if INTERP_STUV0
|
|---|
| 371 | dhs *= invDy;
|
|---|
| 372 | dht *= invDy;
|
|---|
| 373 | dhu *= invDy;
|
|---|
| 374 | dhv *= invDy;
|
|---|
| 375 | #endif
|
|---|
| 376 | #if INTERP_STUV1
|
|---|
| 377 | dhs1 *= invDy;
|
|---|
| 378 | dht1 *= invDy;
|
|---|
| 379 | dhu1 *= invDy;
|
|---|
| 380 | dhv1 *= invDy;
|
|---|
| 381 | #endif
|
|---|
| 382 | #if INTERP_INDEX
|
|---|
| 383 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
|---|
| 384 | dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) * invDy;
|
|---|
| 385 | }
|
|---|
| 386 | #endif
|
|---|
| 387 | for (i = 0; i < dy; i++) {
|
|---|
| 388 | if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {
|
|---|
| 389 | GLfloat xRight = x + halfWidth;
|
|---|
| 390 | GLfloat xLeft = x - halfWidth;
|
|---|
| 391 | GLint xRighti = (GLint) xRight;
|
|---|
| 392 | GLint xLefti = (GLint) xLeft;
|
|---|
| 393 | GLint ix;
|
|---|
| 394 | #if INTERP_RGBA
|
|---|
| 395 | GLubyte red = FixedToInt(fr);
|
|---|
| 396 | GLubyte green = FixedToInt(fg);
|
|---|
| 397 | GLubyte blue = FixedToInt(fb);
|
|---|
| 398 | GLubyte alpha = FixedToInt(fa);
|
|---|
| 399 | GLint coverage;
|
|---|
| 400 | #endif
|
|---|
| 401 | #if INTERP_SPEC
|
|---|
| 402 | GLubyte specRed = FixedToInt(fsr);
|
|---|
| 403 | GLubyte specGreen = FixedToInt(fsg);
|
|---|
| 404 | GLubyte specBlue = FixedToInt(fsb);
|
|---|
| 405 | #endif
|
|---|
| 406 | #if INTERP_INDEX
|
|---|
| 407 | GLuint index = FixedToInt(fi) & 0xfffffff0;
|
|---|
| 408 | GLuint coverage;
|
|---|
| 409 | #endif
|
|---|
| 410 | GLdepth z = FixedToDepth(z0);
|
|---|
| 411 |
|
|---|
| 412 | ASSERT(xLefti < xRight);
|
|---|
| 413 |
|
|---|
| 414 | {
|
|---|
| 415 | #if INTERP_STUV0
|
|---|
| 416 | GLfloat invQ = 1.0F / hv0;
|
|---|
| 417 | GLfloat s = hs0 * invQ;
|
|---|
| 418 | GLfloat t = ht0 * invQ;
|
|---|
| 419 | GLfloat u = hu0 * invQ;
|
|---|
| 420 | #endif
|
|---|
| 421 | #if INTERP_STUV1
|
|---|
| 422 | GLfloat invQ1 = 1.0F / hv01;
|
|---|
| 423 | GLfloat s1 = hs01 * invQ1;
|
|---|
| 424 | GLfloat t1 = ht01 * invQ1;
|
|---|
| 425 | GLfloat u1 = hu01 * invQ1;
|
|---|
| 426 | #endif
|
|---|
| 427 |
|
|---|
| 428 | /* left pixel of swipe */
|
|---|
| 429 | #if INTERP_RGBA
|
|---|
| 430 | coverage = (GLint) (alpha * (1.0F - (xLeft - xLefti)));
|
|---|
| 431 | #endif
|
|---|
| 432 | #if INTERP_INDEX
|
|---|
| 433 | coverage = (GLuint) (15.0F * (1.0F - (xLeft - xLefti)));
|
|---|
| 434 | #endif
|
|---|
| 435 | PLOT(xLefti, y);
|
|---|
| 436 | xLefti++;
|
|---|
| 437 |
|
|---|
| 438 | /* right pixel of swipe */
|
|---|
| 439 | #if INTERP_RGBA
|
|---|
| 440 | coverage = (GLint) (alpha * (xRight - xRighti));
|
|---|
| 441 | #endif
|
|---|
| 442 | #if INTERP_INDEX
|
|---|
| 443 | coverage = (GLuint) (15.0F * (xRight - xRighti));
|
|---|
| 444 | #endif
|
|---|
| 445 | PLOT(xRighti, y)
|
|---|
| 446 | xRighti--;
|
|---|
| 447 |
|
|---|
| 448 | /* pixels between top and bottom with 100% coverage */
|
|---|
| 449 | #if INTERP_RGBA
|
|---|
| 450 | coverage = alpha;
|
|---|
| 451 | #endif
|
|---|
| 452 | #if INTERP_INDEX
|
|---|
| 453 | coverage = 15;
|
|---|
| 454 | #endif
|
|---|
| 455 | for (ix = xLefti; ix <= xRighti; ix++) {
|
|---|
| 456 | PLOT(ix, y);
|
|---|
| 457 | }
|
|---|
| 458 | }
|
|---|
| 459 | PB_CHECK_FLUSH( ctx, pb );
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | x += xStep;
|
|---|
| 463 | y += yStep;
|
|---|
| 464 | z0 += dz;
|
|---|
| 465 | #if INTERP_RGBA
|
|---|
| 466 | fr += dfr;
|
|---|
| 467 | fg += dfg;
|
|---|
| 468 | fb += dfb;
|
|---|
| 469 | fa += dfa;
|
|---|
| 470 | #endif
|
|---|
| 471 | #if INTERP_SPEC
|
|---|
| 472 | fsr += dfsr;
|
|---|
| 473 | fsg += dfsg;
|
|---|
| 474 | fsb += dfsb;
|
|---|
| 475 | #endif
|
|---|
| 476 | #if INTERP_STUV0
|
|---|
| 477 | hs0 += dhs;
|
|---|
| 478 | ht0 += dht;
|
|---|
| 479 | hu0 += dhu;
|
|---|
| 480 | hv0 += dhv;
|
|---|
| 481 | #endif
|
|---|
| 482 | #if INTERP_STUV1
|
|---|
| 483 | hs01 += dhs1;
|
|---|
| 484 | ht01 += dht1;
|
|---|
| 485 | hu01 += dhu1;
|
|---|
| 486 | hv01 += dhv1;
|
|---|
| 487 | #endif
|
|---|
| 488 | #if INTERP_INDEX
|
|---|
| 489 | fi += dfi;
|
|---|
| 490 | #endif
|
|---|
| 491 | if (!solid)
|
|---|
| 492 | ctx->StippleCounter++;
|
|---|
| 493 | }
|
|---|
| 494 | }
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | #undef INTERP_RGBA
|
|---|
| 498 | #undef INTERP_SPEC
|
|---|
| 499 | #undef INTERP_STUV0
|
|---|
| 500 | #undef INTERP_STUV1
|
|---|
| 501 | #undef INTERP_INDEX
|
|---|
| 502 | #undef PLOT
|
|---|