s_aalinetemp.h revision 733a4b602bbbfda83ee03b7ae4f3737bbe659034
1733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul/* $Id: s_aalinetemp.h,v 1.16 2002/02/02 17:24:11 brianp Exp $ */ 27798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 37798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 47798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Mesa 3-D graphics library 5733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul * Version: 4.1 622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 7733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. 822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 97798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Permission is hereby granted, free of charge, to any person obtaining a 107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * copy of this software and associated documentation files (the "Software"), 117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * to deal in the Software without restriction, including without limitation 127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * the rights to use, copy, modify, merge, publish, distribute, sublicense, 137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * and/or sell copies of the Software, and to permit persons to whom the 147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Software is furnished to do so, subject to the following conditions: 1522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * The above copyright notice and this permission notice shall be included 177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * in all copies or substantial portions of the Software. 1822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * 197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 227798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 237798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 247798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 257798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 267798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 277798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 287798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Antialiased line template. 307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 337798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 347798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Function to render each fragment in the AA line. 357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic void 37733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian PaulNAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) 387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fx = (GLfloat) ix; 407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat fy = (GLfloat) iy; 417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat coverage = compute_coveragef(line, ix, iy); 42733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul const GLuint i = line->span.end; 437798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 447798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (coverage == 0.0) 457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul return; 467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 47733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.end++; 48733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.coverage[i] = coverage; 49733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.xArray[i] = ix; 50733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.yArray[i] = iy; 51733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul 527798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* 537798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Compute Z, color, texture coords, fog for the fragment by 547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * solving the plane equations at (ix,iy). 557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_Z 57733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.zArray[i] = (GLdepth) solve_plane(fx, fy, line->zPlane); 587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_FOG 60733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.fogArray[i] = solve_plane(fx, fy, line->fPlane); 617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 627798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_RGBA 63733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.color.rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane); 64733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.color.rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane); 65733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.color.rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane); 66733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.color.rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane); 677798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 687798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_INDEX 69733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.color.index[i] = (GLint) solve_plane(fx, fy, line->iPlane); 707798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 717798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_SPEC 72733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.specArray[i][RCOMP] = solve_plane_chan(fx, fy, line->srPlane); 73733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.specArray[i][GCOMP] = solve_plane_chan(fx, fy, line->sgPlane); 74733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.specArray[i][BCOMP] = solve_plane_chan(fx, fy, line->sbPlane); 757798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 767798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_TEX 777798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul { 78733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul const GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[0]); 79733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.texcoords[0][i][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ; 80733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.texcoords[0][i][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ; 81733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.texcoords[0][i][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ; 82733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.lambda[0][i] = compute_lambda(line->sPlane[0], line->tPlane[0], invQ, 83733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->texWidth[0], line->texHeight[0]); 847798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 857798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#elif defined(DO_MULTITEX) 867798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul { 877798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLuint unit; 887798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { 897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (ctx->Texture.Unit[unit]._ReallyEnabled) { 90733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul const GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[unit]); 91733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.texcoords[unit][i][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ; 92733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.texcoords[unit][i][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ; 93733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.texcoords[unit][i][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ; 94733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->span.lambda[unit][i] = compute_lambda(line->sPlane[unit], 95733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->tPlane[unit], invQ, 96733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line->texWidth[unit], line->texHeight[unit]); 977798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 987798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 1007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 1017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 102733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul if (line->span.end == MAX_WIDTH) { 103733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul#ifdef DO_TEX 104733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul _mesa_write_texture_span(ctx, &line->span, GL_LINE); 1057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#elif defined(DO_RGBA) 106733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul _mesa_write_rgba_span(ctx, &line->span, GL_LINE); 107733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul#else 108733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul _mesa_write_index_span(ctx, &line->span, GL_LINE); 1097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 110733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul } 1117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 1127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul/* 1167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul * Line setup 1177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul */ 1187798374e472a8fa2f8699d38873e6b8490d853a4Brian Paulstatic void 119a852378a6289d154364dde440f89a39bbfc33e2dBrian PaulNAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) 1207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul{ 1217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul SWcontext *swrast = SWRAST_CONTEXT(ctx); 1227798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLfloat tStart, tEnd; /* segment start, end along line length */ 1237798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLboolean inSegment; 1247798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLint iLen, i; 1257798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1267798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* Init the LineInfo struct */ 1277798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul struct LineInfo line; 1287798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.x0 = v0->win[0]; 1297798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.y0 = v0->win[1]; 1307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.x1 = v1->win[0]; 1317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.y1 = v1->win[1]; 1327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.dx = line.x1 - line.x0; 1337798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.dy = line.y1 - line.y0; 1347b9fe820a3fba3849864682fbb1cb512362934abKarl Schultz line.len = (GLfloat) sqrt(line.dx * line.dx + line.dy * line.dy); 1357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.halfWidth = 0.5F * ctx->Line.Width; 136dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul 137ef4f5b391e560e535b25b372f797e41edeef09f1Keith Whitwell if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) 138dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul return; 139dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul 140733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul INIT_SPAN(line.span); 141733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= (SPAN_XY | SPAN_COVERAGE); 142733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul 143dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul line.xAdj = line.dx / line.len * line.halfWidth; 144dbed2027444338dc09fc102d6f4bd5c707c238d7Brian Paul line.yAdj = line.dy / line.len * line.halfWidth; 1457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 1467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_Z 147733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= SPAN_Z; 1487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->win[2], v1->win[2], line.zPlane); 1507798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 1517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_FOG 152733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= SPAN_FOG; 1537798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->fog, v1->fog, line.fPlane); 1557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 1567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_RGBA 157733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= SPAN_RGBA; 1587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (ctx->Light.ShadeModel == GL_SMOOTH) { 1597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1607798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->color[RCOMP], v1->color[RCOMP], line.rPlane); 1617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1627798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->color[GCOMP], v1->color[GCOMP], line.gPlane); 1637798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1647798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->color[BCOMP], v1->color[BCOMP], line.bPlane); 1657798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1667798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->color[ACOMP], v1->color[ACOMP], line.aPlane); 1677798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 1687798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 16958e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v1->color[RCOMP], line.rPlane); 17058e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v1->color[GCOMP], line.gPlane); 17158e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v1->color[BCOMP], line.bPlane); 17258e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v1->color[ACOMP], line.aPlane); 1737798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 1747798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 1757798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_SPEC 176733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= SPAN_SPEC; 1777798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (ctx->Light.ShadeModel == GL_SMOOTH) { 1787798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1797798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->specular[RCOMP], v1->specular[RCOMP], line.srPlane); 1807798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1817798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->specular[GCOMP], v1->specular[GCOMP], line.sgPlane); 1827798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1837798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul v0->specular[BCOMP], v1->specular[BCOMP], line.sbPlane); 1847798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 1857798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 18658e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v1->specular[RCOMP], line.srPlane); 18758e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v1->specular[GCOMP], line.sgPlane); 18858e991705392a2e17a1c8b034f4083a0adaf1943Keith Whitwell constant_plane(v1->specular[BCOMP], line.sbPlane); 1897798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 1907798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 1917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_INDEX 192733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= SPAN_INDEX; 1937798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (ctx->Light.ShadeModel == GL_SMOOTH) { 1947798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, 1957c4268176eaaeb45003db4d5042a518b84c9f6dcKarl Schultz (GLfloat) v0->index, (GLfloat) v1->index, line.iPlane); 1967798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 1977798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 1987c4268176eaaeb45003db4d5042a518b84c9f6dcKarl Schultz constant_plane((GLfloat) v1->index, line.iPlane); 1997798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2007798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 2017798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#ifdef DO_TEX 2027798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul { 2037798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; 2047798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; 2057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat invW0 = v0->win[3]; 2067798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat invW1 = v1->win[3]; 2077798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat s0 = v0->texcoord[0][0] * invW0; 2087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat s1 = v1->texcoord[0][0] * invW1; 2097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat t0 = v0->texcoord[0][1] * invW0; 2107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat t1 = v1->texcoord[0][1] * invW0; 2117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat r0 = v0->texcoord[0][2] * invW0; 2127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat r1 = v1->texcoord[0][2] * invW0; 2137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat q0 = v0->texcoord[0][3] * invW0; 2147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat q1 = v1->texcoord[0][3] * invW0; 215733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); 2167798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[0]); 2177798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[0]); 2187798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[0]); 2197798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[0]); 2207798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.texWidth[0] = (GLfloat) texImage->Width; 2217798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.texHeight[0] = (GLfloat) texImage->Height; 2227798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2236b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul#elif defined(DO_MULTITEX) 2247798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul { 2257798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul GLuint u; 226733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); 2277798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 2286b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul if (ctx->Texture.Unit[u]._ReallyEnabled) { 2296b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; 2307798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; 2317798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat invW0 = v0->win[3]; 2327798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat invW1 = v1->win[3]; 2337798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat s0 = v0->texcoord[u][0] * invW0; 2347798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat s1 = v1->texcoord[u][0] * invW1; 2357798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat t0 = v0->texcoord[u][1] * invW0; 2367798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat t1 = v1->texcoord[u][1] * invW0; 2377798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat r0 = v0->texcoord[u][2] * invW0; 2387798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat r1 = v1->texcoord[u][2] * invW0; 2397798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat q0 = v0->texcoord[u][3] * invW0; 2407798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat q1 = v1->texcoord[u][3] * invW0; 2417798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[u]); 2427798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[u]); 2436b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[u]); 2446b1e4ea5a54ea852a904440cd9fa50251f63f64cBrian Paul compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[u]); 2457798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.texWidth[u] = (GLfloat) texImage->Width; 2467798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul line.texHeight[u] = (GLfloat) texImage->Height; 2477798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2487798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2497798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2507798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#endif 2517798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2527798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul tStart = tEnd = 0.0; 2537798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul inSegment = GL_FALSE; 2547798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul iLen = (GLint) line.len; 2557798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 2567798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (ctx->Line.StippleFlag) { 2577798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul for (i = 0; i < iLen; i++) { 2587798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf; 2597798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if ((1 << bit) & ctx->Line.StipplePattern) { 2607798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* stipple bit is on */ 2617798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul const GLfloat t = (GLfloat) i / (GLfloat) line.len; 2627798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (!inSegment) { 2637798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* start new segment */ 2647798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul inSegment = GL_TRUE; 2657798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul tStart = t; 2667798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2677798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 2687798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* still in the segment, extend it */ 2697798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul tEnd = t; 2707798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2717798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2727798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 2737798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* stipple bit is off */ 2747798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul if (inSegment && (tEnd > tStart)) { 2757798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* draw the segment */ 276733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul segment(ctx, &line, NAME(plot), tStart, tEnd); 2777798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul inSegment = GL_FALSE; 2787798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2797798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 2807798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* still between segments, do nothing */ 2817798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2827798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2837798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul swrast->StippleCounter++; 2847798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 285426628c374d043c5ae2bb73079aff577fc31c138Brian Paul 286426628c374d043c5ae2bb73079aff577fc31c138Brian Paul if (inSegment) { 287426628c374d043c5ae2bb73079aff577fc31c138Brian Paul /* draw the final segment of the line */ 288733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul segment(ctx, &line, NAME(plot), tStart, 1.0F); 289426628c374d043c5ae2bb73079aff577fc31c138Brian Paul } 2907798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 2917798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul else { 2927798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul /* non-stippled */ 293733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul segment(ctx, &line, NAME(plot), 0.0, 1.0); 2947798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul } 295733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul 296733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul#ifdef DO_TEX 297733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul _mesa_write_texture_span(ctx, &line.span, GL_LINE); 298733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul#elif defined(DO_RGBA) 299733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul _mesa_write_rgba_span(ctx, &line.span, GL_LINE); 300733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul#else 301733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul _mesa_write_index_span(ctx, &line.span, GL_LINE); 302733a4b602bbbfda83ee03b7ae4f3737bbe659034Brian Paul#endif 3037798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul} 3047798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3057798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3067798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3077798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul 3087798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_Z 3097798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_FOG 3107798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_RGBA 3117798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_INDEX 3127798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_SPEC 3137798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_TEX 3147798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef DO_MULTITEX 3157798374e472a8fa2f8699d38873e6b8490d853a4Brian Paul#undef NAME 316