From 1e4731f6443a6efdfc4e425977490ddd5387caa3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 9 Mar 2004 16:58:26 +0000 Subject: [PATCH] Fix color index mode rendering. Changed SWvertex's index field to GLfloat and fix a few other bits. --- src/mesa/swrast/s_aaline.c | 17 +++++++++++++++-- src/mesa/swrast/s_aalinetemp.h | 13 ++++++++----- src/mesa/swrast/s_linetemp.h | 6 +++--- src/mesa/swrast/s_pointtemp.h | 4 ++-- src/mesa/swrast/s_triangle.c | 2 +- src/mesa/swrast/s_tritemp.h | 9 ++++++--- src/mesa/swrast/swrast.h | 6 +++--- 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c index bbdc92b92a5..39c51a50f71 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 3a68e528a73..e6ac69d1860 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 1cb330dbdf5..77c985455dc 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 0ca137cd029..22f46f21b0d 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 01cd754e4ab..ab262beabc1 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 2e25e531cc8..3362f3892d1 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 655c74077f1..61cc017b85d 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; -- 2.30.2