summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/allegro/generic.h11
-rw-r--r--src/mesa/drivers/dos/dmesa.c7
-rw-r--r--src/mesa/drivers/ggi/ggimesa.c15
-rw-r--r--src/mesa/drivers/glide/fxdd.c12
-rw-r--r--src/mesa/drivers/svga/svgamesa15.c10
-rw-r--r--src/mesa/drivers/svga/svgamesa16.c12
-rw-r--r--src/mesa/drivers/svga/svgamesa24.c12
-rw-r--r--src/mesa/drivers/svga/svgamesa32.c8
-rw-r--r--src/mesa/drivers/windows/wmesa.c10
-rw-r--r--src/mesa/drivers/windows/wmesa_stereo.c8
-rw-r--r--src/mesa/drivers/x11/xm_dd.c20
-rw-r--r--src/mesa/drivers/x11/xm_span.c51
-rw-r--r--src/mesa/main/attrib.c15
-rw-r--r--src/mesa/main/blend.c14
-rw-r--r--src/mesa/main/buffers.c16
-rw-r--r--src/mesa/main/dd.h10
-rw-r--r--src/mesa/main/get.c26
-rw-r--r--src/mesa/main/mtypes.h29
-rw-r--r--src/mesa/main/texobj.c4
-rw-r--r--src/mesa/main/texstate.c73
-rw-r--r--src/mesa/swrast/s_alpha.c6
-rw-r--r--src/mesa/swrast/s_alphabuf.c30
-rw-r--r--src/mesa/swrast/s_buffers.c32
-rw-r--r--src/mesa/swrast/s_texture.c44
24 files changed, 238 insertions, 237 deletions
diff --git a/src/mesa/drivers/allegro/generic.h b/src/mesa/drivers/allegro/generic.h
index 898a055d62..cbdf5ff2b3 100644
--- a/src/mesa/drivers/allegro/generic.h
+++ b/src/mesa/drivers/allegro/generic.h
@@ -18,13 +18,14 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-static void clear_color_generic(GLcontext *ctx,
- GLubyte red, GLubyte green,
- GLubyte blue, GLubyte alpha)
+static void clear_color_generic(GLcontext *ctx, const GLfloat color[4])
{
AMesaContext context = (AMesaContext)(ctx->DriverCtx);
-
- context->ClearColor = makecol(red, green, blue);
+ GLubyte r, g, b;
+ CLAMPED_FLOAT_TO_UBYTE(r, color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(g, color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(b, color[2]);
+ context->ClearColor = makecol(r, g, b);
}
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 1d430354f6..e45d00f269 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -467,8 +467,13 @@ static void dmesa_choose_tri (GLcontext *ctx)
static void clear_color (GLcontext *ctx, const GLchan color[4])
{
+ const GLubyte col[4];
DMesaContext c = (DMesaContext)ctx->DriverCtx;
- c->ClearColor = vl_mixrgba(color);
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(col[3], color[3]);
+ c->ClearColor = vl_mixrgba(col);
}
diff --git a/src/mesa/drivers/ggi/ggimesa.c b/src/mesa/drivers/ggi/ggimesa.c
index 6fff79648c..94364f49e4 100644
--- a/src/mesa/drivers/ggi/ggimesa.c
+++ b/src/mesa/drivers/ggi/ggimesa.c
@@ -96,17 +96,22 @@ static void gl_ggiSetClearIndex(GLcontext *ctx, GLuint ci)
ggi_ctx->clearcolor = (ggi_pixel)ci;
}
-static void gl_ggiSetClearColor(GLcontext *ctx, const GLchan color[4])
+static void gl_ggiSetClearColor(GLcontext *ctx, const GLfloat color[4])
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
ggi_color rgb;
ggi_pixel col;
-
+ GLubyte byteColor[3];
+
GGIMESADPRINT_CORE("gl_ggiSetClearColor() called\n");
- rgb.r = (uint16)color[0] << SHIFT;
- rgb.g = (uint16)color[1] << SHIFT;
- rgb.b = (uint16)color[2] << SHIFT;
+ CLAMPED_FLOAT_TO_UBYTE(byteColor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(byteColor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(byteColor[2], color[2]);
+
+ rgb.r = (uint16)byteColor[0] << SHIFT;
+ rgb.g = (uint16)byteColor[1] << SHIFT;
+ rgb.b = (uint16)byteColor[2] << SHIFT;
col = ggiMapColor(ggi_ctx->ggi_visual, &rgb);
ggiSetGCForeground(ggi_ctx->ggi_visual, col);
ggi_ctx->clearcolor = col;
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index d4ef05be14..9b98cdd106 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -1,4 +1,4 @@
-/* $Id: fxdd.c,v 1.91 2002/09/27 02:45:38 brianp Exp $ */
+/* $Id: fxdd.c,v 1.92 2002/10/04 19:10:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -125,17 +125,21 @@ fxDDBufferSize(GLframebuffer *buffer, GLuint * width, GLuint * height)
/* Implements glClearColor() */
static void
-fxDDClearColor(GLcontext * ctx, const GLchan color[4])
+fxDDClearColor(GLcontext * ctx, const GLfloat color[4])
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
GLubyte col[4];
if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",
+ fprintf(stderr, "fxmesa: fxDDClearColor(%f,%f,%f,%f)\n",
color[0], color[1], color[2], color[3]);
}
- ASSIGN_4V(col, color[0], color[1], color[2], 255);
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(col[3], color[3]);
+
fxMesa->clearC = FXCOLOR4(col);
fxMesa->clearA = color[3];
}
diff --git a/src/mesa/drivers/svga/svgamesa15.c b/src/mesa/drivers/svga/svgamesa15.c
index 89ff6445be..d14d58d756 100644
--- a/src/mesa/drivers/svga/svgamesa15.c
+++ b/src/mesa/drivers/svga/svgamesa15.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa15.c,v 1.9 2001/02/06 00:03:47 brianp Exp $ */
+/* $Id: svgamesa15.c,v 1.10 2002/10/04 19:10:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -56,9 +56,13 @@ static unsigned long __svga_getpixel15(int x, int y)
return shortBuffer[offset];
}
-void __clear_color15( GLcontext *ctx, const GLchan color[4] )
+void __clear_color15( GLcontext *ctx, const GLfloat color[4] )
{
- SVGAMesa->clear_hicolor=(color[0]>>3)<<10 | (color[1]>>3)<<5 | (color[2]>>3);
+ GLubyte col[3];
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ SVGAMesa->clear_hicolor=(col[0]>>3)<<10 | (col[1]>>3)<<5 | (col[2]>>3);
/* SVGAMesa->clear_hicolor=(red)<<10 | (green)<<5 | (blue);*/
}
diff --git a/src/mesa/drivers/svga/svgamesa16.c b/src/mesa/drivers/svga/svgamesa16.c
index ed36beca24..9078d92709 100644
--- a/src/mesa/drivers/svga/svgamesa16.c
+++ b/src/mesa/drivers/svga/svgamesa16.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa16.c,v 1.9 2001/02/06 00:03:48 brianp Exp $ */
+/* $Id: svgamesa16.c,v 1.10 2002/10/04 19:10:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -59,9 +59,13 @@ static unsigned long __svga_getpixel16(int x, int y)
void __clear_color16( GLcontext *ctx, const GLchan color[4] )
{
- SVGAMesa->clear_hicolor = (color[0] >> 3) << 11 |
- (color[1] >> 2) << 5 |
- (color[2] >> 3);
+ GLubyte col[3];
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ SVGAMesa->clear_hicolor = (col[0] >> 3) << 11 |
+ (col[1] >> 2) << 5 |
+ (col[2] >> 3);
/* SVGAMesa->clear_hicolor=(red)<<11 | (green)<<5 | (blue); */
}
diff --git a/src/mesa/drivers/svga/svgamesa24.c b/src/mesa/drivers/svga/svgamesa24.c
index df1c47be3e..fc56ccb6b3 100644
--- a/src/mesa/drivers/svga/svgamesa24.c
+++ b/src/mesa/drivers/svga/svgamesa24.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa24.c,v 1.10 2001/02/06 00:03:48 brianp Exp $ */
+/* $Id: svgamesa24.c,v 1.11 2002/10/04 19:10:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -81,9 +81,13 @@ static unsigned long __svga_getpixel24(int x, int y)
void __clear_color24( GLcontext *ctx, const GLchan color[4] )
{
- SVGAMesa->clear_red = color[0];
- SVGAMesa->clear_green = color[1];
- SVGAMesa->clear_blue = color[2];
+ GLubyte col[3];
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ SVGAMesa->clear_red = col[0];
+ SVGAMesa->clear_green = col[1];
+ SVGAMesa->clear_blue = col[2];
/* SVGAMesa->clear_truecolor = red<<16 | green<<8 | blue; */
}
diff --git a/src/mesa/drivers/svga/svgamesa32.c b/src/mesa/drivers/svga/svgamesa32.c
index 49c1812b3d..2ef3a191be 100644
--- a/src/mesa/drivers/svga/svgamesa32.c
+++ b/src/mesa/drivers/svga/svgamesa32.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa32.c,v 1.10 2001/02/06 00:03:48 brianp Exp $ */
+/* $Id: svgamesa32.c,v 1.11 2002/10/04 19:10:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -78,7 +78,11 @@ static unsigned long __svga_getpixel32(int x, int y)
void __clear_color32( GLcontext *ctx, const GLchan color[4] )
{
- SVGAMesa->clear_truecolor = (color[0] << 16) | (color[1] << 8) | color[2];
+ GLubyte col[3];
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ SVGAMesa->clear_truecolor = (col[0] << 16) | (col[1] << 8) | col[2];
}
void __clear32( GLcontext *ctx, GLbitfield mask, GLboolean all,
diff --git a/src/mesa/drivers/windows/wmesa.c b/src/mesa/drivers/windows/wmesa.c
index 05029adbfe..8d59cff203 100644
--- a/src/mesa/drivers/windows/wmesa.c
+++ b/src/mesa/drivers/windows/wmesa.c
@@ -1,4 +1,4 @@
-/* $Id: wmesa.c,v 1.37 2002/10/04 15:58:33 kschultz Exp $ */
+/* $Id: wmesa.c,v 1.38 2002/10/04 19:10:11 brianp Exp $ */
/*
* Windows (Win32) device driver for Mesa 3.4
@@ -371,9 +371,13 @@ static void clear_index(GLcontext* ctx, GLuint index)
/*
* Set the color used to clear the color buffer.
*/
-static void clear_color( GLcontext* ctx, const GLchan color[4] )
+static void clear_color( GLcontext* ctx, const GLfloat color[4] )
{
- Current->clearpixel = RGB(color[0], color[1], color[2]);
+ GLubyte col[4];
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ Current->clearpixel = RGB(col[0], col[1], col[2]);
}
diff --git a/src/mesa/drivers/windows/wmesa_stereo.c b/src/mesa/drivers/windows/wmesa_stereo.c
index fea0dc4229..1781b0e439 100644
--- a/src/mesa/drivers/windows/wmesa_stereo.c
+++ b/src/mesa/drivers/windows/wmesa_stereo.c
@@ -153,10 +153,14 @@ static void clear_index(GLcontext* ctx, GLuint index)
/*
* Set the color used to clear the color buffer.
*/
-static void clear_color( GLcontext* ctx, const GLchan color[4] )
+static void clear_color( GLcontext* ctx, const GLfloat color[4] )
{
STARTPROFILE
- Current->clearpixel = RGB(color[0], color[1], color[2]);
+ GLubyte col[4];
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ Current->clearpixel = RGB(col[0], col[1], col[2]);
ENDPROFILE(clear_color)
}
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 3d4792737c..9be4aba69b 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -1,4 +1,4 @@
-/* $Id: xm_dd.c,v 1.36 2002/09/27 02:45:39 brianp Exp $ */
+/* $Id: xm_dd.c,v 1.37 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -27,6 +27,7 @@
#include "glxheader.h"
#include "context.h"
+#include "colormac.h"
#include "depth.h"
#include "drawpix.h"
#include "extensions.h"
@@ -176,15 +177,18 @@ clear_index( GLcontext *ctx, GLuint index )
static void
-clear_color( GLcontext *ctx, const GLchan color[4] )
+clear_color( GLcontext *ctx, const GLfloat color[4] )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- xmesa->clearcolor[0] = color[0];
- xmesa->clearcolor[1] = color[1];
- xmesa->clearcolor[2] = color[2];
- xmesa->clearcolor[3] = color[3];
- xmesa->clearpixel = xmesa_color_to_pixel( xmesa, color[0], color[1],
- color[2], color[3],
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+ xmesa->clearpixel = xmesa_color_to_pixel( xmesa,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2],
+ xmesa->clearcolor[3],
xmesa->xm_visual->undithered_pf );
_glthread_LOCK_MUTEX(_xmesa_lock);
XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc,
diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c
index eed8c91a96..ec51de0d2e 100644
--- a/src/mesa/drivers/x11/xm_span.c
+++ b/src/mesa/drivers/x11/xm_span.c
@@ -1,4 +1,4 @@
-/* $Id: xm_span.c,v 1.15 2002/07/09 01:22:52 brianp Exp $ */
+/* $Id: xm_span.c,v 1.16 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,15 +26,16 @@
/* $XFree86: xc/extras/Mesa/src/X/xm_span.c,v 1.3 2002/02/27 21:07:54 tsi Exp $ */
#include "glxheader.h"
+#include "colormac.h"
#include "context.h"
-#include "drawpix.h"
-#include "mem.h"
-#include "state.h"
#include "depth.h"
+#include "drawpix.h"
+#include "extensions.h"
#include "macros.h"
+#include "mem.h"
#include "mtypes.h"
+#include "state.h"
#include "xmesaP.h"
-#include "extensions.h"
#include "swrast/swrast.h"
@@ -4163,14 +4164,17 @@ static void read_color_pixels( const GLcontext *ctx,
static void
-clear_color_HPCR_ximage( GLcontext *ctx, const GLchan color[4] )
+clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] )
{
int i;
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- COPY_4V(xmesa->clearcolor, color);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
- if (color[0] == 0 && color[1] == 0 && color[2] == 0) {
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
/* black is black */
MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
@@ -4178,24 +4182,33 @@ clear_color_HPCR_ximage( GLcontext *ctx, const GLchan color[4] )
else {
/* build clear pattern */
for (i=0; i<16; i++) {
- xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
- DITHER_HPCR(i, 0, color[0], color[1], color[2]);
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
- DITHER_HPCR(i, 1, color[0], color[1], color[2]);
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
}
}
}
static void
-clear_color_HPCR_pixmap( GLcontext *ctx, const GLchan color[4] )
+clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] )
{
int i;
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- COPY_4V(xmesa->clearcolor, color);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
- if (color[0] == 0 && color[1] == 0 && color[2] == 0) {
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
/* black is black */
for (i=0; i<16; i++) {
XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
@@ -4205,9 +4218,15 @@ clear_color_HPCR_pixmap( GLcontext *ctx, const GLchan color[4] )
else {
for (i=0; i<16; i++) {
XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0,
- DITHER_HPCR(i, 0, color[0], color[1], color[2]));
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1,
- DITHER_HPCR(i, 1, color[0], color[1], color[2]));
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
}
}
/* change tile pixmap content */
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 2ebaaf7341..51787b7505 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.71 2002/09/06 02:56:08 brianp Exp $ */
+/* $Id: attrib.c,v 1.72 2002/10/04 19:10:06 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -739,7 +739,7 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
}
if (ctx->Extensions.SGIX_shadow_ambient) {
_mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX,
- CHAN_TO_FLOAT(obj->ShadowAmbient));
+ obj->ShadowAmbient);
}
}
@@ -809,10 +809,10 @@ _mesa_PopAttrib(void)
const struct gl_colorbuffer_attrib *color;
color = (const struct gl_colorbuffer_attrib *) attr->data;
_mesa_ClearIndex((GLfloat) color->ClearIndex);
- _mesa_ClearColor(CHAN_TO_FLOAT(color->ClearColor[0]),
- CHAN_TO_FLOAT(color->ClearColor[1]),
- CHAN_TO_FLOAT(color->ClearColor[2]),
- CHAN_TO_FLOAT(color->ClearColor[3]));
+ _mesa_ClearColor(color->ClearColor[0],
+ color->ClearColor[1],
+ color->ClearColor[2],
+ color->ClearColor[3]);
_mesa_IndexMask(color->IndexMask);
_mesa_ColorMask((GLboolean) (color->ColorMask[0] != 0),
(GLboolean) (color->ColorMask[1] != 0),
@@ -820,8 +820,7 @@ _mesa_PopAttrib(void)
(GLboolean) (color->ColorMask[3] != 0));
_mesa_DrawBuffer(color->DrawBuffer);
_mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
- _mesa_AlphaFunc(color->AlphaFunc,
- CHAN_TO_FLOAT(color->AlphaRef));
+ _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
_mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);
_mesa_BlendFuncSeparateEXT(color->BlendSrcRGB,
color->BlendDstRGB,
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 97b11872c4..98385e0a70 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -1,4 +1,4 @@
-/* $Id: blend.c,v 1.36 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: blend.c,v 1.37 2002/10/04 19:10:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -346,7 +346,6 @@ void
_mesa_AlphaFunc( GLenum func, GLclampf ref )
{
GET_CURRENT_CONTEXT(ctx);
- GLchan cref;
ASSERT_OUTSIDE_BEGIN_END(ctx);
switch (func) {
@@ -358,18 +357,17 @@ _mesa_AlphaFunc( GLenum func, GLclampf ref )
case GL_NOTEQUAL:
case GL_GEQUAL:
case GL_ALWAYS:
- /* convert float alpha ref to GLchan type */
- UNCLAMPED_FLOAT_TO_CHAN(cref, ref);
+ ref = CLAMP(ref, 0.0F, 1.0F);
- if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == cref)
- return;
+ if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == ref)
+ return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.AlphaFunc = func;
- ctx->Color.AlphaRef = cref;
+ ctx->Color.AlphaRef = ref;
if (ctx->Driver.AlphaFunc)
- ctx->Driver.AlphaFunc(ctx, func, cref);
+ ctx->Driver.AlphaFunc(ctx, func, ref);
return;
default:
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 04a490ada5..20a1c2ee22 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -1,4 +1,4 @@
-/* $Id: buffers.c,v 1.37 2002/07/09 01:22:50 brianp Exp $ */
+/* $Id: buffers.c,v 1.38 2002/10/04 19:10:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -67,20 +67,20 @@ _mesa_ClearIndex( GLfloat c )
void
_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
{
- GLchan tmp[4];
+ GLfloat tmp[4];
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- UNCLAMPED_FLOAT_TO_CHAN(tmp[0], red);
- UNCLAMPED_FLOAT_TO_CHAN(tmp[1], green);
- UNCLAMPED_FLOAT_TO_CHAN(tmp[2], blue);
- UNCLAMPED_FLOAT_TO_CHAN(tmp[3], alpha);
+ tmp[0] = CLAMP(red, 0.0F, 1.0F);
+ tmp[1] = CLAMP(green, 0.0F, 1.0F);
+ tmp[2] = CLAMP(blue, 0.0F, 1.0F);
+ tmp[3] = CLAMP(alpha, 0.0F, 1.0F);
if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
- return;
+ return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
- COPY_CHAN4(ctx->Color.ClearColor, tmp);
+ COPY_4V(ctx->Color.ClearColor, tmp);
if (ctx->Visual.rgbMode && ctx->Driver.ClearColor) {
/* it's OK to call glClearColor in CI mode but it should be a NOP */
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 8f40846975..fc02a15620 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.72 2002/09/27 02:45:37 brianp Exp $ */
+/* $Id: dd.h,v 1.73 2002/10/04 19:10:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -409,22 +409,14 @@ struct dd_function_table {
*** They're ALSO called by the gl_PopAttrib() function!!!
*** May add more functions like these to the device driver in the future.
***/
-#if 1
- void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLchan ref);
-#else
void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLfloat ref);
-#endif
void (*BlendColor)(GLcontext *ctx, const GLfloat color[4]);
void (*BlendEquation)(GLcontext *ctx, GLenum mode);
void (*BlendFunc)(GLcontext *ctx, GLenum sfactor, GLenum dfactor);
void (*BlendFuncSeparate)(GLcontext *ctx,
GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA);
-#if 1
- void (*ClearColor)(GLcontext *ctx, const GLchan color[4]);
-#else
void (*ClearColor)(GLcontext *ctx, const GLfloat color[4]);
-#endif
void (*ClearDepth)(GLcontext *ctx, GLclampd d);
void (*ClearIndex)(GLcontext *ctx, GLuint index);
void (*ClearStencil)(GLcontext *ctx, GLint s);
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 4eee2c9fa7..a952a824b0 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.92 2002/09/27 02:45:37 brianp Exp $ */
+/* $Id: get.c,v 1.93 2002/10/04 19:10:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -173,7 +173,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
*params = ENUM_TO_BOOL(ctx->Color.AlphaFunc);
break;
case GL_ALPHA_TEST_REF:
- *params = FLOAT_TO_BOOL((GLfloat) ctx->Color.AlphaRef / CHAN_MAXF);
+ *params = ctx->Color.AlphaRef ? GL_TRUE : GL_FALSE;
break;
case GL_ATTRIB_STACK_DEPTH:
*params = INT_TO_BOOL(ctx->AttribStackDepth);
@@ -1537,7 +1537,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
*params = ENUM_TO_DOUBLE(ctx->Color.AlphaFunc);
break;
case GL_ALPHA_TEST_REF:
- *params = (GLdouble) ctx->Color.AlphaRef / CHAN_MAXF;
+ *params = (GLdouble) ctx->Color.AlphaRef;
break;
case GL_ATTRIB_STACK_DEPTH:
*params = (GLdouble ) (ctx->AttribStackDepth);
@@ -1602,10 +1602,10 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
*params = 0.0;
break;
case GL_COLOR_CLEAR_VALUE:
- params[0] = (GLdouble) CHAN_TO_FLOAT(ctx->Color.ClearColor[0]);
- params[1] = (GLdouble) CHAN_TO_FLOAT(ctx->Color.ClearColor[1]);
- params[2] = (GLdouble) CHAN_TO_FLOAT(ctx->Color.ClearColor[2]);
- params[3] = (GLdouble) CHAN_TO_FLOAT(ctx->Color.ClearColor[3]);
+ params[0] = (GLdouble) ctx->Color.ClearColor[0];
+ params[1] = (GLdouble) ctx->Color.ClearColor[1];
+ params[2] = (GLdouble) ctx->Color.ClearColor[2];
+ params[3] = (GLdouble) ctx->Color.ClearColor[3];
break;
case GL_COLOR_MATERIAL:
*params = (GLdouble) ctx->Light.ColorMaterialEnabled;
@@ -2898,7 +2898,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
*params = ENUM_TO_FLOAT(ctx->Color.AlphaFunc);
break;
case GL_ALPHA_TEST_REF:
- *params = (GLfloat) ctx->Color.AlphaRef / CHAN_MAXF;
+ *params = (GLfloat) ctx->Color.AlphaRef;
break;
case GL_ATTRIB_STACK_DEPTH:
*params = (GLfloat) (ctx->AttribStackDepth);
@@ -2963,10 +2963,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
*params = 0.0;
break;
case GL_COLOR_CLEAR_VALUE:
- params[0] = CHAN_TO_FLOAT(ctx->Color.ClearColor[0]);
- params[1] = CHAN_TO_FLOAT(ctx->Color.ClearColor[1]);
- params[2] = CHAN_TO_FLOAT(ctx->Color.ClearColor[2]);
- params[3] = CHAN_TO_FLOAT(ctx->Color.ClearColor[3]);
+ params[0] = ctx->Color.ClearColor[0];
+ params[1] = ctx->Color.ClearColor[1];
+ params[2] = ctx->Color.ClearColor[2];
+ params[3] = ctx->Color.ClearColor[3];
break;
case GL_COLOR_MATERIAL:
*params = (GLfloat) ctx->Light.ColorMaterialEnabled;
@@ -4233,7 +4233,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
*params = (GLint) ctx->Color.AlphaEnabled;
break;
case GL_ALPHA_TEST_REF:
- *params = FLOAT_TO_INT( (GLfloat) ctx->Color.AlphaRef / CHAN_MAXF );
+ *params = FLOAT_TO_INT(ctx->Color.AlphaRef);
break;
case GL_ALPHA_TEST_FUNC:
*params = (GLint) ctx->Color.AlphaFunc;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 83a63bfa11..e345c30a4c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.92 2002/10/02 23:24:04 brianp Exp $ */
+/* $Id: mtypes.h,v 1.93 2002/10/04 19:10:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -311,11 +311,7 @@ struct gl_accum_attrib {
struct gl_colorbuffer_attrib {
GLuint ClearIndex; /* Index to use for glClear */
-#if 1
- GLchan ClearColor[4]; /* Color to use for glClear */
-#else
GLclampf ClearColor[4]; /* Color to use for glClear */
-#endif
GLuint IndexMask; /* Color index write mask */
GLubyte ColorMask[4]; /* Each flag is 0xff or 0x0 */
@@ -327,11 +323,7 @@ struct gl_colorbuffer_attrib {
/* alpha testing */
GLboolean AlphaEnabled; /* Alpha test enabled flag */
GLenum AlphaFunc; /* Alpha test function */
-#if 1
- GLchan AlphaRef; /* Alpha ref value as GLchan */
-#else
GLclampf AlphaRef;
-#endif
/* blending */
GLboolean BlendEnabled; /* Blending enabled flag */
@@ -870,11 +862,8 @@ struct gl_texture_object {
GLuint Name; /* an unsigned integer */
GLenum Target; /* GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
GLfloat Priority; /* in [0,1] */
- GLfloat BorderValues[4]; /* unclamped */
-#if 1
- /* omit someday */
- GLchan BorderColor[4]; /* clamped, as GLchan */
-#endif
+ GLfloat BorderColor[4]; /* unclamped */
+ GLchan _BorderChan[4]; /* clamped, as GLchan */
GLenum WrapS; /* Wrap modes are: GL_CLAMP, REPEAT */
GLenum WrapT; /* GL_CLAMP_TO_EDGE, and */
GLenum WrapR; /* GL_CLAMP_TO_BORDER_ARB */
@@ -887,11 +876,7 @@ struct gl_texture_object {
GLfloat MaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
GLboolean CompareFlag; /* GL_SGIX_shadow */
GLenum CompareOperator; /* GL_SGIX_shadow */
-#if 1
- GLchan ShadowAmbient; /* GL_SGIX/ARB_shadow_ambient */
-#else
GLfloat ShadowAmbient;
-#endif
GLenum CompareMode; /* GL_ARB_shadow */
GLenum CompareFunc; /* GL_ARB_shadow */
GLenum DepthMode; /* GL_ARB_depth_texture */
@@ -1329,17 +1314,11 @@ struct gl_frame_buffer {
GLaccum *Accum; /* array [4*Width*Height] of GLaccum values */
/* Software alpha planes */
-#if 1
- GLchan *FrontLeftAlpha; /* array [Width*Height] of GLubyte */
- GLchan *BackLeftAlpha; /* array [Width*Height] of GLubyte */
- GLchan *FrontRightAlpha; /* array [Width*Height] of GLubyte */
- GLchan *BackRightAlpha; /* array [Width*Height] of GLubyte */
-#else
GLvoid *FrontLeftAlpha; /* array [Width*Height] of GLubyte */
GLvoid *BackLeftAlpha; /* array [Width*Height] of GLubyte */
GLvoid *FrontRightAlpha; /* array [Width*Height] of GLubyte */
GLvoid *BackRightAlpha; /* array [Width*Height] of GLubyte */
-#endif
+
/* Drawing bounds: intersection of window size and scissor box */
GLint _Xmin, _Ymin; /* inclusive */
GLint _Xmax, _Ymax; /* exclusive */
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 909492cd49..c27d7a6a5f 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.57 2002/06/29 19:48:16 brianp Exp $ */
+/* $Id: texobj.c,v 1.58 2002/10/04 19:10:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -99,7 +99,7 @@ _mesa_alloc_texture_object( struct gl_shared_state *shared,
obj->CompareMode = GL_LUMINANCE; /* ARB_shadow */
obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */
obj->DepthMode = GL_LUMINANCE; /* ARB_depth_texture */
- obj->ShadowAmbient = 0; /* ARB/SGIX_shadow_ambient */
+ obj->ShadowAmbient = 0.0F; /* ARB/SGIX_shadow_ambient */
_mesa_init_colortable(&obj->Palette);
/* insert into linked list */
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 1287bdf2bf..e5c82e1514 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.79 2002/09/27 02:45:38 brianp Exp $ */
+/* $Id: texstate.c,v 1.80 2002/10/04 19:10:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1148,28 +1148,16 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
_mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
}
break;
-#if 0 /* someday */
- case GL_TEXTUER_BORDER_VALUES_NV:
- /* don't clamp */
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- COPY_4V(texObj->BorderValues, params);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[0], params[0]);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[1], params[1]);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[2], params[2]);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[3], params[3]);
- break;
-#endif
case GL_TEXTURE_BORDER_COLOR:
- /* clamp */
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->BorderValues[0] = CLAMP(params[0], 0.0F, 1.0F);
- texObj->BorderValues[1] = CLAMP(params[1], 0.0F, 1.0F);
- texObj->BorderValues[2] = CLAMP(params[2], 0.0F, 1.0F);
- texObj->BorderValues[3] = CLAMP(params[3], 0.0F, 1.0F);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[0], texObj->BorderValues[0]);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[1], texObj->BorderValues[1]);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[2], texObj->BorderValues[2]);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->BorderColor[3], texObj->BorderValues[3]);
+ texObj->BorderColor[RCOMP] = params[0];
+ texObj->BorderColor[GCOMP] = params[1];
+ texObj->BorderColor[BCOMP] = params[2];
+ texObj->BorderColor[ACOMP] = params[3];
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[RCOMP], params[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[GCOMP], params[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[BCOMP], params[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[ACOMP], params[3]);
break;
case GL_TEXTURE_MIN_LOD:
if (texObj->MinLod == params[0])
@@ -1255,7 +1243,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
if (ctx->Extensions.SGIX_shadow_ambient) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- UNCLAMPED_FLOAT_TO_CHAN(texObj->ShadowAmbient, params[0]);
+ texObj->ShadowAmbient = CLAMP(params[0], 0.0F, 1.0F);
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -1623,21 +1611,11 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
case GL_TEXTURE_WRAP_R_EXT:
*params = ENUM_TO_FLOAT(obj->WrapR);
return;
-#if 0 /* someday */
- case GL_TEXTURE_BORDER_VALUES_NV:
- /* unclamped */
- params[0] = obj->BorderValues[0];
- params[1] = obj->BorderValues[1];
- params[2] = obj->BorderValues[2];
- params[3] = obj->BorderValues[3];
- return;
-#endif
case GL_TEXTURE_BORDER_COLOR:
- /* clamped */
- params[0] = obj->BorderColor[0] / CHAN_MAXF;
- params[1] = obj->BorderColor[1] / CHAN_MAXF;
- params[2] = obj->BorderColor[2] / CHAN_MAXF;
- params[3] = obj->BorderColor[3] / CHAN_MAXF;
+ params[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F);
+ params[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F);
+ params[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F);
+ params[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F);
return;
case GL_TEXTURE_RESIDENT:
{
@@ -1684,7 +1662,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
break;
case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
if (ctx->Extensions.SGIX_shadow_ambient) {
- *params = CHAN_TO_FLOAT(obj->ShadowAmbient);
+ *params = obj->ShadowAmbient;
return;
}
break;
@@ -1750,23 +1728,13 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
case GL_TEXTURE_WRAP_R_EXT:
*params = (GLint) obj->WrapR;
return;
-#if 0 /* someday */
- case GL_TEXTURE_BORDER_VALUES_NV:
- /* unclamped */
- params[0] = FLOAT_TO_INT(obj->BorderValues[0]);
- params[1] = FLOAT_TO_INT(obj->BorderValues[1]);
- params[2] = FLOAT_TO_INT(obj->BorderValues[2]);
- params[3] = FLOAT_TO_INT(obj->BorderValues[3]);
- return;
-#endif
case GL_TEXTURE_BORDER_COLOR:
- /* clamped */
{
GLfloat b[4];
- b[0] = CLAMP(obj->BorderValues[0], 0.0F, 1.0F);
- b[1] = CLAMP(obj->BorderValues[1], 0.0F, 1.0F);
- b[2] = CLAMP(obj->BorderValues[2], 0.0F, 1.0F);
- b[3] = CLAMP(obj->BorderValues[3], 0.0F, 1.0F);
+ b[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F);
+ b[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F);
+ b[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F);
+ b[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F);
params[0] = FLOAT_TO_INT(b[0]);
params[1] = FLOAT_TO_INT(b[1]);
params[2] = FLOAT_TO_INT(b[2]);
@@ -1818,8 +1786,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;
case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
if (ctx->Extensions.SGIX_shadow_ambient) {
- GLfloat a = CHAN_TO_FLOAT(obj->ShadowAmbient);
- *params = (GLint) FLOAT_TO_INT(a);
+ *params = (GLint) FLOAT_TO_INT(obj->ShadowAmbient);
return;
}
break;
diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c
index 79e27d5755..5cbfe8617a 100644
--- a/src/mesa/swrast/s_alpha.c
+++ b/src/mesa/swrast/s_alpha.c
@@ -1,4 +1,4 @@
-/* $Id: s_alpha.c,v 1.11 2002/08/07 00:45:07 brianp Exp $ */
+/* $Id: s_alpha.c,v 1.12 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -50,11 +50,13 @@ GLint
_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span )
{
const GLchan (*rgba)[4] = (const GLchan (*)[4]) span->array->rgba;
- const GLchan ref = ctx->Color.AlphaRef;
+ GLchan ref;
const GLuint n = span->end;
GLubyte *mask = span->array->mask;
GLuint i;
+ CLAMPED_FLOAT_TO_CHAN(ref, ctx->Color.AlphaRef);
+
if (span->arrayMask & SPAN_RGBA) {
/* Use the array values */
switch (ctx->Color.AlphaFunc) {
diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c
index b303c0fc76..2eab878a23 100644
--- a/src/mesa/swrast/s_alphabuf.c
+++ b/src/mesa/swrast/s_alphabuf.c
@@ -1,8 +1,8 @@
-/* $Id: s_alphabuf.c,v 1.11 2002/07/09 01:22:52 brianp Exp $ */
+/* $Id: s_alphabuf.c,v 1.12 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.0.2
+ * Version: 4.1
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
@@ -51,7 +51,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->FrontLeftAlpha) {
MESA_PBUFFER_FREE( buffer->FrontLeftAlpha );
}
- buffer->FrontLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->FrontLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->FrontLeftAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -62,7 +62,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->BackLeftAlpha) {
MESA_PBUFFER_FREE( buffer->BackLeftAlpha );
}
- buffer->BackLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->BackLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->BackLeftAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -74,7 +74,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->FrontRightAlpha) {
MESA_PBUFFER_FREE( buffer->FrontRightAlpha );
}
- buffer->FrontRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->FrontRightAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->FrontRightAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -85,7 +85,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->BackRightAlpha) {
MESA_PBUFFER_FREE( buffer->BackRightAlpha );
}
- buffer->BackRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->BackRightAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->BackRightAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -113,16 +113,16 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
if (bufferBit & ctx->Color._DrawDestMask) {
GLchan *buffer;
if (bufferBit == FRONT_LEFT_BIT) {
- buffer = ctx->DrawBuffer->FrontLeftAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
}
else if (bufferBit == FRONT_RIGHT_BIT) {
- buffer = ctx->DrawBuffer->FrontRightAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
}
else if (bufferBit == BACK_LEFT_BIT) {
- buffer = ctx->DrawBuffer->BackLeftAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
}
else {
- buffer = ctx->DrawBuffer->BackRightAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->BackRightAlpha;
}
if (ctx->Scissor.Enabled) {
@@ -173,20 +173,20 @@ GLchan *get_alpha_buffer( GLcontext *ctx )
{
switch (ctx->Color._DriverDrawBuffer) {
case GL_FRONT_LEFT:
- return ctx->DrawBuffer->FrontLeftAlpha;
+ return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
break;
case GL_BACK_LEFT:
- return ctx->DrawBuffer->BackLeftAlpha;
+ return (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
break;
case GL_FRONT_RIGHT:
- return ctx->DrawBuffer->FrontRightAlpha;
+ return (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
break;
case GL_BACK_RIGHT:
- return ctx->DrawBuffer->BackRightAlpha;
+ return (GLchan *) ctx->DrawBuffer->BackRightAlpha;
break;
default:
_mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()");
- return ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
+ return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
}
}
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c
index dcfa26f5e2..1b07eb0bef 100644
--- a/src/mesa/swrast/s_buffers.c
+++ b/src/mesa/swrast/s_buffers.c
@@ -1,4 +1,4 @@
-/* $Id: s_buffers.c,v 1.12 2002/07/09 01:22:52 brianp Exp $ */
+/* $Id: s_buffers.c,v 1.13 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,6 +26,7 @@
#include "glheader.h"
+#include "colormac.h"
#include "macros.h"
#include "mem.h"
@@ -53,19 +54,17 @@ clear_color_buffer_with_masking( GLcontext *ctx )
if (ctx->Visual.rgbMode) {
/* RGBA mode */
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
- const GLchan a = ctx->Color.ClearColor[3];
+ GLchan clearColor[4];
GLint i;
+ CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
for (i = 0; i < height; i++) {
GLchan rgba[MAX_WIDTH][4];
GLint j;
for (j = 0; j < width; j++) {
- rgba[j][RCOMP] = r;
- rgba[j][GCOMP] = g;
- rgba[j][BCOMP] = b;
- rgba[j][ACOMP] = a;
+ COPY_CHAN4(rgba[j], clearColor);
}
_mesa_mask_rgba_array( ctx, width, x, y + i, rgba );
(*swrast->Driver.WriteRGBASpan)( ctx, width, x, y + i,
@@ -104,20 +103,19 @@ clear_color_buffer(GLcontext *ctx)
if (ctx->Visual.rgbMode) {
/* RGBA mode */
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
- const GLchan a = ctx->Color.ClearColor[3];
+ GLchan clearColor[4];
GLchan span[MAX_WIDTH][4];
GLint i;
+ CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
+
ASSERT(*((GLuint *) &ctx->Color.ColorMask) == 0xffffffff);
for (i = 0; i < width; i++) {
- span[i][RCOMP] = r;
- span[i][GCOMP] = g;
- span[i][BCOMP] = b;
- span[i][ACOMP] = a;
+ COPY_CHAN4(span[i], clearColor);
}
for (i = 0; i < height; i++) {
(*swrast->Driver.WriteRGBASpan)( ctx, width, x, y + i,
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index b8428c9a66..d816104638 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.67 2002/09/23 16:37:15 brianp Exp $ */
+/* $Id: s_texture.c,v 1.68 2002/10/04 19:10:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -417,7 +417,7 @@ sample_1d_nearest(GLcontext *ctx,
if (i < 0 || i >= (GLint) img->Width) {
/* Need this test for GL_CLAMP_TO_BORDER_ARB mode */
- COPY_CHAN4(rgba, tObj->BorderColor);
+ COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i, 0, 0, (GLvoid *) rgba);
@@ -469,7 +469,7 @@ sample_1d_linear(GLcontext *ctx,
GLchan t0[4], t1[4]; /* texels */
if (useBorderColor & I0BIT) {
- COPY_CHAN4(t0, tObj->BorderColor);
+ COPY_CHAN4(t0, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, 0, 0, (GLvoid *) t0);
@@ -478,7 +478,7 @@ sample_1d_linear(GLcontext *ctx,
}
}
if (useBorderColor & I1BIT) {
- COPY_CHAN4(t1, tObj->BorderColor);
+ COPY_CHAN4(t1, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, 0, 0, (GLvoid *) t1);
@@ -746,7 +746,7 @@ sample_2d_nearest(GLcontext *ctx,
if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER_ARB mode */
- COPY_CHAN4(rgba, tObj->BorderColor);
+ COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i, j, 0, (GLvoid *) rgba);
@@ -814,7 +814,7 @@ sample_2d_linear(GLcontext *ctx,
GLchan t11[4];
if (useBorderColor & (I0BIT | J0BIT)) {
- COPY_CHAN4(t00, tObj->BorderColor);
+ COPY_CHAN4(t00, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j0, 0, (GLvoid *) t00);
@@ -823,7 +823,7 @@ sample_2d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J0BIT)) {
- COPY_CHAN4(t10, tObj->BorderColor);
+ COPY_CHAN4(t10, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j0, 0, (GLvoid *) t10);
@@ -832,7 +832,7 @@ sample_2d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I0BIT | J1BIT)) {
- COPY_CHAN4(t01, tObj->BorderColor);
+ COPY_CHAN4(t01, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j1, 0, (GLvoid *) t01);
@@ -841,7 +841,7 @@ sample_2d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J1BIT)) {
- COPY_CHAN4(t11, tObj->BorderColor);
+ COPY_CHAN4(t11, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j1, 0, (GLvoid *) t11);
@@ -1334,7 +1334,7 @@ sample_3d_nearest(GLcontext *ctx,
j < 0 || j >= (GLint) img->Height ||
k < 0 || k >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER_ARB mode */
- COPY_CHAN4(rgba, tObj->BorderColor);
+ COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i, j, k, (GLvoid *) rgba);
@@ -1417,7 +1417,7 @@ sample_3d_linear(GLcontext *ctx,
GLchan t100[4], t110[4], t101[4], t111[4];
if (useBorderColor & (I0BIT | J0BIT | K0BIT)) {
- COPY_CHAN4(t000, tObj->BorderColor);
+ COPY_CHAN4(t000, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j0, k0, (GLvoid *) t000);
@@ -1426,7 +1426,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
- COPY_CHAN4(t100, tObj->BorderColor);
+ COPY_CHAN4(t100, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j0, k0, (GLvoid *) t100);
@@ -1435,7 +1435,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
- COPY_CHAN4(t010, tObj->BorderColor);
+ COPY_CHAN4(t010, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j1, k0, (GLvoid *) t010);
@@ -1444,7 +1444,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
- COPY_CHAN4(t110, tObj->BorderColor);
+ COPY_CHAN4(t110, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j1, k0, (GLvoid *) t110);
@@ -1454,7 +1454,7 @@ sample_3d_linear(GLcontext *ctx,
}
if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
- COPY_CHAN4(t001, tObj->BorderColor);
+ COPY_CHAN4(t001, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j0, k1, (GLvoid *) t001);
@@ -1463,7 +1463,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
- COPY_CHAN4(t101, tObj->BorderColor);
+ COPY_CHAN4(t101, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j0, k1, (GLvoid *) t101);
@@ -1472,7 +1472,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
- COPY_CHAN4(t011, tObj->BorderColor);
+ COPY_CHAN4(t011, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j1, k1, (GLvoid *) t011);
@@ -1481,7 +1481,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
- COPY_CHAN4(t111, tObj->BorderColor);
+ COPY_CHAN4(t111, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j1, k1, (GLvoid *) t111);
@@ -2212,7 +2212,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
const struct gl_texture_image *texImage = tObj->Image[baseLevel];
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
- const GLchan ambient = tObj->ShadowAmbient;
+ const GLchan ambient;
GLenum function;
GLchan result;
@@ -2223,6 +2223,8 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
tObj->Target == GL_TEXTURE_2D ||
tObj->Target == GL_TEXTURE_RECTANGLE_NV);
+ UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient);
+
/* XXXX if tObj->MinFilter != tObj->MagFilter, we're ignoring lambda */
/* XXX this could be precomputed and saved in the texture object */
@@ -2501,7 +2503,7 @@ sample_depth_texture2(const GLcontext *ctx,
const struct gl_texture_image *texImage = texObj->Image[baseLevel];
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
- const GLchan ambient = texObj->ShadowAmbient;
+ GLchan ambient;
GLboolean lequal, gequal;
if (texObj->Target != GL_TEXTURE_2D) {
@@ -2523,6 +2525,8 @@ sample_depth_texture2(const GLcontext *ctx,
return;
}
+ UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient);
+
if (texObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) {
lequal = GL_TRUE;
gequal = GL_FALSE;