FLOAT_TO_CHAN() macro removed.
(*(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).
-/* $Id: colormac.h,v 1.5 2001/01/02 22:02:51 brianp Exp $ */
+/* $Id: colormac.h,v 1.6 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
#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 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 UINT_TO_CHAN(i) ((GLchan) ((i) >> 16))
#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF) + 0.5F))
-#define FLOAT_TO_CHAN(f) ((GLchan) IROUND((f) * CHAN_MAXF))
#define CLAMPED_FLOAT_TO_CHAN(c, f) \
c = ((GLchan) IROUND((f) * CHAN_MAXF))
#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
#define CHAN_TO_FLOAT(c) (c)
-#define FLOAT_TO_CHAN(f) (f)
-#define CLAMPED_FLOAT_COLOR_TO_CHAN(c, f) c = (f)
+#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
/*
* Convert 3 channels at once.
*/
-#define FLOAT_RGB_TO_CHAN_RGB(dst, f) \
+#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \
do { \
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)
+} while (0)
+
+
+/*
+ * Convert 4 channels at once.
+ */
+#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \
+do { \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[3], f[3]); \
+} while (0)
#endif /* COLORMAC_H */
-/* $Id: image.c,v 1.51 2001/01/02 22:02:51 brianp Exp $ */
+/* $Id: image.c,v 1.52 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstRedIndex] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstRedIndex], rgba[i][RCOMP]);
dst += dstComponents;
}
}
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstGreenIndex] = FLOAT_TO_CHAN(rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstGreenIndex], rgba[i][GCOMP]);
dst += dstComponents;
}
}
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstBlueIndex] = FLOAT_TO_CHAN(rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstBlueIndex], rgba[i][BCOMP]);
dst += dstComponents;
}
}
GLchan *dst = dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[dstAlphaIndex] = FLOAT_TO_CHAN(rgba[i][ACOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[dstAlphaIndex], rgba[i][ACOMP]);
dst += dstComponents;
}
}
assert(dstComponents == 1);
for (i = 0; i < n; i++) {
/* Intensity comes from red channel */
- dst[i] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]);
}
}
assert(dstLuminanceIndex == 0);
for (i = 0; i < n; i++) {
/* Luminance comes from red channel */
- dst[0] = FLOAT_TO_CHAN(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]);
dst += dstComponents;
}
}
-/* $Id: pixel.c,v 1.22 2000/12/26 05:09:29 keithw Exp $ */
+/* $Id: pixel.c,v 1.23 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
const GLfloat *aMap = ctx->Pixel.MapItoA;
GLuint i;
for (i=0;i<n;i++) {
- rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]);
- rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]);
- rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]);
- rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
}
#endif
}
const GLfloat *aMap = ctx->Pixel.MapItoA;
GLuint i;
for (i=0;i<n;i++) {
- rgba[i][RCOMP] = FLOAT_TO_CHAN(rMap[index[i] & rmask]);
- rgba[i][GCOMP] = FLOAT_TO_CHAN(gMap[index[i] & gmask]);
- rgba[i][BCOMP] = FLOAT_TO_CHAN(bMap[index[i] & bmask]);
- rgba[i][ACOMP] = FLOAT_TO_CHAN(aMap[index[i] & amask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
}
#endif
}
-/* $Id: s_drawpix.c,v 1.5 2000/12/26 05:09:32 keithw Exp $ */
+/* $Id: s_drawpix.c,v 1.6 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
/* Colors or indexes */
if (ctx->Visual.RGBAflag) {
- GLint r = FLOAT_TO_CHAN(ctx->Current.RasterColor[0]);
- GLint g = FLOAT_TO_CHAN(ctx->Current.RasterColor[1]);
- GLint b = FLOAT_TO_CHAN(ctx->Current.RasterColor[2]);
- GLint a = FLOAT_TO_CHAN(ctx->Current.RasterColor[3]);
GLint i;
+ GLint r, g, b, a;
+ UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]);
for (i = 0; i < drawWidth; i++) {
rgba[i][RCOMP] = r;
rgba[i][GCOMP] = g;
-/* $Id: s_fog.c,v 1.6 2001/01/02 21:09:50 brianp Exp $ */
+/* $Id: s_fog.c,v 1.7 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
const GLfixed fog[],
GLchan rgba[][4] )
{
- const GLchan rFog = FLOAT_TO_CHAN(ctx->Fog.Color[RCOMP]);
- const GLchan gFog = FLOAT_TO_CHAN(ctx->Fog.Color[GCOMP]);
- const GLchan bFog = FLOAT_TO_CHAN(ctx->Fog.Color[BCOMP]);
GLuint i;
+ GLchan rFog, gFog, bFog;
+
+ UNCLAMPED_FLOAT_TO_CHAN(rFog, ctx->Fog.Color[RCOMP]);
+ UNCLAMPED_FLOAT_TO_CHAN(gFog, ctx->Fog.Color[GCOMP]);
+ UNCLAMPED_FLOAT_TO_CHAN(bFog, ctx->Fog.Color[BCOMP]);
#if CHAN_TYPE == GL_FLOAT
for (i = 0; i < n; i++) {
-/* $Id: s_texture.c,v 1.5 2001/01/02 22:02:52 brianp Exp $ */
+/* $Id: s_texture.c,v 1.6 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
break;
case GL_CONSTANT_EXT:
{
- GLchan (*c)[4] = ccolor[j];
- GLchan alpha = FLOAT_TO_CHAN(textureUnit->EnvColor[3]);
+ GLchan alpha, (*c)[4] = ccolor[j];
+ UNCLAMPED_FLOAT_TO_CHAN(alpha, textureUnit->EnvColor[3]);
for (i = 0; i < n; i++)
c[i][ACOMP] = alpha;
argA[j] = ccolor[j];
case GL_CONSTANT_EXT:
{
GLchan (*c)[4] = ccolor[j];
- const GLchan red = FLOAT_TO_CHAN(textureUnit->EnvColor[0]);
- const GLchan green = FLOAT_TO_CHAN(textureUnit->EnvColor[1]);
- const GLchan blue = FLOAT_TO_CHAN(textureUnit->EnvColor[2]);
+ GLchan red, green, blue;
+ UNCLAMPED_FLOAT_TO_CHAN(red, textureUnit->EnvColor[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(green, textureUnit->EnvColor[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(blue, textureUnit->EnvColor[2]);
for (i = 0; i < n; i++) {
c[i][RCOMP] = red;
c[i][GCOMP] = green;
-/* $Id: t_imm_eval.c,v 1.2 2000/12/27 22:30:29 keithw Exp $ */
+/* $Id: t_imm_eval.c,v 1.3 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLubyte (*to)[4] = dest->data;
GLuint i;
- for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++)
+ for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) {
if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
GLfloat u = (coord[i][0] - u1) * du;
GLfloat fcolor[4];
_math_horner_bezier_curve(map->Points, fcolor, u, 4, map->Order);
- FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN(to[i], fcolor);
}
+ }
}
GLubyte (*to)[4] = dest->data;
GLuint i;
- for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++)
+ for (i = 0 ; !(flags[i] & VERT_END_VB) ; i++) {
if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
GLfloat u = (coord[i][0] - u1) * du;
GLfloat v = (coord[i][1] - v1) * dv;
GLfloat fcolor[4];
_math_horner_bezier_surf(map->Points, fcolor, u, v, 4,
map->Uorder, map->Vorder);
- FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN(to[i], fcolor);
}
-
+ }
}
-/* $Id: t_vb_lighttmp.h,v 1.1 2000/12/26 05:09:33 keithw Exp $ */
+/* $Id: t_vb_lighttmp.h,v 1.2 2001/01/03 15:59:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
}
} /*loop over lights*/
- FLOAT_RGB_TO_CHAN_RGB( Fcolor[j], sum[0] );
- FLOAT_RGB_TO_CHAN_RGB( Fspec[j], spec[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fspec[j], spec[0] );
Fcolor[j][3] = sumA[0];
if (IDX & LIGHT_TWOSIDE) {
- FLOAT_RGB_TO_CHAN_RGB( Bcolor[j], sum[1] );
- FLOAT_RGB_TO_CHAN_RGB( Bspec[j], spec[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bspec[j], spec[1] );
Bcolor[j][3] = sumA[1];
}
}
ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib );
}
- FLOAT_RGB_TO_CHAN_RGB( Fcolor[j], sum[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
Fcolor[j][3] = sumA[0];
if (IDX & LIGHT_TWOSIDE) {
- FLOAT_RGB_TO_CHAN_RGB( Bcolor[j], sum[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
Bcolor[j][3] = sumA[1];
}
}
{
COPY_3V(base[0], light->_MatAmbient[0]);
ACC_3V(base[0], ctx->Light._BaseColor[0] );
- FLOAT_RGB_TO_CHAN_RGB( baseubyte[0], base[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[0], base[0] );
if (IDX & LIGHT_TWOSIDE) {
COPY_3V(base[1], light->_MatAmbient[1]);
ACC_3V(base[1], ctx->Light._BaseColor[1]);
- FLOAT_RGB_TO_CHAN_RGB( baseubyte[1], base[1]);
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( baseubyte[1], base[1]);
}
}
GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
}
- FLOAT_RGB_TO_CHAN_RGB(Bcolor[j], sum );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN(Bcolor[j], sum );
}
} else {
GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm);
ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]);
}
- FLOAT_RGB_TO_CHAN_RGB(Fcolor[j], sum );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN(Fcolor[j], sum );
}
j++;
}
}
- FLOAT_RGB_TO_CHAN_RGB( Fcolor[j], sum[0] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] );
Fcolor[j][3] = sumA[0];
if (IDX & LIGHT_TWOSIDE) {
- FLOAT_RGB_TO_CHAN_RGB( Bcolor[j], sum[1] );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] );
Bcolor[j][3] = sumA[1];
}
-/* $Id: t_vb_render.c,v 1.4 2000/12/28 22:11:06 keithw Exp $ */
+/* $Id: t_vb_render.c,v 1.5 2001/01/03 15:59:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
#if 1
-#define LINTERP_RGBA(nr, t, out, a, b) { \
+#define LINTERP_RGBA(nr, t, out, a, b) { \
int i; \
for (i = 0; i < nr; i++) { \
GLfloat fa = CHAN_TO_FLOAT(a[i]); \
GLfloat fb = CHAN_TO_FLOAT(b[i]); \
GLfloat fo = LINTERP(t, fa, fb); \
- FLOAT_COLOR_TO_CHAN(out[i], fo); \
+ CLAMPED_FLOAT_TO_CHAN(out[i], fo); \
} \
}
#else
-#define LINTERP_RGBA(nr, t, out, a, b) { \
+#define LINTERP_RGBA(nr, t, out, a, b) { \
int n; \
const GLuint ti = FloatToInt(t*256.0F); \
const GLubyte *Ib = (const GLubyte *)&a[0]; \