-/* $Id: s_aatritemp.h,v 1.11 2001/05/07 16:01:59 brianp Exp $ */
+/* $Id: s_aatritemp.h,v 1.18 2001/06/05 21:41:05 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLint iyMin, iyMax;
GLfloat yMin, yMax;
GLboolean ltor;
- GLfloat majDx, majDy;
+ GLfloat majDx, majDy; /* major (i.e. long) edge dx and dy */
+
#ifdef DO_Z
- GLfloat zPlane[4]; /* Z (depth) */
+ GLfloat zPlane[4];
GLdepth z[MAX_WIDTH];
+#endif
+#ifdef DO_FOG
GLfloat fogPlane[4];
GLfloat fog[MAX_WIDTH];
+#else
+ GLfloat *fog = NULL;
#endif
#ifdef DO_RGBA
- GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; /* color */
- GLchan rgba[MAX_WIDTH][4];
+ GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4];
+ DEFMARRAY(GLchan, rgba, MAX_WIDTH, 4); /* mac 32k limitation */
#endif
#ifdef DO_INDEX
- GLfloat iPlane[4]; /* color index */
+ GLfloat iPlane[4];
GLuint index[MAX_WIDTH];
+ GLint icoverageSpan[MAX_WIDTH];
+#else
+ GLfloat coverageSpan[MAX_WIDTH];
#endif
#ifdef DO_SPEC
- GLfloat srPlane[4], sgPlane[4], sbPlane[4]; /* spec color */
- GLchan spec[MAX_WIDTH][4];
+ GLfloat srPlane[4], sgPlane[4], sbPlane[4];
+ DEFMARRAY(GLchan, spec, MAX_WIDTH, 4);
#endif
#ifdef DO_TEX
GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4];
GLfloat texWidth, texHeight;
- GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH];
- GLfloat lambda[MAX_WIDTH];
+ DEFARRAY(GLfloat, s, MAX_WIDTH); /* mac 32k limitation */
+ DEFARRAY(GLfloat, t, MAX_WIDTH);
+ DEFARRAY(GLfloat, u, MAX_WIDTH);
+ DEFARRAY(GLfloat, lambda, MAX_WIDTH);
#elif defined(DO_MULTITEX)
GLfloat sPlane[MAX_TEXTURE_UNITS][4];
GLfloat tPlane[MAX_TEXTURE_UNITS][4];
GLfloat uPlane[MAX_TEXTURE_UNITS][4];
GLfloat vPlane[MAX_TEXTURE_UNITS][4];
GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS];
- GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH];
- GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH];
- GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH];
- GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH];
+ DEFMARRAY(GLfloat, s, MAX_TEXTURE_UNITS, MAX_WIDTH); /* mac 32k limit */
+ DEFMARRAY(GLfloat, t, MAX_TEXTURE_UNITS, MAX_WIDTH);
+ DEFMARRAY(GLfloat, u, MAX_TEXTURE_UNITS, MAX_WIDTH);
+ DEFMARRAY(GLfloat, lambda, MAX_TEXTURE_UNITS, MAX_WIDTH);
#endif
GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign;
+#ifdef DO_RGBA
+ CHECKARRAY(rgba, return); /* mac 32k limitation */
+#endif
+#ifdef DO_SPEC
+ CHECKARRAY(spec, return);
+#endif
+#if defined(DO_TEX) || defined(DO_MULTITEX)
+ CHECKARRAY(s, return);
+ CHECKARRAY(t, return);
+ CHECKARRAY(u, return);
+ CHECKARRAY(lambda, return);
+#endif
+
/* determine bottom to top order of vertices */
{
GLfloat y0 = v0->win[1];
ctx->OcclusionResult = GL_TRUE;
#endif
- /* plane setup */
+ /* Plane equation setup:
+ * We evaluate plane equations at window (x,y) coordinates in order
+ * to compute color, Z, fog, texcoords, etc. This isn't terribly
+ * efficient but it's easy and reliable.
+ */
#ifdef DO_Z
compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane);
- compute_plane(p0, p1, p2,
- v0->fog,
- v1->fog,
- v2->fog,
- fogPlane);
+#endif
+#ifdef DO_FOG
+ compute_plane(p0, p1, p2, v0->fog, v1->fog, v2->fog, fogPlane);
#endif
#ifdef DO_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
compute_plane(p0, p1, p2, v0->specular[2], v1->specular[2], v2->specular[2],sbPlane);
}
else {
- /* KW: added this */
constant_plane(v2->specular[RCOMP], srPlane);
constant_plane(v2->specular[GCOMP], sgPlane);
constant_plane(v2->specular[BCOMP], sbPlane);
}
#endif
+ /* Begin bottom-to-top scan over the triangle.
+ * The long edge will either be on the left or right side of the
+ * triangle. We always scan from the long edge toward the shorter
+ * edges, stopping when we find that coverage = 0. If the long edge
+ * is on the left we scan left-to-right. Else, we scan right-to-left.
+ */
yMin = vMin->win[1];
yMax = vMax->win[1];
- iyMin = (int) yMin;
- iyMax = (int) yMax + 1;
+ iyMin = (GLint) yMin;
+ iyMax = (GLint) yMax + 1;
if (ltor) {
/* scan left to right */
- const float *pMin = vMin->win;
- const float *pMid = vMid->win;
- const float *pMax = vMax->win;
- const float dxdy = majDx / majDy;
- const float xAdj = dxdy < 0.0F ? -dxdy : 0.0F;
- float x = vMin->win[0] - (yMin - iyMin) * dxdy;
- int iy;
+ const GLfloat *pMin = vMin->win;
+ const GLfloat *pMid = vMid->win;
+ const GLfloat *pMax = vMax->win;
+ const GLfloat dxdy = majDx / majDy;
+ const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F;
+ GLfloat x = pMin[0] - (yMin - iyMin) * dxdy;
+ GLint iy;
for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
GLint ix, startX = (GLint) (x - xAdj);
GLuint count, n;
while (coverage > 0.0F) {
/* (cx,cy) = center of fragment */
const GLfloat cx = ix + 0.5F, cy = iy + 0.5F;
+#ifdef DO_INDEX
+ icoverageSpan[count] = compute_coveragei(pMin, pMid, pMax, ix, iy);
+#else
+ coverageSpan[count] = coverage;
+#endif
#ifdef DO_Z
z[count] = (GLdepth) solve_plane(cx, cy, zPlane);
+#endif
+#ifdef DO_FOG
fog[count] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane);
rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane);
rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane);
- rgba[count][ACOMP] = (GLchan) (solve_plane_chan(cx, cy, aPlane) * coverage);
+ rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane);
#endif
#ifdef DO_INDEX
- {
- GLint frac = compute_coveragei(pMin, pMid, pMax, ix, iy);
- GLint indx = (GLint) solve_plane(cx, cy, iPlane);
- index[count] = (indx & ~0xf) | frac;
- }
+ index[count] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
spec[count][RCOMP] = solve_plane_chan(cx, cy, srPlane);
coverage = compute_coveragef(pMin, pMid, pMax, ix, iy);
}
+ if (ix <= startX)
+ continue;
+
n = (GLuint) ix - (GLuint) startX;
+
#ifdef DO_MULTITEX
# ifdef DO_SPEC
_mesa_write_multitexture_span(ctx, n, startX, iy, z, fog,
- (const GLfloat (*)[MAX_WIDTH]) s,
- (const GLfloat (*)[MAX_WIDTH]) t,
- (const GLfloat (*)[MAX_WIDTH]) u,
- (GLfloat (*)[MAX_WIDTH]) lambda,
- rgba, (const GLchan (*)[4]) spec,
- GL_POLYGON);
+ (const GLfloat (*)[MAX_WIDTH]) s,
+ (const GLfloat (*)[MAX_WIDTH]) t,
+ (const GLfloat (*)[MAX_WIDTH]) u,
+ (GLfloat (*)[MAX_WIDTH]) lambda,
+ rgba, (const GLchan (*)[4]) spec,
+ coverageSpan, GL_POLYGON);
# else
_mesa_write_multitexture_span(ctx, n, startX, iy, z, fog,
- (const GLfloat (*)[MAX_WIDTH]) s,
- (const GLfloat (*)[MAX_WIDTH]) t,
- (const GLfloat (*)[MAX_WIDTH]) u,
- lambda, rgba, NULL, GL_POLYGON);
+ (const GLfloat (*)[MAX_WIDTH]) s,
+ (const GLfloat (*)[MAX_WIDTH]) t,
+ (const GLfloat (*)[MAX_WIDTH]) u,
+ lambda, rgba, NULL, coverageSpan,
+ GL_POLYGON);
# endif
#elif defined(DO_TEX)
# ifdef DO_SPEC
_mesa_write_texture_span(ctx, n, startX, iy, z, fog,
- s, t, u, lambda, rgba,
- (const GLchan (*)[4]) spec, GL_POLYGON);
+ s, t, u, lambda, rgba,
+ (const GLchan (*)[4]) spec,
+ coverageSpan, GL_POLYGON);
# else
_mesa_write_texture_span(ctx, n, startX, iy, z, fog,
- s, t, u, lambda,
- rgba, NULL, GL_POLYGON);
+ s, t, u, lambda,
+ rgba, NULL, coverageSpan, GL_POLYGON);
# endif
#elif defined(DO_RGBA)
- _mesa_write_rgba_span(ctx, n, startX, iy, z, fog, rgba, GL_POLYGON);
+ _mesa_write_rgba_span(ctx, n, startX, iy, z, fog, rgba,
+ coverageSpan, GL_POLYGON);
#elif defined(DO_INDEX)
- _mesa_write_index_span(ctx, n, startX, iy, z, fog, index, GL_POLYGON);
+ _mesa_write_index_span(ctx, n, startX, iy, z, fog, index,
+ icoverageSpan, GL_POLYGON);
#endif
}
}
const GLfloat *pMax = vMax->win;
const GLfloat dxdy = majDx / majDy;
const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F;
- GLfloat x = vMin->win[0] - (yMin - iyMin) * dxdy;
+ GLfloat x = pMin[0] - (yMin - iyMin) * dxdy;
GLint iy;
for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
GLint ix, left, startX = (GLint) (x + xAdj);
while (coverage > 0.0F) {
/* (cx,cy) = center of fragment */
const GLfloat cx = ix + 0.5F, cy = iy + 0.5F;
+#ifdef DO_INDEX
+ icoverageSpan[ix] = compute_coveragei(pMin, pMid, pMax, ix, iy);
+#else
+ coverageSpan[ix] = coverage;
+#endif
#ifdef DO_Z
z[ix] = (GLdepth) solve_plane(cx, cy, zPlane);
+#endif
+#ifdef DO_FOG
fog[ix] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane);
rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane);
rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane);
- rgba[ix][ACOMP] = (GLchan) (solve_plane_chan(cx, cy, aPlane) * coverage);
+ rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane);
#endif
#ifdef DO_INDEX
- {
- GLint frac = compute_coveragei(pMin, pMax, pMid, ix, iy);
- GLint indx = (GLint) solve_plane(cx, cy, iPlane);
- index[ix] = (indx & ~0xf) | frac;
- }
+ index[ix] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
spec[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane);
coverage = compute_coveragef(pMin, pMax, pMid, ix, iy);
}
+ if (startX <= ix)
+ continue;
+
n = (GLuint) startX - (GLuint) ix;
+
left = ix + 1;
#ifdef DO_MULTITEX
{
}
# ifdef DO_SPEC
_mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left,
- (const GLfloat (*)[MAX_WIDTH]) s,
- (const GLfloat (*)[MAX_WIDTH]) t,
- (const GLfloat (*)[MAX_WIDTH]) u,
- lambda, rgba + left,
- (const GLchan (*)[4]) (spec + left),
- GL_POLYGON);
+ (const GLfloat (*)[MAX_WIDTH]) s,
+ (const GLfloat (*)[MAX_WIDTH]) t,
+ (const GLfloat (*)[MAX_WIDTH]) u,
+ lambda, rgba + left,
+ (const GLchan (*)[4]) (spec + left),
+ coverageSpan + left,
+ GL_POLYGON);
# else
_mesa_write_multitexture_span(ctx, n, left, iy, z + left, fog + left,
- (const GLfloat (*)[MAX_WIDTH]) s,
- (const GLfloat (*)[MAX_WIDTH]) t,
- (const GLfloat (*)[MAX_WIDTH]) u,
- lambda,
- rgba + left, NULL, GL_POLYGON);
+ (const GLfloat (*)[MAX_WIDTH]) s,
+ (const GLfloat (*)[MAX_WIDTH]) t,
+ (const GLfloat (*)[MAX_WIDTH]) u,
+ lambda,
+ rgba + left, NULL, coverageSpan + left,
+ GL_POLYGON);
# endif
#elif defined(DO_TEX)
# ifdef DO_SPEC
_mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left,
- s + left, t + left, u + left,
- lambda + left, rgba + left,
- (const GLchan (*)[4]) (spec + left),
- GL_POLYGON);
+ s + left, t + left, u + left,
+ lambda + left, rgba + left,
+ (const GLchan (*)[4]) (spec + left),
+ coverageSpan + left,
+ GL_POLYGON);
# else
_mesa_write_texture_span(ctx, n, left, iy, z + left, fog + left,
- s + left, t + left,
- u + left, lambda + left,
- rgba + left, NULL, GL_POLYGON);
+ s + left, t + left,
+ u + left, lambda + left,
+ rgba + left, NULL,
+ coverageSpan + left, GL_POLYGON);
# endif
#elif defined(DO_RGBA)
_mesa_write_rgba_span(ctx, n, left, iy, z + left, fog + left,
- rgba + left, GL_POLYGON);
+ rgba + left, coverageSpan + left, GL_POLYGON);
#elif defined(DO_INDEX)
_mesa_write_index_span(ctx, n, left, iy, z + left, fog + left,
- index + left, GL_POLYGON);
+ index + left, icoverageSpan + left, GL_POLYGON);
#endif
}
}
+
+#ifdef DO_RGBA
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+#endif
+#ifdef DO_SPEC
+ UNDEFARRAY(spec);
+#endif
+#if defined(DO_TEX) || defined(DO_MULTITEX)
+ UNDEFARRAY(s);
+ UNDEFARRAY(t);
+ UNDEFARRAY(u);
+ UNDEFARRAY(lambda);
+#endif
}
#undef DO_Z
#endif
+#ifdef DO_FOG
+#undef DO_FOG
+#endif
+
#ifdef DO_RGBA
#undef DO_RGBA
#endif