summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-04-10 15:25:45 +0000
committerBrian Paul <[email protected]>2001-04-10 15:25:45 +0000
commit33143303feaf84afbef2e63ac0adab2d70b3c344 (patch)
tree254797012163f4adfc14c6b6d38b59d24f8c0e9e /src/mesa/main
parent148bd34079a677138af570a4824c50ddc6c6e786 (diff)
Added IROUND_POS() macro to mmath.h and use where appropriate. (Klaus Niederkrueger)
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/colortab.c40
-rw-r--r--src/mesa/main/drawpix.c6
-rw-r--r--src/mesa/main/pixel.c58
3 files changed, 52 insertions, 52 deletions
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 5a50ae50e66..61f93be2aad 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,4 +1,4 @@
-/* $Id: colortab.c,v 1.38 2001/03/19 02:25:35 keithw Exp $ */
+/* $Id: colortab.c,v 1.39 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -683,7 +683,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
rgba[i][RCOMP] = 0;
rgba[i][GCOMP] = 0;
rgba[i][BCOMP] = 0;
- rgba[i][ACOMP] = (GLint) (tableF[i] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
}
}
else {
@@ -702,9 +702,9 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
rgba[i][ACOMP] = CHAN_MAX;
}
}
@@ -724,10 +724,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i*2+0] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i*2+0] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i*2+0] * CHAN_MAXF);
- rgba[i][ACOMP] = (GLint) (tableF[i*2+1] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i*2+1] * CHAN_MAXF);
}
}
else {
@@ -746,10 +746,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i] * CHAN_MAXF);
- rgba[i][ACOMP] = (GLint) (tableF[i] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
}
}
else {
@@ -768,9 +768,9 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i*3+0] * CHAN_MAXF);
- rgba[i][GCOMP] = (GLint) (tableF[i*3+1] * CHAN_MAXF);
- rgba[i][BCOMP] = (GLint) (tableF[i*3+2] * CHAN_MAXF);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*3+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*3+1] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*3+2] * CHAN_MAXF);
rgba[i][ACOMP] = CHAN_MAX;
}
}
@@ -790,10 +790,10 @@ _mesa_GetColorTable( GLenum target, GLenum format,
const GLfloat *tableF = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = (GLint) (tableF[i*4+0] * CHAN_MAXF + 0.5F);
- rgba[i][GCOMP] = (GLint) (tableF[i*4+1] * CHAN_MAXF + 0.5F);
- rgba[i][BCOMP] = (GLint) (tableF[i*4+2] * CHAN_MAXF + 0.5F);
- rgba[i][ACOMP] = (GLint) (tableF[i*4+3] * CHAN_MAXF + 0.5F);
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*4+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*4+1] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*4+2] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i*4+3] * CHAN_MAXF);
}
}
else {
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index 4b34ddd707a..d46ace0a655 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.51 2001/03/19 02:25:35 keithw Exp $ */
+/* $Id: drawpix.c,v 1.52 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -64,8 +64,8 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
_mesa_update_state(ctx);
}
- x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
- y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
+ x = IROUND(ctx->Current.RasterPos[0]);
+ y = IROUND(ctx->Current.RasterPos[1]);
ctx->OcclusionResult = GL_TRUE;
ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 6a31d5a59fe..dc8f5be3073 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.27 2001/03/12 00:48:38 gareth Exp $ */
+/* $Id: pixel.c,v 1.28 2001/04/10 15:25:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -832,10 +832,10 @@ _mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
const GLfloat *aMap = ctx->Pixel.MapAtoA;
GLuint i;
for (i=0;i<n;i++) {
- rgba[i][RCOMP] = rMap[(GLint) (rgba[i][RCOMP] * rscale + 0.5F)];
- rgba[i][GCOMP] = gMap[(GLint) (rgba[i][GCOMP] * gscale + 0.5F)];
- rgba[i][BCOMP] = bMap[(GLint) (rgba[i][BCOMP] * bscale + 0.5F)];
- rgba[i][ACOMP] = aMap[(GLint) (rgba[i][ACOMP] * ascale + 0.5F)];
+ rgba[i][RCOMP] = rMap[IROUND(rgba[i][RCOMP] * rscale)];
+ rgba[i][GCOMP] = gMap[IROUND(rgba[i][GCOMP] * gscale)];
+ rgba[i][BCOMP] = bMap[IROUND(rgba[i][BCOMP] * bscale)];
+ rgba[i][ACOMP] = aMap[IROUND(rgba[i][ACOMP] * ascale)];
}
}
@@ -888,7 +888,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = CHAN_TO_FLOAT(lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
@@ -900,7 +900,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = lut[j];
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
@@ -914,7 +914,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = CHAN_TO_FLOAT(lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
@@ -924,7 +924,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
GLfloat c = lut[j];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
@@ -937,7 +937,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[j]);
}
}
@@ -946,7 +946,7 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint j = IROUND(rgba[i][ACOMP] * scale);
rgba[i][ACOMP] = lut[j];
}
}
@@ -958,8 +958,8 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jL = IROUND(rgba[i][RCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
GLfloat luminance = CHAN_TO_FLOAT(lut[jL * 2 + 0]);
GLfloat alpha = CHAN_TO_FLOAT(lut[jA * 2 + 1]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
@@ -971,8 +971,8 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jL = IROUND(rgba[i][RCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
GLfloat luminance = lut[jL * 2 + 0];
GLfloat alpha = lut[jA * 2 + 1];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
@@ -987,9 +987,9 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 3 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 3 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 3 + 2]);
@@ -1000,9 +1000,9 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
rgba[i][RCOMP] = lut[jR * 3 + 0];
rgba[i][GCOMP] = lut[jG * 3 + 1];
rgba[i][BCOMP] = lut[jB * 3 + 2];
@@ -1016,10 +1016,10 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 4 + 0]);
rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 4 + 1]);
rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 4 + 2]);
@@ -1031,10 +1031,10 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
- GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
- GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
rgba[i][RCOMP] = lut[jR * 4 + 0];
rgba[i][GCOMP] = lut[jG * 4 + 1];
rgba[i][BCOMP] = lut[jB * 4 + 2];