@@ -11,6 +11,7 @@ liblol_a_SOURCES = \ | |||||
text.cpp text.h emitter.cpp emitter.h numeric.h hash.cpp hash.h \ | text.cpp text.h emitter.cpp emitter.h numeric.h hash.cpp hash.h \ | ||||
worldentity.cpp worldentity.h gradient.cpp gradient.h half.cpp half.h \ | worldentity.cpp worldentity.h gradient.cpp gradient.h half.cpp half.h \ | ||||
platform.cpp platform.h sprite.cpp sprite.h trig.cpp trig.h \ | platform.cpp platform.h sprite.cpp sprite.h trig.cpp trig.h \ | ||||
real.cpp real.h \ | |||||
\ | \ | ||||
lol/unit.h \ | lol/unit.h \ | ||||
\ | \ | ||||
@@ -64,6 +64,7 @@ static inline int isnan(float f) | |||||
// Base types | // Base types | ||||
#include "trig.h" | #include "trig.h" | ||||
#include "half.h" | #include "half.h" | ||||
#include "real.h" | |||||
#include "matrix.h" | #include "matrix.h" | ||||
#include "numeric.h" | #include "numeric.h" | ||||
#include "timer.h" | #include "timer.h" | ||||
@@ -0,0 +1,48 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cstring> | |||||
#include "core.h" | |||||
using namespace std; | |||||
namespace lol | |||||
{ | |||||
template<> real4k::Real(float f) | |||||
{ | |||||
union { float f; uint32_t x; } u = { f }; | |||||
uint32_t sign = u.x & 0x80000000u; | |||||
int e = ((u.x >> 23) & 0xff) + (1 << 30) - (1 << 10); | |||||
m_signexp = sign | e; | |||||
m_mantissa[0] = u.x << 17; | |||||
memset(m_mantissa + 1, 0, sizeof(m_mantissa) - sizeof(m_mantissa[0])); | |||||
} | |||||
template<> real4k::operator float() const | |||||
{ | |||||
union { float f; uint32_t x; } u; | |||||
u.x = m_mantissa[0] >> 17; | |||||
u.x |= ((m_signexp & 0x7fffffffu) - (1 << 30) + (1 << 10)) << 23; | |||||
u.x |= m_signexp & 0x80000000u; | |||||
return u.f; | |||||
} | |||||
} /* namespace lol */ | |||||
@@ -0,0 +1,42 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
// | |||||
// The Real class | |||||
// -------------- | |||||
// | |||||
#if !defined __LOL_REAL_H__ | |||||
#define __LOL_REAL_H__ | |||||
#include <stdint.h> | |||||
namespace lol | |||||
{ | |||||
template<int NBITS> class Real | |||||
{ | |||||
public: | |||||
inline Real<NBITS>() {} | |||||
Real<NBITS>(float f); | |||||
operator float() const; | |||||
private: | |||||
uint32_t m_signexp; | |||||
uint32_t m_mantissa[(NBITS + 31) / 32]; | |||||
}; | |||||
typedef Real<4096> real4k; | |||||
} /* namespace lol */ | |||||
#endif // __LOL_REAL_H__ | |||||
@@ -19,7 +19,7 @@ noinst_PROGRAMS = quad sandbox benchsuite testsuite | |||||
TESTS = testsuite | TESTS = testsuite | ||||
testsuite_SOURCES = testsuite.cpp \ | testsuite_SOURCES = testsuite.cpp \ | ||||
unit/matrix.cpp unit/half.cpp unit/trig.cpp unit/build.cpp | |||||
unit/matrix.cpp unit/half.cpp unit/trig.cpp unit/build.cpp unit/real.cpp | |||||
testsuite_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | testsuite_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | ||||
testsuite_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | testsuite_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | ||||
testsuite_DEPENDENCIES = $(top_builddir)/src/liblol.a | testsuite_DEPENDENCIES = $(top_builddir)/src/liblol.a | ||||