aboutsummaryrefslogtreecommitdiff
path: root/src/config.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
index 5099409..18dc414 100644
--- a/src/config.h
+++ b/src/config.h
@@ -9,12 +9,28 @@ typedef unsigned long long u64;
typedef float f32;
typedef double f64;
+/*
+You may be wondering "why fixed point values???", and that's simple
+Floating Point was a mistake and has caused great suffering to countless.
+Time-keeping is specially burdened. Nobody should ever keep track of time
+with float values. Variable precision can and WILL throw off calculations
+no matter how much of a NERD you are.
+
+What I did was to just leverage the support for floats in order to make most
+things simply take them (that's what everyone expects) then convert them to
+fixed point for precise operations.
+
+They can still be happily used for other things, specially inside shaders.
+But don't @ me.
+*/
+
// 24.8 format
typedef i32 fx32;
#define FIXED_POINT_BITS 8
#define FIXED_POINT_ONE (1 << FIXED_POINT_BITS)
#define TO_FIXED(x) ((fx32)(x) << FIXED_POINT_BITS)
#define FROM_FIXED(x) ((x) >> FIXED_POINT_BITS)
+#define FP_TO_FIXED(x) (fx32)((x) * FIXED_POINT_BITS)
typedef struct{
fx32 x, y;