summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-07-26 15:57:49 +0000
committerBrian Paul <[email protected]>2001-07-26 15:57:49 +0000
commitd4cff4f2fa43b22effdd5c339bd48508669a0a42 (patch)
tree151312407d72af59aaa52ca1e00f40c446883113 /src/mesa/swrast
parentbbf6a41d2fd4a3d54e6b5dea50bba24768c01ece (diff)
Applied Klaus Niederkrueger's latest flat-shading clean-ups and some of my own.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_triangle.c130
-rw-r--r--src/mesa/swrast/s_tritemp.h250
2 files changed, 172 insertions, 208 deletions
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 85a153aad09..1781c993d97 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.35 2001/07/23 16:47:53 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.36 2001/07/26 15:57:49 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -671,14 +671,7 @@ static void affine_textured_triangle( GLcontext *ctx,
} \
info.tsize = obj->Image[b]->Height * info.tbytesline;
-#define RENDER_SPAN( span ) \
- if (ctx->Light.ShadeModel == GL_FLAT) { \
- span.red = IntToFixed(v2->color[RCOMP]); \
- span.green = IntToFixed(v2->color[GCOMP]); \
- span.blue = IntToFixed(v2->color[BCOMP]); \
- span.alpha = IntToFixed(v2->color[ACOMP]); \
- } \
- affine_span(ctx, &span, &info);
+#define RENDER_SPAN( span ) affine_span(ctx, &span, &info);
#include "s_tritemp.h"
@@ -970,14 +963,7 @@ static void persp_textured_triangle( GLcontext *ctx,
} \
info.tsize = obj->Image[b]->Height * info.tbytesline;
-#define RENDER_SPAN( span ) \
- if (ctx->Light.ShadeModel == GL_FLAT) { \
- span.red = IntToFixed(v2->color[RCOMP]); \
- span.green = IntToFixed(v2->color[GCOMP]); \
- span.blue = IntToFixed(v2->color[BCOMP]); \
- span.alpha = IntToFixed(v2->color[ACOMP]); \
- } \
- fast_persp_span(ctx, &span, &info);
+#define RENDER_SPAN( span ) fast_persp_span(ctx, &span, &info);
#include "s_tritemp.h"
@@ -1294,20 +1280,12 @@ static void general_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; \
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];\
- const GLboolean flatShade = (ctx->Light.ShadeModel==GL_FLAT); \
- GLfixed rFlat, gFlat, bFlat, aFlat; \
DEFARRAY(GLfloat, sSpan, MAX_WIDTH); /* mac 32k limitation */ \
DEFARRAY(GLfloat, tSpan, MAX_WIDTH); /* mac 32k limitation */ \
DEFARRAY(GLfloat, uSpan, MAX_WIDTH); /* mac 32k limitation */ \
CHECKARRAY(sSpan, return); /* mac 32k limitation */ \
CHECKARRAY(tSpan, return); /* mac 32k limitation */ \
CHECKARRAY(uSpan, return); /* mac 32k limitation */ \
- if (flatShade) { \
- rFlat = ChanToFixed(v2->color[RCOMP]); \
- gFlat = ChanToFixed(v2->color[GCOMP]); \
- bFlat = ChanToFixed(v2->color[BCOMP]); \
- aFlat = ChanToFixed(v2->color[ACOMP]); \
- } \
span.texWidth[0] = (GLfloat) texImage->Width; \
span.texHeight[0] = (GLfloat) texImage->Height; \
(void) fixedToDepthShift;
@@ -1317,12 +1295,6 @@ static void general_textured_triangle( GLcontext *ctx,
GLfloat fogSpan[MAX_WIDTH]; \
GLchan rgbaSpan[MAX_WIDTH][4]; \
GLuint i; \
- if (flatShade) { \
- span.red = rFlat; span.redStep = 0; \
- span.green = gFlat; span.greenStep = 0; \
- span.blue = bFlat; span.blueStep = 0; \
- span.alpha = aFlat; span.alphaStep = 0; \
- } \
/* NOTE: we could just call rasterize_span() here instead */ \
for (i = 0; i < span.count; i++) { \
GLdouble invQ = span.tex[0][3] ? (1.0 / span.tex[0][3]) : 1.0; \
@@ -1380,33 +1352,11 @@ static void general_textured_spec_triangle( GLcontext *ctx,
#define SETUP_CODE \
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; \
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];\
- const GLboolean flatShade = (ctx->Light.ShadeModel == GL_FLAT); \
- GLfixed rFlat, gFlat, bFlat, aFlat; \
- GLfixed srFlat, sgFlat, sbFlat; \
- if (flatShade) { \
- rFlat = ChanToFixed(v2->color[RCOMP]); \
- gFlat = ChanToFixed(v2->color[GCOMP]); \
- bFlat = ChanToFixed(v2->color[BCOMP]); \
- aFlat = ChanToFixed(v2->color[ACOMP]); \
- srFlat = ChanToFixed(v2->specular[RCOMP]); \
- sgFlat = ChanToFixed(v2->specular[GCOMP]); \
- sbFlat = ChanToFixed(v2->specular[BCOMP]); \
- } \
span.texWidth[0] = (GLfloat) texImage->Width; \
span.texHeight[0] = (GLfloat) texImage->Height; \
(void) fixedToDepthShift;
-#define RENDER_SPAN( span ) \
- if (flatShade) { \
- span.red = rFlat; span.redStep = 0; \
- span.green = gFlat; span.greenStep = 0; \
- span.blue = bFlat; span.blueStep = 0; \
- span.alpha = aFlat; span.alphaStep = 0; \
- span.specRed = srFlat; span.specRedStep = 0; \
- span.specGreen = sgFlat; span.specGreenStep = 0; \
- span.specBlue = sbFlat; span.specBlueStep = 0; \
- } \
- rasterize_span(ctx, &span);
+#define RENDER_SPAN( span ) rasterize_span(ctx, &span);
#include "s_tritemp.h"
}
@@ -1435,33 +1385,11 @@ static void lambda_textured_triangle( GLcontext *ctx,
#define SETUP_CODE \
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; \
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];\
- const GLboolean flatShade = (ctx->Light.ShadeModel==GL_FLAT); \
- GLfixed rFlat, gFlat, bFlat, aFlat; \
- GLfixed srFlat, sgFlat, sbFlat; \
- if (flatShade) { \
- rFlat = ChanToFixed(v2->color[RCOMP]); \
- gFlat = ChanToFixed(v2->color[GCOMP]); \
- bFlat = ChanToFixed(v2->color[BCOMP]); \
- aFlat = ChanToFixed(v2->color[ACOMP]); \
- srFlat = ChanToFixed(v2->specular[RCOMP]); \
- sgFlat = ChanToFixed(v2->specular[GCOMP]); \
- sbFlat = ChanToFixed(v2->specular[BCOMP]); \
- } \
span.texWidth[0] = (GLfloat) texImage->Width; \
span.texHeight[0] = (GLfloat) texImage->Height; \
(void) fixedToDepthShift;
-#define RENDER_SPAN( span ) \
- if (flatShade) { \
- span.red = rFlat; span.redStep = 0; \
- span.green = gFlat; span.greenStep = 0; \
- span.blue = bFlat; span.blueStep = 0; \
- span.alpha = aFlat; span.alphaStep = 0; \
- span.specRed = srFlat; span.specRedStep = 0; \
- span.specGreen = sgFlat; span.specGreenStep = 0; \
- span.specBlue = sbFlat; span.specBlueStep = 0; \
- } \
- rasterize_span(ctx, &span);
+#define RENDER_SPAN( span ) rasterize_span(ctx, &span);
#include "s_tritemp.h"
}
@@ -1492,33 +1420,11 @@ static void lambda_textured_spec_triangle( GLcontext *ctx,
#define SETUP_CODE \
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; \
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];\
- const GLboolean flatShade = (ctx->Light.ShadeModel == GL_FLAT); \
- GLfixed rFlat, gFlat, bFlat, aFlat; \
- GLfixed srFlat, sgFlat, sbFlat; \
- if (flatShade) { \
- rFlat = ChanToFixed(v2->color[RCOMP]); \
- gFlat = ChanToFixed(v2->color[GCOMP]); \
- bFlat = ChanToFixed(v2->color[BCOMP]); \
- aFlat = ChanToFixed(v2->color[ACOMP]); \
- srFlat = ChanToFixed(v2->specular[RCOMP]); \
- sgFlat = ChanToFixed(v2->specular[GCOMP]); \
- sbFlat = ChanToFixed(v2->specular[BCOMP]); \
- } \
span.texWidth[0] = (GLfloat) texImage->Width; \
span.texHeight[0] = (GLfloat) texImage->Height; \
(void) fixedToDepthShift;
-#define RENDER_SPAN( span ) \
- if (flatShade) { \
- span.red = rFlat; span.redStep = 0; \
- span.green = gFlat; span.greenStep = 0; \
- span.blue = bFlat; span.blueStep = 0; \
- span.alpha = aFlat; span.alphaStep = 0; \
- span.specRed = srFlat; span.specRedStep = 0; \
- span.specGreen = sgFlat; span.specGreenStep = 0; \
- span.specBlue = sbFlat; span.specBlueStep = 0; \
- } \
- rasterize_span(ctx, &span);
+#define RENDER_SPAN( span ) rasterize_span(ctx, &span);
#include "s_tritemp.h"
}
@@ -1547,19 +1453,7 @@ lambda_multitextured_triangle( GLcontext *ctx,
#define INTERP_LAMBDA 1
#define SETUP_CODE \
- const GLboolean flatShade = (ctx->Light.ShadeModel == GL_FLAT); \
- GLfixed rFlat, gFlat, bFlat, aFlat; \
- GLfixed srFlat, sgFlat, sbFlat; \
GLuint u; \
- if (flatShade) { \
- rFlat = ChanToFixed(v2->color[RCOMP]); \
- gFlat = ChanToFixed(v2->color[GCOMP]); \
- bFlat = ChanToFixed(v2->color[BCOMP]); \
- aFlat = ChanToFixed(v2->color[ACOMP]); \
- srFlat = ChanToFixed(v2->specular[RCOMP]); \
- sgFlat = ChanToFixed(v2->specular[GCOMP]); \
- sbFlat = ChanToFixed(v2->specular[BCOMP]); \
- } \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
if (ctx->Texture.Unit[u]._ReallyEnabled) { \
const struct gl_texture_object *texObj; \
@@ -1572,17 +1466,7 @@ lambda_multitextured_triangle( GLcontext *ctx,
} \
(void) fixedToDepthShift;
-#define RENDER_SPAN( span ) \
- if (flatShade) { \
- span.red = rFlat; span.redStep = 0; \
- span.green = gFlat; span.greenStep = 0; \
- span.blue = bFlat; span.blueStep = 0; \
- span.alpha = aFlat; span.alphaStep = 0; \
- span.specRed = srFlat; span.specRedStep = 0; \
- span.specGreen = sgFlat; span.specGreenStep = 0; \
- span.specBlue = sbFlat; span.specBlueStep = 0; \
- } \
- rasterize_span(ctx, &span);
+#define RENDER_SPAN( span ) rasterize_span(ctx, &span);
#include "s_tritemp.h"
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 0c0c5956eab..9f0ce46a21d 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_tritemp.h,v 1.22 2001/07/14 17:53:04 brianp Exp $ */
+/* $Id: s_tritemp.h,v 1.23 2001/07/26 15:57:49 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,7 +35,7 @@
* INTERP_Z - if defined, interpolate Z values
* INTERP_FOG - if defined, interpolate fog values
* INTERP_RGB - if defined, interpolate RGB values
- * INTERP_ALPHA - if defined, interpolate Alpha values
+ * INTERP_ALPHA - if defined, interpolate Alpha values (req's INTERP_RGB)
* INTERP_SPEC - if defined, interpolate specular RGB values
* INTERP_INDEX - if defined, interpolate color index values
* INTERP_INT_TEX - if defined, interpolate integer ST texcoords
@@ -280,7 +280,7 @@
*/
{
- GLint ltor; /* true if scanning left-to-right */
+ GLint scan_from_left_to_right; /* true if scanning left-to-right */
#ifdef INTERP_Z
GLfloat dzdx, dzdy;
#endif
@@ -331,7 +331,7 @@
SETUP_CODE
#endif
- ltor = (oneOverArea < 0.0F);
+ scan_from_left_to_right = (oneOverArea < 0.0F);
span.activeMask = 0;
@@ -368,116 +368,148 @@
#endif
#ifdef INTERP_RGB
span.activeMask |= SPAN_RGBA;
- {
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dr, eBot_dr;
GLfloat eMaj_dg, eBot_dg;
GLfloat eMaj_db, eBot_db;
- eMaj_dr = (GLint) vMax->color[0] - (GLint) vMin->color[0];
- eBot_dr = (GLint) vMid->color[0] - (GLint) vMin->color[0];
+# ifdef INTERP_ALPHA
+ GLfloat eMaj_da, eBot_da;
+# endif
+ eMaj_dr = (GLint) vMax->color[RCOMP] - (GLint) vMin->color[RCOMP];
+ eBot_dr = (GLint) vMid->color[RCOMP] - (GLint) vMin->color[RCOMP];
drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
span.redStep = SignedFloatToFixed(drdx);
drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
- eMaj_dg = (GLint) vMax->color[1] - (GLint) vMin->color[1];
- eBot_dg = (GLint) vMid->color[1] - (GLint) vMin->color[1];
+ eMaj_dg = (GLint) vMax->color[GCOMP] - (GLint) vMin->color[GCOMP];
+ eBot_dg = (GLint) vMid->color[GCOMP] - (GLint) vMin->color[GCOMP];
dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
span.greenStep = SignedFloatToFixed(dgdx);
dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
- eMaj_db = (GLint) vMax->color[2] - (GLint) vMin->color[2];
- eBot_db = (GLint) vMid->color[2] - (GLint) vMin->color[2];
+ eMaj_db = (GLint) vMax->color[BCOMP] - (GLint) vMin->color[BCOMP];
+ eBot_db = (GLint) vMid->color[BCOMP] - (GLint) vMin->color[BCOMP];
dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
span.blueStep = SignedFloatToFixed(dbdx);
dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
- }
-#endif
-#ifdef INTERP_ALPHA
- {
- GLfloat eMaj_da, eBot_da;
- eMaj_da = (GLint) vMax->color[3] - (GLint) vMin->color[3];
- eBot_da = (GLint) vMid->color[3] - (GLint) vMin->color[3];
+# ifdef INTERP_ALPHA
+ eMaj_da = (GLint) vMax->color[ACOMP] - (GLint) vMin->color[ACOMP];
+ eBot_da = (GLint) vMid->color[ACOMP] - (GLint) vMin->color[ACOMP];
dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
span.alphaStep = SignedFloatToFixed(dadx);
dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
+# endif
+ }
+ else {
+ ASSERT (ctx->Light.ShadeModel == GL_FLAT);
+ drdx = drdy = 0.0F;
+ dgdx = dgdy = 0.0F;
+ dbdx = dbdy = 0.0F;
+ span.redStep = 0;
+ span.greenStep = 0;
+ span.blueStep = 0;
+# ifdef INTERP_ALPHA
+ dadx = dady = 0.0F;
+ span.alphaStep = 0;
+# endif
}
#endif
#ifdef INTERP_FLOAT_RGBA
span.activeMask |= SPAN_RGBA;
- {
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dr, eBot_dr;
GLfloat eMaj_dg, eBot_dg;
GLfloat eMaj_db, eBot_db;
GLfloat eMaj_da, eBot_da;
- eMaj_dr = (GLint) vMax->color[0] - (GLint) vMin->color[0];
- eBot_dr = (GLint) vMid->color[0] - (GLint) vMin->color[0];
+ eMaj_dr = (GLint) vMax->color[RCOMP] - (GLint) vMin->color[RCOMP];
+ eBot_dr = (GLint) vMid->color[RCOMP] - (GLint) vMin->color[RCOMP];
drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
span.redStep = drdx;
drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
- eMaj_dg = (GLint) vMax->color[1] - (GLint) vMin->color[1];
- eBot_dg = (GLint) vMid->color[1] - (GLint) vMin->color[1];
+ eMaj_dg = (GLint) vMax->color[GCOMP] - (GLint) vMin->color[GCOMP];
+ eBot_dg = (GLint) vMid->color[GCOMP] - (GLint) vMin->color[GCOMP];
dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
span.greenStep = dgdx;
dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
- eMaj_db = (GLint) vMax->color[2] - (GLint) vMin->color[2];
- eBot_db = (GLint) vMid->color[2] - (GLint) vMin->color[2];
+ eMaj_db = (GLint) vMax->color[BCOMP] - (GLint) vMin->color[BCOMP];
+ eBot_db = (GLint) vMid->color[BCOMP] - (GLint) vMin->color[BCOMP];
dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
span.blueStep = dbdx;
dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
- eMaj_da = (GLint) vMax->color[3] - (GLint) vMin->color[3];
- eBot_da = (GLint) vMid->color[3] - (GLint) vMin->color[3];
+ eMaj_da = (GLint) vMax->color[ACOMP] - (GLint) vMin->color[ACOMP];
+ eBot_da = (GLint) vMid->color[ACOMP] - (GLint) vMin->color[ACOMP];
dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
span.alphaStep = dadx;
dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
}
+ else {
+ drdx = drdy = span.redStep = 0.0F;
+ dgdx = dgdy = span.greenStep = 0.0F;
+ dbdx = dbdy = span.blueStep = 0.0F;
+ dadx = dady = span.alphaStep = 0.0F;
+ }
#endif
#ifdef INTERP_SPEC
span.activeMask |= SPAN_SPEC;
- {
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dsr, eBot_dsr;
GLfloat eMaj_dsg, eBot_dsg;
GLfloat eMaj_dsb, eBot_dsb;
- eMaj_dsr = (GLint) vMax->specular[0] - (GLint) vMin->specular[0];
- eBot_dsr = (GLint) vMid->specular[0] - (GLint) vMin->specular[0];
+ eMaj_dsr = (GLint) vMax->specular[RCOMP] - (GLint) vMin->specular[RCOMP];
+ eBot_dsr = (GLint) vMid->specular[RCOMP] - (GLint) vMin->specular[RCOMP];
dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr);
span.specRedStep = SignedFloatToFixed(dsrdx);
dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx);
- eMaj_dsg = (GLint) vMax->specular[1] - (GLint) vMin->specular[1];
- eBot_dsg = (GLint) vMid->specular[1] - (GLint) vMin->specular[1];
+ eMaj_dsg = (GLint) vMax->specular[GCOMP] - (GLint) vMin->specular[GCOMP];
+ eBot_dsg = (GLint) vMid->specular[GCOMP] - (GLint) vMin->specular[GCOMP];
dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg);
span.specGreenStep = SignedFloatToFixed(dsgdx);
dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx);
- eMaj_dsb = (GLint) vMax->specular[2] - (GLint) vMin->specular[2];
- eBot_dsb = (GLint) vMid->specular[2] - (GLint) vMin->specular[2];
+ eMaj_dsb = (GLint) vMax->specular[BCOMP] - (GLint) vMin->specular[BCOMP];
+ eBot_dsb = (GLint) vMid->specular[BCOMP] - (GLint) vMin->specular[BCOMP];
dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb);
span.specBlueStep = SignedFloatToFixed(dsbdx);
dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx);
}
+ else {
+ dsrdx = dsrdy = 0.0F;
+ dsgdx = dsgdy = 0.0F;
+ dsbdx = dsbdy = 0.0F;
+ span.specRedStep = 0;
+ span.specGreenStep = 0;
+ span.specBlueStep = 0;
+ }
#endif
#ifdef INTERP_FLOAT_SPEC
span.activeMask |= SPAN_SPEC;
- {
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_dsr, eBot_dsr;
GLfloat eMaj_dsg, eBot_dsg;
GLfloat eMaj_dsb, eBot_dsb;
- eMaj_dsr = (GLint) vMax->specular[0] - (GLint) vMin->specular[0];
- eBot_dsr = (GLint) vMid->specular[0] - (GLint) vMin->specular[0];
+ eMaj_dsr = (GLint) vMax->specular[RCOMP] - (GLint) vMin->specular[RCOMP];
+ eBot_dsr = (GLint) vMid->specular[RCOMP] - (GLint) vMin->specular[RCOMP];
dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr);
span.specRedStep = dsrdx;
dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx);
- eMaj_dsg = (GLint) vMax->specular[1] - (GLint) vMin->specular[1];
- eBot_dsg = (GLint) vMid->specular[1] - (GLint) vMin->specular[1];
+ eMaj_dsg = (GLint) vMax->specular[GCOMP] - (GLint) vMin->specular[GCOMP];
+ eBot_dsg = (GLint) vMid->specular[GCOMP] - (GLint) vMin->specular[GCOMP];
dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg);
span.specGreenStep = dsgdx;
dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx);
- eMaj_dsb = (GLint) vMax->specular[2] - (GLint) vMin->specular[2];
- eBot_dsb = (GLint) vMid->specular[2] - (GLint) vMin->specular[2];
+ eMaj_dsb = (GLint) vMax->specular[BCOMP] - (GLint) vMin->specular[BCOMP];
+ eBot_dsb = (GLint) vMid->specular[BCOMP] - (GLint) vMin->specular[BCOMP];
dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb);
span.specBlueStep = dsbdx;
dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx);
}
+ else {
+ dsrdx = dsrdy = span.specRedStep = 0;
+ dsgdx = dsgdy = span.specGreenStep = 0;
+ dsbdx = dsbdy = span.specBlueStep = 0;
+ }
#endif
#ifdef INTERP_INDEX
span.activeMask |= SPAN_INDEX;
- {
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLfloat eMaj_di, eBot_di;
eMaj_di = (GLint) vMax->index - (GLint) vMin->index;
eBot_di = (GLint) vMid->index - (GLint) vMin->index;
@@ -485,6 +517,10 @@
span.indexStep = SignedFloatToFixed(didx);
didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx);
}
+ else {
+ didx = didy = 0.0F;
+ span.indexStep = 0;
+ }
#endif
#ifdef INTERP_INT_TEX
span.activeMask |= SPAN_INT_TEXTURE;
@@ -696,7 +732,7 @@
GLfixed fb, fdbOuter, fdbInner;
#endif
#ifdef INTERP_ALPHA
- GLfixed fa=0, fdaOuter=0, fdaInner;
+ GLfixed fa, fdaOuter, fdaInner;
#endif
#ifdef INTERP_FLOAT_RGBA
GLfloat fr, fdrOuter, fdrInner;
@@ -745,7 +781,7 @@
if (subTriangle==0) {
/* bottom half */
- if (ltor) {
+ if (scan_from_left_to_right) {
eLeft = &eMaj;
eRight = &eBot;
lines = eRight->lines;
@@ -762,7 +798,7 @@
}
else {
/* top half */
- if (ltor) {
+ if (scan_from_left_to_right) {
eLeft = &eMaj;
eRight = &eTop;
lines = eRight->lines;
@@ -853,54 +889,98 @@
dfogOuter = dfogdy + dxOuter * span.fogStep;
#endif
#ifdef INTERP_RGB
- fr = (GLfixed) (ChanToFixed(vLower->color[0])
- + drdx * adjx + drdy * adjy) + FIXED_HALF;
- fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx);
- fg = (GLfixed) (ChanToFixed(vLower->color[1])
- + dgdx * adjx + dgdy * adjy) + FIXED_HALF;
- fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx);
- fb = (GLfixed) (ChanToFixed(vLower->color[2])
- + dbdx * adjx + dbdy * adjy) + FIXED_HALF;
- fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx);
-#endif
-#ifdef INTERP_ALPHA
- fa = (GLfixed) (ChanToFixed(vLower->color[3])
- + dadx * adjx + dady * adjy) + FIXED_HALF;
- fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx);
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ fr = (GLfixed) (ChanToFixed(vLower->color[RCOMP])
+ + drdx * adjx + drdy * adjy) + FIXED_HALF;
+ fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx);
+ fg = (GLfixed) (ChanToFixed(vLower->color[GCOMP])
+ + dgdx * adjx + dgdy * adjy) + FIXED_HALF;
+ fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx);
+ fb = (GLfixed) (ChanToFixed(vLower->color[BCOMP])
+ + dbdx * adjx + dbdy * adjy) + FIXED_HALF;
+ fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx);
+# ifdef INTERP_ALPHA
+ fa = (GLfixed) (ChanToFixed(vLower->color[ACOMP])
+ + dadx * adjx + dady * adjy) + FIXED_HALF;
+ fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx);
+# endif
+ }
+ else {
+ ASSERT (ctx->Light.ShadeModel == GL_FLAT);
+ fr = ChanToFixed(v2->color[RCOMP]);
+ fg = ChanToFixed(v2->color[GCOMP]);
+ fb = ChanToFixed(v2->color[BCOMP]);
+ fdrOuter = fdgOuter = fdbOuter = 0;
+# ifdef INTERP_ALPHA
+ fa = ChanToFixed(v2->color[ACOMP]);
+ fdaOuter = 0;
+# endif
+ }
#endif
#ifdef INTERP_FLOAT_RGBA
- fr = vLower->color[0] + drdx * adjx + drdy * adjy;
- fdrOuter = drdy + dxOuter * drdx;
- fg = vLower->color[1] + dgdx * adjx + dgdy * adjy;
- fdgOuter = dgdy + dxOuter * dgdx;
- fb = vLower->color[2] + dbdx * adjx + dbdy * adjy;
- fdbOuter = dbdy + dxOuter * dbdx;
- fa = vLower->color[3] + dadx * adjx + dady * adjy;
- fdaOuter = dady + dxOuter * dadx;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ fr = vLower->color[RCOMP] + drdx * adjx + drdy * adjy;
+ fdrOuter = drdy + dxOuter * drdx;
+ fg = vLower->color[GCOMP] + dgdx * adjx + dgdy * adjy;
+ fdgOuter = dgdy + dxOuter * dgdx;
+ fb = vLower->color[BCOMP] + dbdx * adjx + dbdy * adjy;
+ fdbOuter = dbdy + dxOuter * dbdx;
+ fa = vLower->color[ACOMP] + dadx * adjx + dady * adjy;
+ fdaOuter = dady + dxOuter * dadx;
+ }
+ else {
+ fr = v2->color[RCOMP];
+ fg = v2->color[GCOMP];
+ fb = v2->color[BCOMP];
+ fa = v2->color[ACOMP];
+ fdrOuter = fdgOuter = fdbOuter = fdaOuter = 0.0F;
+ }
#endif
#ifdef INTERP_SPEC
- fsr = (GLfixed) (ChanToFixed(vLower->specular[0])
- + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF;
- fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx);
- fsg = (GLfixed) (ChanToFixed(vLower->specular[1])
- + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF;
- fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx);
- fsb = (GLfixed) (ChanToFixed(vLower->specular[2])
- + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF;
- fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx);
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ fsr = (GLfixed) (ChanToFixed(vLower->specular[RCOMP])
+ + dsrdx * adjx + dsrdy * adjy) + FIXED_HALF;
+ fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx);
+ fsg = (GLfixed) (ChanToFixed(vLower->specular[GCOMP])
+ + dsgdx * adjx + dsgdy * adjy) + FIXED_HALF;
+ fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx);
+ fsb = (GLfixed) (ChanToFixed(vLower->specular[BCOMP])
+ + dsbdx * adjx + dsbdy * adjy) + FIXED_HALF;
+ fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx);
+ }
+ else {
+ fsr = ChanToFixed(v2->specular[RCOMP]);
+ fsg = ChanToFixed(v2->specular[GCOMP]);
+ fsb = ChanToFixed(v2->specular[BCOMP]);
+ fdsrOuter = fdsgOuter = fdsbOuter = 0;
+ }
#endif
#ifdef INTERP_FLOAT_SPEC
- fsr = vLower->specular[0] + dsrdx * adjx + dsrdy * adjy;
- fdsrOuter = dsrdy + dxOuter * dsrdx;
- fsg = vLower->specular[1] + dsgdx * adjx + dsgdy * adjy;
- fdsgOuter = dsgdy + dxOuter * dsgdx;
- fsb = vLower->specular[2] + dsbdx * adjx + dsbdy * adjy;
- fdsbOuter = dsbdy + dxOuter * dsbdx;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ fsr = vLower->specular[RCOMP] + dsrdx * adjx + dsrdy * adjy;
+ fdsrOuter = dsrdy + dxOuter * dsrdx;
+ fsg = vLower->specular[GCOMP] + dsgdx * adjx + dsgdy * adjy;
+ fdsgOuter = dsgdy + dxOuter * dsgdx;
+ fsb = vLower->specular[BCOMP] + dsbdx * adjx + dsbdy * adjy;
+ fdsbOuter = dsbdy + dxOuter * dsbdx;
+ }
+ else {
+ fsr = v2->specular[RCOMP];
+ fsg = v2->specular[GCOMP];
+ fsb = v2->specular[BCOMP];
+ fdsrOuter = fdsgOuter = fdsbOuter = 0.0F:
+ }
#endif
#ifdef INTERP_INDEX
- fi = (GLfixed)(vLower->index * FIXED_SCALE
- + didx * adjx + didy * adjy) + FIXED_HALF;
- fdiOuter = SignedFloatToFixed(didy + dxOuter * didx);
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ fi = (GLfixed)(vLower->index * FIXED_SCALE
+ + didx * adjx + didy * adjy) + FIXED_HALF;
+ fdiOuter = SignedFloatToFixed(didy + dxOuter * didx);
+ }
+ else {
+ fi = (GLfixed) (v2->index * FIXED_SCALE);
+ fdiOuter = 0;
+ }
#endif
#ifdef INTERP_INT_TEX
{