summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-03-09 16:58:26 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-03-09 16:58:26 +0000
commit1e4731f6443a6efdfc4e425977490ddd5387caa3 (patch)
tree9b830c21e9fddf93a63b983a6570cab643e3e12e
parent7bcada8c278a17e6170e35f1aaf74dd88294ddc5 (diff)
Fix color index mode rendering.
Changed SWvertex's index field to GLfloat and fix a few other bits.
-rw-r--r--src/mesa/swrast/s_aaline.c17
-rw-r--r--src/mesa/swrast/s_aalinetemp.h13
-rw-r--r--src/mesa/swrast/s_linetemp.h6
-rw-r--r--src/mesa/swrast/s_pointtemp.h4
-rw-r--r--src/mesa/swrast/s_triangle.c2
-rw-r--r--src/mesa/swrast/s_tritemp.h9
-rw-r--r--src/mesa/swrast/swrast.h6
7 files changed, 38 insertions, 19 deletions
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index bbdc92b92a..39c51a50f7 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.0.3
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -331,6 +331,19 @@ compute_coveragef(const struct LineInfo *info,
}
+/**
+ * Compute coverage value for color index mode.
+ * XXX this may not be quite correct.
+ * \return coverage in [0,15].
+ */
+static GLfloat
+compute_coveragei(const struct LineInfo *info,
+ GLint winx, GLint winy)
+{
+ return compute_coveragef(info, winx, winy) * 15.0F;
+}
+
+
typedef void (*plot_func)(GLcontext *ctx, struct LineInfo *line,
int ix, int iy);
diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h
index 3a68e528a7..e6ac69d186 100644
--- a/src/mesa/swrast/s_aalinetemp.h
+++ b/src/mesa/swrast/s_aalinetemp.h
@@ -1,9 +1,8 @@
-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -37,7 +36,11 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy)
{
const GLfloat fx = (GLfloat) ix;
const GLfloat fy = (GLfloat) iy;
+#ifdef DO_INDEX
+ const GLfloat coverage = compute_coveragei(line, ix, iy);
+#else
const GLfloat coverage = compute_coveragef(line, ix, iy);
+#endif
const GLuint i = line->span.end;
if (coverage == 0.0)
@@ -191,10 +194,10 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
line.span.arrayMask |= SPAN_INDEX;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
compute_plane(line.x0, line.y0, line.x1, line.y1,
- (GLfloat) v0->index, (GLfloat) v1->index, line.iPlane);
+ v0->index, v1->index, line.iPlane);
}
else {
- constant_plane((GLfloat) v1->index, line.iPlane);
+ constant_plane(v1->index, line.iPlane);
}
#endif
#ifdef DO_TEX
diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h
index 1cb330dbdf..77c985455d 100644
--- a/src/mesa/swrast/s_linetemp.h
+++ b/src/mesa/swrast/s_linetemp.h
@@ -251,11 +251,11 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
#ifdef INTERP_INDEX
interpFlags |= SPAN_INDEX;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- span.index = IntToFixed(vert0->index);
- span.indexStep = IntToFixed(vert1->index - vert0->index) / numPixels;
+ span.index = FloatToFixed(vert0->index);
+ span.indexStep = FloatToFixed(vert1->index - vert0->index) / numPixels;
}
else {
- span.index = IntToFixed(vert1->index);
+ span.index = FloatToFixed(vert1->index);
span.indexStep = 0;
}
#endif
diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h
index 0ca137cd02..22f46f21b0 100644
--- a/src/mesa/swrast/s_pointtemp.h
+++ b/src/mesa/swrast/s_pointtemp.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.0
+ * Version: 6.1
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
@@ -86,7 +86,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
const GLchan specBlue = vert->specular[2];
#endif
#if FLAGS & INDEX
- const GLuint colorIndex = vert->index;
+ const GLuint colorIndex = (GLuint) vert->index; /* XXX round? */
#endif
#if FLAGS & TEXTURE
GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4];
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 01cd754e4a..ab262beabc 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -77,7 +77,7 @@ _swrast_culltriangle( GLcontext *ctx,
#define INTERP_FOG 1
#define SETUP_CODE \
span.interpMask |= SPAN_INDEX; \
- span.index = IntToFixed(v2->index); \
+ span.index = FloatToFixed(v2->index);\
span.indexStep = 0;
#define RENDER_SPAN( span ) _swrast_write_index_span(ctx, &span);
#include "s_tritemp.h"
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 2e25e531cc..3362f3892d 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -192,6 +192,9 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
printf(" %g, %g, %g\n", v1->win[0], v1->win[1], v1->win[2]);
printf(" %g, %g, %g\n", v2->win[0], v2->win[1], v2->win[2]);
*/
+ ASSERT(v0->win[2] >= 0.0);
+ ASSERT(v1->win[2] >= 0.0);
+ ASSERT(v2->win[2] >= 0.0);
/* Compute fixed point x,y coords w/ half-pixel offsets and snapping.
* And find the order of the 3 vertices along the Y axis.
@@ -530,8 +533,8 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
#ifdef INTERP_INDEX
span.interpMask |= SPAN_INDEX;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- GLfloat eMaj_di = (GLfloat) ((GLint) vMax->index - (GLint) vMin->index);
- GLfloat eBot_di = (GLfloat) ((GLint) vMid->index - (GLint) vMin->index);
+ GLfloat eMaj_di = vMax->index - vMin->index;
+ GLfloat eBot_di = vMid->index - vMin->index;
didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di);
didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx);
span.indexStep = SignedFloatToFixed(didx);
@@ -907,7 +910,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
diOuter = SignedFloatToFixed(didy + dxOuter * didx);
}
else {
- iLeft = (GLfixed) (v2->index * FIXED_SCALE);
+ iLeft = FloatToFixed(v2->index);
diOuter = 0;
}
#endif
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 655c74077f..61cc017b85 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -68,7 +68,7 @@ typedef struct {
GLchan color[4];
GLchan specular[4];
GLfloat fog;
- GLuint index;
+ GLfloat index;
GLfloat pointSize;
} SWvertex;