summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2001-01-02 22:02:51 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2001-01-02 22:02:51 +0000
commit3041d05bbcccfddba01a1eeaba01e5da0e1e99af (patch)
treee25361e01fdf7be6d75713235c7e130246be67f1 /src/mesa/swrast
parent8446d1bab15ef82b35b8980a0a56072ace6feb04 (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/swrast')
-rw-r--r--src/mesa/swrast/s_aatriangle.c3
-rw-r--r--src/mesa/swrast/s_texture.c54
2 files changed, 19 insertions, 38 deletions
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index 43cf9013d3..090d5b6a81 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 b08724f3a9..bcc5f2677d 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) \
@@ -216,26 +216,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]);