diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2018-04-27 20:56:00 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2018-04-27 20:56:00 +0100 |
commit | bab0824608498d1079d4e9522f3014d3d538aabe (patch) | |
tree | 932f082b58fd48f85fbbdfa3f7419d2b3b03eedb /test_ieee754.c | |
parent | 3d73622dbd5a9ddc687fe6f42268c760695d7226 (diff) | |
download | faqe-bab0824608498d1079d4e9522f3014d3d538aabe.tar.gz faqe-bab0824608498d1079d4e9522f3014d3d538aabe.tar.xz faqe-bab0824608498d1079d4e9522f3014d3d538aabe.zip |
Implement basic model loading of FMD format.
The FMD (Faqe Model Data) format is a format designed for faqe. It
stores vertex, element and material information and mesh information.
This patch provides the basic implementation and use of this format.
This patch also implements perspective projection, depth testing and
view and model matrices.
An example fmd file is provided.
Diffstat (limited to 'test_ieee754.c')
-rw-r--r-- | test_ieee754.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test_ieee754.c b/test_ieee754.c new file mode 100644 index 0000000..44873c9 --- /dev/null +++ b/test_ieee754.c @@ -0,0 +1,38 @@ +#include <math.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +#include "ieee754.h" + +static unsigned long naiive(float n) +{ + union { + float f; + uint32_t u; + } u = { .f = n }; + + return u.u; +} + +void test(float a) +{ + float b = ieee754f(naiive(a)); + + if (!((isnan(a) && isnan(b)) || a == b)) { + fprintf(stderr, "%lu: %.40f != %.40f\n", naiive(a), a, b); + exit(EXIT_FAILURE); + } +} + +int main(void) +{ + test(NAN); + test(+INFINITY); + test(-INFINITY); + test(0x1p127f); + test(0x7fffffp-149f); + + for (float n = -0.000000001; n <= 1; n = nextafterf(n, 2)) + test(n); +} |