diff options
author | Brian Paul <[email protected]> | 2001-01-02 22:02:51 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2001-01-02 22:02:51 +0000 |
commit | 3041d05bbcccfddba01a1eeaba01e5da0e1e99af (patch) | |
tree | e25361e01fdf7be6d75713235c7e130246be67f1 /src/mesa/main | |
parent | 8446d1bab15ef82b35b8980a0a56072ace6feb04 (diff) |
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.
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/api_loopback.c | 35 | ||||
-rw-r--r-- | src/mesa/main/api_noop.c | 32 | ||||
-rw-r--r-- | src/mesa/main/colormac.h | 118 | ||||
-rw-r--r-- | src/mesa/main/get.c | 20 | ||||
-rw-r--r-- | src/mesa/main/image.c | 34 | ||||
-rw-r--r-- | src/mesa/main/light.c | 14 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 22 |
7 files changed, 109 insertions, 166 deletions
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,11 +100,6 @@ #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: */ @@ -113,6 +107,13 @@ typedef GLuint GLdepth; /* Must be 32-bits! */ /* + * Fixed point data type: + */ +typedef int GLfixed; + + + +/* * Some forward type declarations */ struct _mesa_HashTable; @@ -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) |