From: Brian Paul Date: Tue, 2 Jan 2001 22:02:51 +0000 (+0000) Subject: Removed fixed.h (GLfixed now in mtypes.h, fixed-pt macros in mmath.h) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3041d05bbcccfddba01a1eeaba01e5da0e1e99af;p=mesa.git Removed fixed.h (GLfixed now in mtypes.h, fixed-pt macros in mmath.h) Clean-up of color conversion macros. New mmath.h macros (IROUND, IFLOOR, ICEIL, FRAC) used in various places. --- diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 0f1ace3ee0d..306e0be3b96 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -63,6 +63,9 @@ #include "tnl/t_pipeline.h" + +float gl_ubyte_to_float_255_color_tab[256]; + /* These lookup table are used to extract RGB values in [0,255] from * 16-bit pixel values. */ @@ -667,8 +670,13 @@ static const struct gl_pipeline_stage *fx_pipeline[] = { int fxDDInitFxMesaContext( fxMesaContext fxMesa ) { + int i; static int firsttime = 1; + for (i = 0 ; i < 256 ; i++) { + gl_ubyte_to_float_255_color_tab[i] = (float) i; + } + if (firsttime) { fxDDSetupInit(); fxDDTrifuncInit(); diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index 2f62133221f..3e3147e3632 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -87,6 +87,16 @@ #define T1COORD GR_VERTEX_TOW_TMU1_OFFSET +extern float gl_ubyte_to_float_255_color_tab[256]; +#define UBYTE_COLOR_TO_FLOAT_255_COLOR(c) gl_ubyte_to_float_255_color_tab[c] +#define UBYTE_COLOR_TO_FLOAT_255_COLOR2(f,c) \ + (*(int *)&(f)) = ((int *)gl_ubyte_to_float_255_color_tab)[c] + + +#define LINTERP(T, A, B) ((A) + (T) * ((B) - (A))) + + + /* Should have size == 16 * sizeof(float). */ typedef union { diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 1349ceecb5a..6148100e222 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.35 2000/12/26 05:09:30 keithw Exp $ */ +/* $Id: osmesa.c,v 1.36 2001/01/02 22:02:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -45,6 +45,7 @@ #include "macros.h" #include "mem.h" #include "matrix.h" +#include "mmath.h" #include "mtypes.h" #include "extensions.h" #include "swrast/swrast.h" diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c index a759d376bb4..c76de401c88 100644 --- a/src/mesa/drivers/x11/xm_line.c +++ b/src/mesa/drivers/x11/xm_line.c @@ -1,4 +1,4 @@ -/* $Id: xm_line.c,v 1.13 2000/12/13 16:24:40 brianp Exp $ */ +/* $Id: xm_line.c,v 1.14 2001/01/02 22:02:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -35,6 +35,7 @@ #include "glxheader.h" #include "depth.h" #include "macros.h" +#include "mmath.h" #include "mtypes.h" #include "xmesaP.h" diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index 09f1f7ce1c1..dbd252c50c6 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -1,4 +1,4 @@ -/* $Id: xm_tri.c,v 1.14 2000/12/13 16:24:39 brianp Exp $ */ +/* $Id: xm_tri.c,v 1.15 2001/01/02 22:02:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -35,6 +35,7 @@ #include "glxheader.h" #include "depth.h" #include "macros.h" +#include "mmath.h" #include "mtypes.h" #include "xmesaP.h" diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c index e8b642741f9..79400252257 100644 --- a/src/mesa/main/api_loopback.c +++ b/src/mesa/main/api_loopback.c @@ -1,4 +1,4 @@ -/* $Id: api_loopback.c,v 1.4 2000/12/26 05:09:27 keithw Exp $ */ +/* $Id: api_loopback.c,v 1.5 2001/01/02 22:02:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -88,9 +88,9 @@ loopback_Color3d( GLdouble red, GLdouble green, GLdouble blue ) GLfloat r = red; GLfloat g = green; GLfloat b = blue; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], r); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], g); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); col[3] = 255; COLORUBV( col ); } @@ -158,10 +158,10 @@ loopback_Color4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) GLfloat g = green; GLfloat b = blue; GLfloat a = alpha; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], r); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], g); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b); - FLOAT_COLOR_TO_UBYTE_COLOR(col[3], a); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); + UNCLAMPED_FLOAT_TO_UBYTE(col[3], a); COLORUBV( col ); } @@ -1178,9 +1178,9 @@ loopback_SecondaryColor3dEXT( GLdouble red, GLdouble green, GLdouble blue ) GLfloat r = red; GLfloat g = green; GLfloat b = blue; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], r); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], g); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); SECONDARYCOLORUB( col[0], col[1], col[2] ); } @@ -1219,9 +1219,10 @@ loopback_SecondaryColor3usEXT( GLushort red, GLushort green, GLushort blue ) static void loopback_SecondaryColor3bvEXT( const GLbyte *v ) { - SECONDARYCOLORUB(BYTE_TO_UBYTE(v[0]), - BYTE_TO_UBYTE(v[1]), - BYTE_TO_UBYTE(v[2])); + const GLfloat r = BYTE_TO_FLOAT(v[0]); + const GLfloat g = BYTE_TO_FLOAT(v[1]); + const GLfloat b = BYTE_TO_FLOAT(v[2]); + SECONDARYCOLORF(r, g, b); } static void @@ -1231,9 +1232,9 @@ loopback_SecondaryColor3dvEXT( const GLdouble *v ) GLfloat r = v[0]; GLfloat g = v[1]; GLfloat b = v[2]; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], r); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], g); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); SECONDARYCOLORUB( col[0], col[1], col[2] ); } diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index bd5c3cd3ea0..e8298186f55 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -151,17 +151,19 @@ void _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) { GET_CURRENT_CONTEXT(ctx); GLubyte *color = ctx->Current.Color; - FLOAT_COLOR_TO_UBYTE_COLOR(color[0], a); - FLOAT_COLOR_TO_UBYTE_COLOR(color[1], b); - FLOAT_COLOR_TO_UBYTE_COLOR(color[2], c); - FLOAT_COLOR_TO_UBYTE_COLOR(color[3], d); + UNCLAMPED_FLOAT_TO_UBYTE(color[0], a); + UNCLAMPED_FLOAT_TO_UBYTE(color[1], b); + UNCLAMPED_FLOAT_TO_UBYTE(color[2], c); + UNCLAMPED_FLOAT_TO_UBYTE(color[3], d); } void _mesa_noop_Color4fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLubyte *color = ctx->Current.Color; - FLOAT_RGBA_TO_CHAN_RGBA( color, v ); + UNCLAMPED_FLOAT_TO_CHAN(color[0], v[0]); + UNCLAMPED_FLOAT_TO_CHAN(color[1], v[1]); + UNCLAMPED_FLOAT_TO_CHAN(color[2], v[2]); } void _mesa_noop_Color3ub( GLubyte a, GLubyte b, GLubyte c ) @@ -188,9 +190,9 @@ void _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c ) { GET_CURRENT_CONTEXT(ctx); GLubyte *color = ctx->Current.Color; - FLOAT_COLOR_TO_UBYTE_COLOR(color[0], a); - FLOAT_COLOR_TO_UBYTE_COLOR(color[1], b); - FLOAT_COLOR_TO_UBYTE_COLOR(color[2], c); + UNCLAMPED_FLOAT_TO_UBYTE(color[0], a); + UNCLAMPED_FLOAT_TO_UBYTE(color[1], b); + UNCLAMPED_FLOAT_TO_UBYTE(color[2], c); color[3] = 255; } @@ -198,7 +200,9 @@ void _mesa_noop_Color3fv( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLubyte *color = ctx->Current.Color; - FLOAT_RGB_TO_CHAN_RGB( color, v ); + UNCLAMPED_FLOAT_TO_CHAN(color[0], v[0]); + UNCLAMPED_FLOAT_TO_CHAN(color[1], v[1]); + UNCLAMPED_FLOAT_TO_CHAN(color[2], v[2]); color[3] = 255; } @@ -363,9 +367,9 @@ void _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c ) { GET_CURRENT_CONTEXT(ctx); GLubyte *color = ctx->Current.SecondaryColor; - FLOAT_COLOR_TO_UBYTE_COLOR(color[0], a); - FLOAT_COLOR_TO_UBYTE_COLOR(color[1], b); - FLOAT_COLOR_TO_UBYTE_COLOR(color[2], c); + UNCLAMPED_FLOAT_TO_UBYTE(color[0], a); + UNCLAMPED_FLOAT_TO_UBYTE(color[1], b); + UNCLAMPED_FLOAT_TO_UBYTE(color[2], c); color[3] = 255; } @@ -373,7 +377,9 @@ void _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); GLubyte *color = ctx->Current.SecondaryColor; - FLOAT_RGB_TO_CHAN_RGB( color, v ); + UNCLAMPED_FLOAT_TO_CHAN(color[0], v[0]); + UNCLAMPED_FLOAT_TO_CHAN(color[1], v[1]); + UNCLAMPED_FLOAT_TO_CHAN(color[2], v[2]); color[3] = 255; } diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h index f0a7cc96b22..6101ab02256 100644 --- a/src/mesa/main/colormac.h +++ b/src/mesa/main/colormac.h @@ -1,4 +1,4 @@ -/* $Id: colormac.h,v 1.4 2000/11/24 10:25:05 keithw Exp $ */ +/* $Id: colormac.h,v 1.5 2001/01/02 22:02:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -42,60 +42,6 @@ */ -/* - * Integer / float conversion for colors, normals, etc. - */ - -#define BYTE_TO_UBYTE(b) (b < 0 ? 0 : (GLubyte) b) -#define SHORT_TO_UBYTE(s) (s < 0 ? 0 : (GLubyte) (s >> 7)) -#define USHORT_TO_UBYTE(s) (GLubyte) (s >> 8) -#define INT_TO_UBYTE(i) (i < 0 ? 0 : (GLubyte) (i >> 23)) -#define UINT_TO_UBYTE(i) (GLubyte) (i >> 24) - -/* Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */ -#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) (((X)) * 255.0F)) - - -/* Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */ -#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F)) - -/* Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */ -#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 ) - - -/* Convert GLushort in [0,65536] to GLfloat in [0.0,1.0] */ -#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) - -/* Convert GLfloat in [0.0,1.0] to GLushort in [0,65536] */ -#define FLOAT_TO_USHORT(X) ((GLushort) (GLint) ((X) * 65535.0F)) - - -/* Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */ -#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)) - -/* Convert GLfloat in [0.0,1.0] to GLshort in [-32768,32767] */ -#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 ) - - -/* Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */ -#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F)) - -/* Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */ -#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0)) - - -/* Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */ -#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0F)) - -/* Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */ -/* causes overflow: -#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 ) -*/ -/* a close approximation: */ -#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) ) - - - #if CHAN_BITS == 8 #define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (GLchan) (b)) @@ -106,12 +52,15 @@ #define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24)) #define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c) +#define FLOAT_TO_CHAN(f) ( (GLchan) IROUND((f) * CHAN_MAXF) ) -#define FLOAT_COLOR_TO_CHAN(c, f) FLOAT_COLOR_TO_UBYTE_COLOR(c, f) +#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f) +#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f) #define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC) -#define CHAN_PRODUCT(a, b) ( (GLubyte) (((GLint)(a) * ((GLint)(b) + 1)) >> 8) ) +#define CHAN_PRODUCT(a, b) ((GLubyte) (((GLint)(a) * ((GLint)(b) + 1)) >> 8)) + #elif CHAN_BITS == 16 @@ -122,14 +71,18 @@ #define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15)) #define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16)) -#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF))) +#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF) + 0.5F)) +#define FLOAT_TO_CHAN(f) ((GLchan) IROUND((f) * CHAN_MAXF)) -#define FLOAT_COLOR_TO_CHAN(c, f) \ - c = ((GLchan) FloatToInt(CLAMP(f, 0.0F, 1.0F) * CHAN_MAXF + 0.5F)) +#define CLAMPED_FLOAT_TO_CHAN(c, f) \ + c = ((GLchan) IROUND((f) * CHAN_MAXF)) +#define UNCLAMPED_FLOAT_TO_CHAN(c, f) \ + c = ( (GLchan) IROUND( CLAMP(f, 0.0, 1.0) * CHAN_MAXF) ) #define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) -#define CHAN_PRODUCT(a, b) ( (GLchan) ((((GLint) (a)) * ((GLint) (b))) / 65535) ) +#define CHAN_PRODUCT(a, b) ((GLchan) ((((GLint) (a)) * ((GLint) (b))) / 65535)) + #elif CHAN_BITS == 32 @@ -142,8 +95,10 @@ #define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F))) #define CHAN_TO_FLOAT(c) (c) +#define FLOAT_TO_CHAN(f) (f) -#define FLOAT_COLOR_TO_CHAN(c, f) c = f +#define CLAMPED_FLOAT_COLOR_TO_CHAN(c, f) c = (f) +#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f) #define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) @@ -156,41 +111,16 @@ #endif -#define FLOAT_RGB_TO_CHAN_RGB(dst, f) \ -do { \ - FLOAT_COLOR_TO_CHAN(dst[0], f[0]); \ - FLOAT_COLOR_TO_CHAN(dst[1], f[1]); \ - FLOAT_COLOR_TO_CHAN(dst[2], f[2]); \ -} while(0) -#define FLOAT_RGBA_TO_CHAN_RGBA(c, f) \ +/* + * Convert 3 channels at once. + */ +#define FLOAT_RGB_TO_CHAN_RGB(dst, f) \ do { \ - FLOAT_COLOR_TO_CHAN(c[0], f[0]); \ - FLOAT_COLOR_TO_CHAN(c[1], f[1]); \ - FLOAT_COLOR_TO_CHAN(c[2], f[2]); \ - FLOAT_COLOR_TO_CHAN(c[3], f[3]); \ + UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \ + UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \ + UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \ } while(0) -#if CHAN_BITS == 32 - -#define FLOAT_TO_CHAN(f) (f) -#define DOUBLE_TO_CHAN(f) ((GLfloat) (f)) -#define UNCLAMPED_FLOAT_TO_CHAN(f) (f) -#define UNCLAMPED_DOUBLE_TO_CHAN(f) ((GLfloat) (f)) - -#else - -#define FLOAT_TO_CHAN(f) ( (GLchan) FloatToInt((f) * CHAN_MAXF + 0.5F) ) -#define DOUBLE_TO_CHAN(f) ( (GLchan) FloatToInt((f) * CHAN_MAXF + 0.5F) ) - -#define UNCLAMPED_FLOAT_TO_CHAN(f) \ - ( (GLchan) FloatToInt( CLAMP(f, 0.0, 1.0) * CHAN_MAXF + 0.5F) ) - -#define UNCLAMPED_DOUBLE_TO_CHAN(f) \ - ( (GLchan) FloatToInt( CLAMP(f, 0.0, 1.0) * CHAN_MAXF + 0.5F) ) - -#endif - - #endif /* COLORMAC_H */ diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 0a697280623..d3d562318e8 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,4 +1,4 @@ -/* $Id: get.c,v 1.48 2000/12/26 05:09:28 keithw Exp $ */ +/* $Id: get.c,v 1.49 2001/01/02 22:02:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -2509,9 +2509,9 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) break; case GL_CURRENT_SECONDARY_COLOR_EXT: FLUSH_CURRENT(ctx, 0); - params[0] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[0]); - params[1] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[1]); - params[2] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[2]); + params[0] = CHAN_TO_FLOAT(ctx->Current.SecondaryColor[0]); + params[1] = CHAN_TO_FLOAT(ctx->Current.SecondaryColor[1]); + params[2] = CHAN_TO_FLOAT(ctx->Current.SecondaryColor[2]); break; case GL_SECONDARY_COLOR_ARRAY_EXT: *params = (GLdouble) ctx->Array.SecondaryColor.Enabled; @@ -3721,9 +3721,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_CURRENT_SECONDARY_COLOR_EXT: FLUSH_CURRENT(ctx, 0); - params[0] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[0]); - params[1] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[1]); - params[2] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[2]); + params[0] = CHAN_TO_FLOAT(ctx->Current.SecondaryColor[0]); + params[1] = CHAN_TO_FLOAT(ctx->Current.SecondaryColor[1]); + params[2] = CHAN_TO_FLOAT(ctx->Current.SecondaryColor[2]); break; case GL_SECONDARY_COLOR_ARRAY_EXT: *params = (GLfloat) ctx->Array.SecondaryColor.Enabled; @@ -4962,9 +4962,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_CURRENT_SECONDARY_COLOR_EXT: FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_INT( UBYTE_COLOR_TO_FLOAT_COLOR( ctx->Current.SecondaryColor[0] ) ); - params[1] = FLOAT_TO_INT( UBYTE_COLOR_TO_FLOAT_COLOR( ctx->Current.SecondaryColor[1] ) ); - params[2] = FLOAT_TO_INT( UBYTE_COLOR_TO_FLOAT_COLOR( ctx->Current.SecondaryColor[2] ) ); + params[0] = FLOAT_TO_INT( CHAN_TO_FLOAT(ctx->Current.SecondaryColor[0]) ); + params[1] = FLOAT_TO_INT( CHAN_TO_FLOAT(ctx->Current.SecondaryColor[1]) ); + params[2] = FLOAT_TO_INT( CHAN_TO_FLOAT(ctx->Current.SecondaryColor[2]) ); break; case GL_SECONDARY_COLOR_ARRAY_EXT: *params = (GLint) ctx->Array.SecondaryColor.Enabled; diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index f2003ccfbe0..6c50fed23e4 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.50 2000/11/28 00:07:51 brianp Exp $ */ +/* $Id: image.c,v 1.51 2001/01/02 22:02:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -2337,10 +2337,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], GLuint i; for (i = 0; i < n; i ++) { GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p ) & 0xff); - rgba[i][gComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 8) & 0xff); - rgba[i][bComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 16) & 0xff); - rgba[i][aComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 24) ); + rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff); + rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) ); } } else { @@ -2348,10 +2348,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], GLuint i; for (i = 0; i < n; i ++) { GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 24) ); - rgba[i][gComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 16) & 0xff); - rgba[i][bComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 8) & 0xff); - rgba[i][aComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p ) & 0xff); + rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) ); + rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff); } } break; @@ -2361,10 +2361,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], GLuint i; for (i = 0; i < n; i ++) { GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 24) ); - rgba[i][gComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 16) & 0xff); - rgba[i][bComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 8) & 0xff); - rgba[i][aComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p ) & 0xff); + rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) ); + rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff); } } else { @@ -2372,10 +2372,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], GLuint i; for (i = 0; i < n; i ++) { GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p ) & 0xff); - rgba[i][gComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 8) & 0xff); - rgba[i][bComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 16) & 0xff); - rgba[i][aComp] = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 24) ); + rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff); + rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) ); } } break; diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index e1a1b96e192..83a3095726e 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,4 +1,4 @@ -/* $Id: light.c,v 1.31 2000/12/26 05:09:28 keithw Exp $ */ +/* $Id: light.c,v 1.32 2001/01/02 22:02:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -616,7 +616,7 @@ void gl_update_material( GLcontext *ctx, foreach (light, list) { SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse ); } - FLOAT_COLOR_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]); } if (bitmask & BACK_DIFFUSE_BIT) { struct gl_material *mat = &ctx->Light.Material[1]; @@ -627,7 +627,7 @@ void gl_update_material( GLcontext *ctx, foreach (light, list) { SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse ); } - FLOAT_COLOR_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]); } /* update material specular values */ @@ -760,7 +760,7 @@ void gl_update_color_material( GLcontext *ctx, foreach (light, list) { SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse ); } - FLOAT_COLOR_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]); } if (bitmask & BACK_DIFFUSE_BIT) { @@ -769,7 +769,7 @@ void gl_update_color_material( GLcontext *ctx, foreach (light, list) { SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse ); } - FLOAT_COLOR_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]); } /* update light->_MatSpecular = light's specular * material's specular */ @@ -1173,8 +1173,8 @@ gl_update_lighting( GLcontext *ctx ) ctx->Light.Model.Ambient, mat->Ambient); - FLOAT_COLOR_TO_CHAN(ctx->Light._BaseAlpha[side], - ctx->Light.Material[side].Diffuse[3] ); + UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[side], + ctx->Light.Material[side].Diffuse[3] ); } foreach (light, &ctx->Light.EnabledList) { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 61e70688b68..7992b00304e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.8 2000/12/27 22:52:45 keithw Exp $ */ +/* $Id: mtypes.h,v 1.9 2001/01/02 22:02:51 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -31,7 +31,6 @@ #include "glheader.h" #include "config.h" /* Hardwired parameters */ -#include "fixed.h" /* GLfixed */ #include "glapitable.h" #include "glthread.h" @@ -101,17 +100,19 @@ #endif -/* Maximum number of temporary vertices required for clipping. (Used - * in array_cache and tnl modules). - */ -#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) - /* * Depth buffer data type: */ typedef GLuint GLdepth; /* Must be 32-bits! */ +/* + * Fixed point data type: + */ +typedef int GLfixed; + + + /* * Some forward type declarations */ @@ -123,6 +124,12 @@ typedef struct __GLcontextRec GLcontext; +/* Maximum number of temporary vertices required for clipping. (Used + * in array_cache and tnl modules). + */ +#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) + + /* Data structure for color tables */ struct gl_color_table { GLvoid *Table; @@ -1386,7 +1393,6 @@ struct gl_extensions { #define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT| \ _NEW_TEXTURE) - #define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL|_NEW_COLOR_MATRIX) diff --git a/src/mesa/math/m_trans_tmp.h b/src/mesa/math/m_trans_tmp.h index 952fde55942..e7d8a880719 100644 --- a/src/mesa/math/m_trans_tmp.h +++ b/src/mesa/math/m_trans_tmp.h @@ -1,8 +1,8 @@ -/* $Id: m_trans_tmp.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */ +/* $Id: m_trans_tmp.h,v 1.2 2001/01/02 22:02:52 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.5 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * diff --git a/src/mesa/math/m_translate.c b/src/mesa/math/m_translate.c index 1a0804ab60a..1f22b5a0bcb 100644 --- a/src/mesa/math/m_translate.c +++ b/src/mesa/math/m_translate.c @@ -1,4 +1,4 @@ -/* $Id: m_translate.c,v 1.2 2000/12/26 05:09:31 keithw Exp $ */ +/* $Id: m_translate.c,v 1.3 2001/01/02 22:02:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -110,6 +110,8 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; /* GL_BYTE */ +#define BYTE_TO_UBYTE(b) (b < 0 ? 0 : (GLubyte) b) + #define SRC GLbyte #define SRC_IDX TYPE_IDX(GL_BYTE) #define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) @@ -362,7 +364,7 @@ static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES]; #define SRC_IDX TYPE_IDX(GL_DOUBLE) #define TRX_3F(f,n) PTR_ELT(f,n) #define TRX_4F(f,n) PTR_ELT(f,n) -#define TRX_UB(ub,f,n) FLOAT_COLOR_TO_CHAN(ub, PTR_ELT(f,n)) +#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_CHAN(ub, PTR_ELT(f,n)) #define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n) #define TRX_1F(f,n) PTR_ELT(f,n) diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index 43cf9013d3c..090d5b6a81e 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -1,4 +1,4 @@ -/* $Id: s_aatriangle.c,v 1.4 2000/11/19 23:10:26 brianp Exp $ */ +/* $Id: s_aatriangle.c,v 1.5 2001/01/02 22:02:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -30,6 +30,7 @@ */ +#include "mmath.h" #include "s_aatriangle.h" #include "s_context.h" #include "s_span.h" diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index b08724f3a95..bcc5f2677d9 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.4 2000/12/14 20:25:59 brianp Exp $ */ +/* $Id: s_texture.c,v 1.5 2001/01/02 22:02:52 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -109,7 +109,7 @@ static void palette_sample(const struct gl_texture_object *tObj, { \ if (wrapMode == GL_REPEAT) { \ U = S * SIZE - 0.5F; \ - I0 = ((GLint) myFloor(U)) & (SIZE - 1); \ + I0 = IFLOOR(U) & (SIZE - 1); \ I1 = (I0 + 1) & (SIZE - 1); \ } \ else { \ @@ -119,7 +119,7 @@ static void palette_sample(const struct gl_texture_object *tObj, else if (U >= SIZE) \ U = SIZE; \ U -= 0.5F; \ - I0 = (GLint) myFloor(U); \ + I0 = IFLOOR(U); \ I1 = I0 + 1; \ if (wrapMode == GL_CLAMP_TO_EDGE) { \ if (I0 < 0) \ @@ -215,26 +215,6 @@ static void palette_sample(const struct gl_texture_object *tObj, /**********************************************************************/ -/* - * Return floor of x, being careful of negative values. - */ -static GLfloat myFloor(GLfloat x) -{ - if (x < 0.0F) - return (GLfloat) ((GLint) x - 1); - else - return (GLfloat) (GLint) x; -} - - -/* - * Return the fractional part of x. - */ -#define myFrac(x) ( (x) - myFloor(x) ) - - - - /* * Given 1-D texture image and an (i) texel column coordinate, return the * texel color. @@ -373,7 +353,7 @@ static void sample_1d_linear( const struct gl_texture_object *tObj, } { - const GLfloat a = myFrac(u); + const GLfloat a = FRAC(u); /* compute sample weights in fixed point in [0,WEIGHT_SCALE] */ const GLint w0 = (GLint) ((1.0F-a) * WEIGHT_SCALE + 0.5F); const GLint w1 = (GLint) ( a * WEIGHT_SCALE + 0.5F); @@ -438,7 +418,7 @@ sample_1d_nearest_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_1d_nearest( tObj, tObj->Image[level ], s, t0 ); sample_1d_nearest( tObj, tObj->Image[level+1], s, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -464,7 +444,7 @@ sample_1d_linear_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_1d_linear( tObj, tObj->Image[level ], s, t0 ); sample_1d_linear( tObj, tObj->Image[level+1], s, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -731,8 +711,8 @@ static void sample_2d_linear( const struct gl_texture_object *tObj, } { - const GLfloat a = myFrac(u); - const GLfloat b = myFrac(v); + const GLfloat a = FRAC(u); + const GLfloat b = FRAC(v); /* compute sample weights in fixed point in [0,WEIGHT_SCALE] */ const GLint w00 = (GLint) ((1.0F-a)*(1.0F-b) * WEIGHT_SCALE + 0.5F); const GLint w10 = (GLint) ( a *(1.0F-b) * WEIGHT_SCALE + 0.5F); @@ -816,7 +796,7 @@ sample_2d_nearest_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; /* texels */ - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_2d_nearest( tObj, tObj->Image[level ], s, t, t0 ); sample_2d_nearest( tObj, tObj->Image[level+1], s, t, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -842,7 +822,7 @@ sample_2d_linear_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; /* texels */ - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_2d_linear( tObj, tObj->Image[level ], s, t, t0 ); sample_2d_linear( tObj, tObj->Image[level+1], s, t, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1196,9 +1176,9 @@ static void sample_3d_linear( const struct gl_texture_object *tObj, } { - const GLfloat a = myFrac(u); - const GLfloat b = myFrac(v); - const GLfloat c = myFrac(w); + const GLfloat a = FRAC(u); + const GLfloat b = FRAC(v); + const GLfloat c = FRAC(w); /* compute sample weights in fixed point in [0,WEIGHT_SCALE] */ GLint w000 = (GLint) ((1.0F-a)*(1.0F-b)*(1.0F-c) * WEIGHT_SCALE + 0.5F); GLint w100 = (GLint) ( a *(1.0F-b)*(1.0F-c) * WEIGHT_SCALE + 0.5F); @@ -1319,7 +1299,7 @@ sample_3d_nearest_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; /* texels */ - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_3d_nearest( tObj, tObj->Image[level ], s, t, r, t0 ); sample_3d_nearest( tObj, tObj->Image[level+1], s, t, r, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1344,7 +1324,7 @@ sample_3d_linear_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; /* texels */ - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_3d_linear( tObj, tObj->Image[level ], s, t, r, t0 ); sample_3d_linear( tObj, tObj->Image[level+1], s, t, r, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1607,7 +1587,7 @@ sample_cube_nearest_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; /* texels */ - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_2d_nearest( tObj, images[level ], newS, newT, t0 ); sample_2d_nearest( tObj, images[level+1], newS, newT, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1636,7 +1616,7 @@ sample_cube_linear_mipmap_linear( const struct gl_texture_object *tObj, } else { GLchan t0[4], t1[4]; - const GLfloat f = myFrac(lambda); + const GLfloat f = FRAC(lambda); sample_2d_linear( tObj, images[level ], newS, newT, t0 ); sample_2d_linear( tObj, images[level+1], newS, newT, t1 ); rgba[RCOMP] = (GLchan) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index 6224bff3cba..528f1016612 100644 --- a/src/mesa/tnl/t_imm_api.c +++ b/src/mesa/tnl/t_imm_api.c @@ -347,9 +347,9 @@ _tnl_Color3f( GLfloat red, GLfloat green, GLfloat blue ) #if CHAN_BITS == 8 GLubyte col[4]; GET_IMMEDIATE; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], red); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], green); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], blue); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], red); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], green); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], blue); col[3] = CHAN_MAX; COLORV( IM, col ); #else @@ -388,10 +388,10 @@ _tnl_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) #if CHAN_BITS == 8 GLubyte col[4]; GET_IMMEDIATE; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], red); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], green); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], blue); - FLOAT_COLOR_TO_UBYTE_COLOR(col[3], alpha); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], red); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], green); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], blue); + UNCLAMPED_FLOAT_TO_UBYTE(col[3], alpha); COLORV( IM, col ); #else GET_IMMEDIATE; @@ -426,9 +426,9 @@ _tnl_Color3fv( const GLfloat *v ) #if CHAN_BITS == 8 GLubyte col[4]; GET_IMMEDIATE; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], v[0]); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], v[1]); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], v[2]); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], v[0]); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], v[1]); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], v[2]); col[3] = CHAN_MAX; COLORV( IM, col ); #else @@ -466,10 +466,10 @@ _tnl_Color4fv( const GLfloat *v ) #if CHAN_BITS == 8 GLubyte col[4]; GET_IMMEDIATE; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], v[0]); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], v[1]); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], v[2]); - FLOAT_COLOR_TO_UBYTE_COLOR(col[3], v[3]); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], v[0]); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], v[1]); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], v[2]); + UNCLAMPED_FLOAT_TO_UBYTE(col[3], v[3]); COLORV( IM, col ); #else GET_IMMEDIATE; @@ -529,9 +529,9 @@ _tnl_SecondaryColor3fEXT( GLfloat red, GLfloat green, GLfloat blue ) #if CHAN_BITS == 8 GLubyte col[3]; GET_IMMEDIATE; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], red); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], green); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], blue); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], red); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], green); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], blue); SECONDARY_COLORV( IM, col ); #else GET_IMMEDIATE; @@ -568,9 +568,9 @@ _tnl_SecondaryColor3fvEXT( const GLfloat *v ) #if CHAN_BITS == 8 GLubyte col[3]; GET_IMMEDIATE; - FLOAT_COLOR_TO_UBYTE_COLOR(col[0], v[0]); - FLOAT_COLOR_TO_UBYTE_COLOR(col[1], v[1]); - FLOAT_COLOR_TO_UBYTE_COLOR(col[2], v[2]); + UNCLAMPED_FLOAT_TO_UBYTE(col[0], v[0]); + UNCLAMPED_FLOAT_TO_UBYTE(col[1], v[1]); + UNCLAMPED_FLOAT_TO_UBYTE(col[2], v[2]); SECONDARY_COLORV( IM, col ); #else GET_IMMEDIATE; diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index 67fbdbe907c..ec79c7e52be 100644 --- a/src/mesa/tnl/t_imm_elt.c +++ b/src/mesa/tnl/t_imm_elt.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_elt.c,v 1.1 2000/12/26 05:09:32 keithw Exp $ */ +/* $Id: t_imm_elt.c,v 1.2 2001/01/02 22:02:53 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -388,7 +388,7 @@ static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES]; #define SRC_IDX TYPE_IDX(GL_DOUBLE) #define TRX_3F(f,n) PTR_ELT(f,n) #define TRX_4F(f,n) PTR_ELT(f,n) -#define TRX_UB(ub,f,n) FLOAT_COLOR_TO_CHAN(ub, PTR_ELT(f,n)) +#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_CHAN(ub, PTR_ELT(f,n)) #define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n) #define TRX_1F(f,n) PTR_ELT(f,n)