summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-02-08 00:37:32 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-02-08 00:37:32 +0000
commit08a45d4d4f01100d3c99d1c8fc4b7db1242b78ef (patch)
tree64f168fb240c0ae1edd36453b72dd1995f546c6d /src/mesa
parent875f763c9fbe00661335e6b252aa3740101ea8d0 (diff)
fully parameterize the macros for fixed-point arithmetic
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/mtypes.h20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5ed79424d5..37fb9a2408 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -108,21 +108,15 @@ typedef int GLfixed;
/*
* Fixed point arithmetic macros
*/
-#ifdef FIXED_14
-#define FIXED_ONE 0x00004000
-#define FIXED_HALF 0x00002000
-#define FIXED_FRAC_MASK 0x00003FFF
-#define FIXED_SCALE 16384.0f
-#define FIXED_SHIFT 14
-#else
-#define FIXED_ONE 0x00000800
-#define FIXED_HALF 0x00000400
-#define FIXED_FRAC_MASK 0x000007FF
-#define FIXED_SCALE 2048.0f
-#define FIXED_SHIFT 11
-#endif
+#define FIXED_FRAC_BITS 11
+
+#define FIXED_SHIFT FIXED_FRAC_BITS
+#define FIXED_ONE (1 << FIXED_SHIFT)
+#define FIXED_HALF (1 << (FIXED_SHIFT-1))
+#define FIXED_FRAC_MASK (FIXED_ONE - 1)
#define FIXED_INT_MASK (~FIXED_FRAC_MASK)
#define FIXED_EPSILON 1
+#define FIXED_SCALE ((float) FIXED_ONE)
#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
#define IntToFixed(I) ((I) << FIXED_SHIFT)
#define FixedToInt(X) ((X) >> FIXED_SHIFT)