From 06c4ec01c36655efc57a05a4a5bd604f708b1d8c Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 4 Feb 2013 23:48:19 +0000 Subject: [PATCH] base: move headers around and promote gpu/ to lol/gpu/. --- src/Makefile.am | 62 ++++++----- src/core.h | 28 +---- src/lol/base/base.h | 23 ++++ src/{ => lol}/gpu/framebuffer.h | 6 +- src/lol/gpu/gpu.h | 22 ++++ src/{ => lol}/gpu/indexbuffer.h | 6 +- src/{ => lol}/gpu/lolfx.h | 8 +- src/{ => lol}/gpu/shader.h | 6 +- src/{ => lol}/gpu/texture.h | 6 +- src/{ => lol}/gpu/vertexbuffer.h | 6 +- src/lol/image/image.h | 17 +++ src/lol/math/functions.h | 177 +++++++++++++++++++++++++++++++ src/lol/math/geometry.h | 8 +- src/lol/math/half.h | 6 +- src/lol/math/math.h | 166 +---------------------------- src/lol/sys/sys.h | 19 ++++ src/lol/sys/thread.h | 6 +- src/lolcore.vcxproj | 17 +-- 18 files changed, 345 insertions(+), 244 deletions(-) create mode 100644 src/lol/base/base.h rename src/{ => lol}/gpu/framebuffer.h (85%) create mode 100644 src/lol/gpu/gpu.h rename src/{ => lol}/gpu/indexbuffer.h (86%) rename src/{ => lol}/gpu/lolfx.h (86%) rename src/{ => lol}/gpu/shader.h (96%) rename src/{ => lol}/gpu/texture.h (91%) rename src/{ => lol}/gpu/vertexbuffer.h (98%) create mode 100644 src/lol/image/image.h create mode 100644 src/lol/math/functions.h create mode 100644 src/lol/sys/sys.h diff --git a/src/Makefile.am b/src/Makefile.am index 0a922dfe..bc22cc9a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,14 +16,44 @@ liblol_a_SOURCES = \ platform.cpp platform.h sprite.cpp sprite.h camera.cpp camera.h \ light.cpp light.h \ \ + $(liblol_headers) \ + $(liblol_sources) \ + \ + $(ps3_sources) \ + $(xbox_sources) \ + $(nacl_sources) \ + $(sdl_sources) \ + $(d3d9_sources) \ + $(android_sources) \ + \ + $(bullet_sources) +liblol_a_CPPFLAGS = @LOL_CFLAGS@ -I$(srcdir)/bullet + +EXTRA_DIST = easymesh/easymesh-scanner.l easymesh/easymesh-parser.y \ + gpu/lolfx-scanner.l gpu/lolfx-parser.y + +liblol_headers = \ + lol/base/base.h \ lol/base/log.h lol/base/array.h lol/base/types.h lol/base/array.h \ lol/base/string.h lol/base/hash.h lol/base/map.h \ - lol/math/vector.h lol/math/half.h lol/math/real.h lol/math/remez.h \ - lol/math/math.h lol/math/geometry.h \ + \ + lol/math/math.h \ + lol/math/functions.h lol/math/vector.h lol/math/half.h lol/math/real.h \ + lol/math/remez.h lol/math/math.h lol/math/geometry.h \ + \ + lol/sys/sys.h \ lol/sys/init.h lol/sys/thread.h lol/sys/timer.h \ + \ + lol/image/image.h \ lol/image/color.h \ - lol/unit.h \ \ + lol/gpu/gpu.h \ + lol/gpu/shader.h lol/gpu/indexbuffer.h lol/gpu/vertexbuffer.h \ + lol/gpu/gpu/framebuffer.h lol/gpu/texture.h lol/gpu/lolfx.h \ + \ + lol/unit.h + +liblol_sources = \ generated/location.hh generated/position.hh generated/stack.hh \ \ application/application.cpp application/application.h \ @@ -36,34 +66,24 @@ liblol_a_SOURCES = \ generated/easymesh-parser.cpp generated/easymesh-parser.h \ generated/easymesh-scanner.cpp \ \ - $(ps3_sources) \ - $(xbox_sources) \ - $(nacl_sources) \ - $(sdl_sources) \ - $(d3d9_sources) \ - $(android_sources) \ - \ base/hash.cpp base/log.cpp base/string.cpp \ \ math/vector.cpp math/real.cpp math/half.cpp math/trig.cpp \ math/geometry.cpp \ \ + gpu/shader.cpp gpu/indexbuffer.cpp gpu/vertexbuffer.cpp \ + gpu/framebuffer.cpp gpu/texture.cpp \ + \ input/input.cpp input/input.h \ input/keyboard.cpp input/keyboard.h \ input/stick.cpp input/stick.h \ \ - gpu/shader.cpp gpu/shader.h \ - gpu/indexbuffer.cpp gpu/indexbuffer.h \ - gpu/vertexbuffer.cpp gpu/vertexbuffer.h \ - gpu/framebuffer.cpp gpu/framebuffer.h \ - gpu/texture.cpp gpu/texture.h \ - \ gpu/defaultmaterial.lolfx \ gpu/tile.lolfx \ gpu/emptymaterial.lolfx \ gpu/testmaterial.lolfx \ \ - gpu/lolfx.cpp gpu/lolfx.h \ + gpu/lolfx.cpp \ gpu/lolfx-compiler.cpp gpu/lolfx-compiler.h \ generated/lolfx-parser.cpp generated/lolfx-parser.h \ generated/lolfx-scanner.cpp \ @@ -81,13 +101,7 @@ liblol_a_SOURCES = \ \ loldebug.h \ debug/fps.cpp debug/fps.h \ - debug/record.cpp debug/record.h debug/stats.cpp debug/stats.h \ - \ - $(bullet_sources) -liblol_a_CPPFLAGS = @LOL_CFLAGS@ -I$(srcdir)/bullet - -EXTRA_DIST = easymesh/easymesh-scanner.l easymesh/easymesh-parser.y \ - gpu/lolfx-scanner.l gpu/lolfx-parser.y + debug/record.cpp debug/record.h debug/stats.cpp debug/stats.h sdl_sources = \ image/codec/sdl-image.cpp \ diff --git a/src/core.h b/src/core.h index 930dd7f5..182f2d2e 100644 --- a/src/core.h +++ b/src/core.h @@ -79,25 +79,11 @@ static inline int isnan(float f) #endif // Base types -#include -#include -#include -#include -#include -#include -#include - +#include #include -#include -#include -#include -#include - -#include -#include -#include - -#include +#include +#include +#include #include "numeric.h" @@ -130,12 +116,6 @@ static inline int isnan(float f) #include "dict.h" #include "map.h" #include "layer.h" -#include "gpu/lolfx.h" -#include "gpu/shader.h" -#include "gpu/texture.h" -#include "gpu/indexbuffer.h" -#include "gpu/vertexbuffer.h" -#include "gpu/framebuffer.h" #include "mesh/mesh.h" #include "image/image.h" #include "application/application.h" diff --git a/src/lol/base/base.h b/src/lol/base/base.h new file mode 100644 index 00000000..7b3925bf --- /dev/null +++ b/src/lol/base/base.h @@ -0,0 +1,23 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2013 Sam Hocevar +// 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://www.wtfpl.net/ for more details. +// + +#if !defined __LOL_BASE_BASE_H__ +#define __LOL_BASE_BASE_H__ + +#include +#include +#include +#include +#include +#include +#include + +#endif // __LOL_BASE_BASE_H__ + diff --git a/src/gpu/framebuffer.h b/src/lol/gpu/framebuffer.h similarity index 85% rename from src/gpu/framebuffer.h rename to src/lol/gpu/framebuffer.h index 3f3dd877..403792a9 100644 --- a/src/gpu/framebuffer.h +++ b/src/lol/gpu/framebuffer.h @@ -13,8 +13,8 @@ // --------------------- // -#if !defined __LOL_FRAMEBUFFER_H__ -#define __LOL_FRAMEBUFFER_H__ +#if !defined __LOL_GPU_FRAMEBUFFER_H__ +#define __LOL_GPU_FRAMEBUFFER_H__ #include @@ -38,5 +38,5 @@ private: } /* namespace lol */ -#endif // __LOL_FRAMEBUFFER_H__ +#endif // __LOL_GPU_FRAMEBUFFER_H__ diff --git a/src/lol/gpu/gpu.h b/src/lol/gpu/gpu.h new file mode 100644 index 00000000..3010d379 --- /dev/null +++ b/src/lol/gpu/gpu.h @@ -0,0 +1,22 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2013 Sam Hocevar +// 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://www.wtfpl.net/ for more details. +// + +#if !defined __LOL_GPU_GPU_H__ +#define __LOL_GPU_GPU_H__ + +#include +#include +#include +#include +#include +#include + +#endif // __LOL_GPU_GPU_H__ + diff --git a/src/gpu/indexbuffer.h b/src/lol/gpu/indexbuffer.h similarity index 86% rename from src/gpu/indexbuffer.h rename to src/lol/gpu/indexbuffer.h index fe848dc3..4a756737 100644 --- a/src/gpu/indexbuffer.h +++ b/src/lol/gpu/indexbuffer.h @@ -13,8 +13,8 @@ // --------------------- // -#if !defined __LOL_INDEXBUFFER_H__ -#define __LOL_INDEXBUFFER_H__ +#if !defined __LOL_GPU_INDEXBUFFER_H__ +#define __LOL_GPU_INDEXBUFFER_H__ #include @@ -39,5 +39,5 @@ private: } /* namespace lol */ -#endif // __LOL_INDEXBUFFER_H__ +#endif // __LOL_GPU_INDEXBUFFER_H__ diff --git a/src/gpu/lolfx.h b/src/lol/gpu/lolfx.h similarity index 86% rename from src/gpu/lolfx.h rename to src/lol/gpu/lolfx.h index 1d68597d..5570d907 100644 --- a/src/gpu/lolfx.h +++ b/src/lol/gpu/lolfx.h @@ -13,10 +13,10 @@ // --------------- // -#if !defined __GPU_LOLFX_H__ -#define __GPU_LOLFX_H__ +#if !defined __LOL_GPU_LOLFX_H__ +#define __LOL_GPU_LOLFX_H__ -#include "gpu/shader.h" +#include namespace lol { @@ -44,5 +44,5 @@ private: } /* namespace lol */ -#endif /* __GPU_LOLFX_H__ */ +#endif /* __LOL_GPU_LOLFX_H__ */ diff --git a/src/gpu/shader.h b/src/lol/gpu/shader.h similarity index 96% rename from src/gpu/shader.h rename to src/lol/gpu/shader.h index cfc42706..99e56e0d 100644 --- a/src/gpu/shader.h +++ b/src/lol/gpu/shader.h @@ -13,8 +13,8 @@ // ---------------- // -#if !defined __LOL_SHADER_H__ -#define __LOL_SHADER_H__ +#if !defined __LOL_GPU_SHADER_H__ +#define __LOL_GPU_SHADER_H__ #include @@ -102,5 +102,5 @@ private: } /* namespace lol */ -#endif // __LOL_SHADER_H__ +#endif // __LOL_GPU_SHADER_H__ diff --git a/src/gpu/texture.h b/src/lol/gpu/texture.h similarity index 91% rename from src/gpu/texture.h rename to src/lol/gpu/texture.h index 1846f509..8dc9df53 100644 --- a/src/gpu/texture.h +++ b/src/lol/gpu/texture.h @@ -13,8 +13,8 @@ // ----------------- // -#if !defined __LOL_TEXTURE_H__ -#define __LOL_TEXTURE_H__ +#if !defined __LOL_GPU_TEXTURE_H__ +#define __LOL_GPU_TEXTURE_H__ namespace lol { @@ -55,5 +55,5 @@ private: } /* namespace lol */ -#endif // __LOL_TEXTURE_H__ +#endif // __LOL_GPU_TEXTURE_H__ diff --git a/src/gpu/vertexbuffer.h b/src/lol/gpu/vertexbuffer.h similarity index 98% rename from src/gpu/vertexbuffer.h rename to src/lol/gpu/vertexbuffer.h index 88e5a379..66a50f4d 100644 --- a/src/gpu/vertexbuffer.h +++ b/src/lol/gpu/vertexbuffer.h @@ -13,8 +13,8 @@ // ---------------------------------------------- // -#if !defined __LOL_VERTEXBUFFER_H__ -#define __LOL_VERTEXBUFFER_H__ +#if !defined __LOL_GPU_VERTEXBUFFER_H__ +#define __LOL_GPU_VERTEXBUFFER_H__ #include @@ -222,5 +222,5 @@ private: } /* namespace lol */ -#endif // __LOL_VERTEXBUFFER_H__ +#endif // __LOL_GPU_VERTEXBUFFER_H__ diff --git a/src/lol/image/image.h b/src/lol/image/image.h new file mode 100644 index 00000000..fb4f1e8f --- /dev/null +++ b/src/lol/image/image.h @@ -0,0 +1,17 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2013 Sam Hocevar +// 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://www.wtfpl.net/ for more details. +// + +#if !defined __LOL_IMAGE_IMAGE_H__ +#define __LOL_IMAGE_IMAGE_H__ + +#include + +#endif // __LOL_IMAGE_IMAGE_H__ + diff --git a/src/lol/math/functions.h b/src/lol/math/functions.h new file mode 100644 index 00000000..d3780479 --- /dev/null +++ b/src/lol/math/functions.h @@ -0,0 +1,177 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2013 Sam Hocevar +// Copyright: (c) 2012-2013 Benjamin "Touky" Huet +// 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://www.wtfpl.net/ for more details. +// + +// +// Various maths functions +// ----------------------- +// + +#if !defined __LOL_MATH_FUNCTIONS_H__ +#define __LOL_MATH_FUNCTIONS_H__ + +#include +#include +#include + +#include + +namespace lol +{ + +/* This is OUR namespace. Don't let Windows headers fuck with it. */ +#undef min +#undef max + +/* Standard cmath functions */ +static inline double sqrt(double const &x) { return std::sqrt(x); } +static inline float sqrt(float const &x) { return std::sqrt(x); } + +static inline double exp(double const &x) { return std::exp(x); } +static inline float exp(float const &x) { return std::exp(x); } + +static inline double sin(double const &x) { return std::sin(x); } +static inline double cos(double const &x) { return std::cos(x); } +static inline double tan(double const &x) { return std::tan(x); } +static inline float sin(float const &x) { return std::sin(x); } +static inline float cos(float const &x) { return std::cos(x); } +static inline float tan(float const &x) { return std::tan(x); } + +static inline double asin(double const &x) { return std::asin(x); } +static inline double acos(double const &x) { return std::acos(x); } +static inline double atan(double const &x) { return std::atan(x); } +static inline float asin(float const &x) { return std::asin(x); } +static inline float acos(float const &x) { return std::acos(x); } +static inline float atan(float const &x) { return std::atan(x); } + +static inline double atan2(double const &y, double const &x) +{ + return std::atan2(y, x); +} + +static inline float atan2(float const &y, float const &x) +{ + return std::atan2(y, x); +} + +static inline double pow(double const &x, double const &y) +{ + return std::pow(x, y); +} + +static inline float pow(float const &x, float const &y) +{ + return std::pow(x, y); +} + +/* Our extensions */ +static inline void sincos(double const &x, double *s, double *c) +{ + *s = std::sin(x); + *c = std::cos(x); +} + +static inline void sincos(float const &x, float *s, float *c) +{ + *s = std::sin(x); + *c = std::cos(x); +} + +static inline float lerp(float const &a, float const &b, float const &x) +{ + return a + (b - a) * x; +} + +static inline double lerp(double const &a, double const &b, double const &x) +{ + return a + (b - a) * x; +} + +static inline ldouble lerp(ldouble const &a, ldouble const &b, ldouble const &x) +{ + return a + (b - a) * x; +} + + +/* These accelerated functions will be merged into the above, one day */ +double lol_sin(double); +double lol_cos(double); +double lol_tan(double); +void lol_sincos(double, double*, double*); +void lol_sincos(float, float*, float*); +double lol_asin(double); +double lol_acos(double); +double lol_atan(double); +double lol_atan2(double, double); + +/* C++ doesn't define abs() and fmod() for all types; we add these for + * convenience to avoid adding complexity to vector.h. */ +static inline int8_t abs(int8_t x) { return std::abs(x); } +static inline uint8_t abs(uint8_t x) { return x; } +static inline int16_t abs(int16_t x) { return std::abs(x); } +static inline uint16_t abs(uint16_t x) { return x; } +static inline int32_t abs(int32_t x) { return std::abs(x); } +static inline uint32_t abs(uint32_t x) { return x; } +#if defined __native_client__ +/* The pepper 19 toolchain doesn't provide abs() for long long int. */ +static inline int64_t abs(int64_t x) { return x > 0 ? x : -x; } +#else +static inline int64_t abs(int64_t x) { return std::abs(x); } +#endif +static inline uint64_t abs(uint64_t x) { return x; } +static inline float abs(float x) { return std::abs(x); } +static inline double abs(double x) { return std::abs(x); } +static inline ldouble abs(ldouble x) { return std::abs(x); } + +static inline uint8_t fmod(uint8_t x, uint8_t y) { return x % y; } +static inline int8_t fmod(int8_t x, int8_t y) { return x % y; } +static inline uint16_t fmod(uint16_t x, uint16_t y) { return x % y; } +static inline int16_t fmod(int16_t x, int16_t y) { return x % y; } +static inline uint32_t fmod(uint32_t x, uint32_t y) { return x % y; } +static inline int32_t fmod(int32_t x, int32_t y) { return x % y; } +static inline uint64_t fmod(uint64_t x, uint64_t y) { return x % y; } +static inline int64_t fmod(int64_t x, int64_t y) { return x % y; } +static inline float fmod(float x, float y) { return std::fmod(x, y); } +static inline double fmod(double x, double y) { return std::fmod(x, y); } +static inline ldouble fmod(ldouble x, ldouble y) { return std::fmod(x, y); } + +static inline uint8_t fract(uint8_t x) { (void)x; return 0; } +static inline int8_t fract(int8_t x) { (void)x; return 0; } +static inline uint16_t fract(uint16_t x) { (void)x; return 0; } +static inline int16_t fract(int16_t x) { (void)x; return 0; } +static inline uint32_t fract(uint32_t x) { (void)x; return 0; } +static inline int32_t fract(int32_t x) { (void)x; return 0; } +static inline uint64_t fract(uint64_t x) { (void)x; return 0; } +static inline int64_t fract(int64_t x) { (void)x; return 0; } +static inline float fract(float x) { return x - std::floor(x); } +static inline double fract(double x) { return x - std::floor(x); } +static inline ldouble fract(ldouble x) { return x - std::floor(x); } + +#define LOL_MIN_MAX_CLAMP(T) \ + static inline T min(T x, T y) { return std::min(x, y); } \ + static inline T max(T x, T y) { return std::max(x, y); } \ + static inline T clamp(T x, T y, T z) { return min(max(x, y), z); } +LOL_MIN_MAX_CLAMP(uint8_t) +LOL_MIN_MAX_CLAMP(int8_t) +LOL_MIN_MAX_CLAMP(uint16_t) +LOL_MIN_MAX_CLAMP(int16_t) +LOL_MIN_MAX_CLAMP(uint32_t) +LOL_MIN_MAX_CLAMP(int32_t) +LOL_MIN_MAX_CLAMP(uint64_t) +LOL_MIN_MAX_CLAMP(int64_t) +LOL_MIN_MAX_CLAMP(float) +LOL_MIN_MAX_CLAMP(double) +LOL_MIN_MAX_CLAMP(ldouble) +#undef LOL_CLAMP + +} /* namespace lol */ + +#endif // __LOL_MATH_FUNCTIONS_H__ + diff --git a/src/lol/math/geometry.h b/src/lol/math/geometry.h index 50eff445..61f172ee 100644 --- a/src/lol/math/geometry.h +++ b/src/lol/math/geometry.h @@ -11,11 +11,11 @@ // // Various geometry functions -// ----------------------- +// -------------------------- // -#if !defined __LOL_GEOMETRY_GEOMETRY_H__ -#define __LOL_GEOMETRY_GEOMETRY_H__ +#if !defined __LOL_MATH_GEOMETRY_H__ +#define __LOL_MATH_GEOMETRY_H__ #include #include @@ -51,5 +51,5 @@ namespace lol } /* namespace lol */ -#endif // __LOL_GEOMETRY_GEOMETRY_H__ +#endif // __LOL_MATH_GEOMETRY_H__ diff --git a/src/lol/math/half.h b/src/lol/math/half.h index b554e190..08a6f3f6 100644 --- a/src/lol/math/half.h +++ b/src/lol/math/half.h @@ -13,8 +13,8 @@ // -------------- // -#if !defined __LOL_HALF_H__ -#define __LOL_HALF_H__ +#if !defined __LOL_MATH_HALF_H__ +#define __LOL_MATH_HALF_H__ #include #include @@ -181,5 +181,5 @@ DECLARE_COERCE_FROM_HALF_OPS(long double) } /* namespace lol */ -#endif // __LOL_HALF_H__ +#endif // __LOL_MATH_HALF_H__ diff --git a/src/lol/math/math.h b/src/lol/math/math.h index 9fd03748..9128d64b 100644 --- a/src/lol/math/math.h +++ b/src/lol/math/math.h @@ -2,176 +2,20 @@ // Lol Engine // // Copyright: (c) 2010-2013 Sam Hocevar -// Copyright: (c) 2012-2013 Benjamin "Touky" Huet // 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://www.wtfpl.net/ for more details. // -// -// Various maths functions -// ----------------------- -// - #if !defined __LOL_MATH_MATH_H__ #define __LOL_MATH_MATH_H__ -#include -#include -#include - -#include - -namespace lol -{ - -/* This is OUR namespace. Don't let Windows headers fuck with it. */ -#undef min -#undef max - -/* Standard cmath functions */ -static inline double sqrt(double const &x) { return std::sqrt(x); } -static inline float sqrt(float const &x) { return std::sqrt(x); } - -static inline double exp(double const &x) { return std::exp(x); } -static inline float exp(float const &x) { return std::exp(x); } - -static inline double sin(double const &x) { return std::sin(x); } -static inline double cos(double const &x) { return std::cos(x); } -static inline double tan(double const &x) { return std::tan(x); } -static inline float sin(float const &x) { return std::sin(x); } -static inline float cos(float const &x) { return std::cos(x); } -static inline float tan(float const &x) { return std::tan(x); } - -static inline double asin(double const &x) { return std::asin(x); } -static inline double acos(double const &x) { return std::acos(x); } -static inline double atan(double const &x) { return std::atan(x); } -static inline float asin(float const &x) { return std::asin(x); } -static inline float acos(float const &x) { return std::acos(x); } -static inline float atan(float const &x) { return std::atan(x); } - -static inline double atan2(double const &y, double const &x) -{ - return std::atan2(y, x); -} - -static inline float atan2(float const &y, float const &x) -{ - return std::atan2(y, x); -} - -static inline double pow(double const &x, double const &y) -{ - return std::pow(x, y); -} - -static inline float pow(float const &x, float const &y) -{ - return std::pow(x, y); -} - -/* Our extensions */ -static inline void sincos(double const &x, double *s, double *c) -{ - *s = std::sin(x); - *c = std::cos(x); -} - -static inline void sincos(float const &x, float *s, float *c) -{ - *s = std::sin(x); - *c = std::cos(x); -} - -static inline float lerp(float const &a, float const &b, float const &x) -{ - return a + (b - a) * x; -} - -static inline double lerp(double const &a, double const &b, double const &x) -{ - return a + (b - a) * x; -} - -static inline ldouble lerp(ldouble const &a, ldouble const &b, ldouble const &x) -{ - return a + (b - a) * x; -} - - -/* These accelerated functions will be merged into the above, one day */ -double lol_sin(double); -double lol_cos(double); -double lol_tan(double); -void lol_sincos(double, double*, double*); -void lol_sincos(float, float*, float*); -double lol_asin(double); -double lol_acos(double); -double lol_atan(double); -double lol_atan2(double, double); - -/* C++ doesn't define abs() and fmod() for all types; we add these for - * convenience to avoid adding complexity to vector.h. */ -static inline int8_t abs(int8_t x) { return std::abs(x); } -static inline uint8_t abs(uint8_t x) { return x; } -static inline int16_t abs(int16_t x) { return std::abs(x); } -static inline uint16_t abs(uint16_t x) { return x; } -static inline int32_t abs(int32_t x) { return std::abs(x); } -static inline uint32_t abs(uint32_t x) { return x; } -#if defined __native_client__ -/* The pepper 19 toolchain doesn't provide abs() for long long int. */ -static inline int64_t abs(int64_t x) { return x > 0 ? x : -x; } -#else -static inline int64_t abs(int64_t x) { return std::abs(x); } -#endif -static inline uint64_t abs(uint64_t x) { return x; } -static inline float abs(float x) { return std::abs(x); } -static inline double abs(double x) { return std::abs(x); } -static inline ldouble abs(ldouble x) { return std::abs(x); } - -static inline uint8_t fmod(uint8_t x, uint8_t y) { return x % y; } -static inline int8_t fmod(int8_t x, int8_t y) { return x % y; } -static inline uint16_t fmod(uint16_t x, uint16_t y) { return x % y; } -static inline int16_t fmod(int16_t x, int16_t y) { return x % y; } -static inline uint32_t fmod(uint32_t x, uint32_t y) { return x % y; } -static inline int32_t fmod(int32_t x, int32_t y) { return x % y; } -static inline uint64_t fmod(uint64_t x, uint64_t y) { return x % y; } -static inline int64_t fmod(int64_t x, int64_t y) { return x % y; } -static inline float fmod(float x, float y) { return std::fmod(x, y); } -static inline double fmod(double x, double y) { return std::fmod(x, y); } -static inline ldouble fmod(ldouble x, ldouble y) { return std::fmod(x, y); } - -static inline uint8_t fract(uint8_t x) { (void)x; return 0; } -static inline int8_t fract(int8_t x) { (void)x; return 0; } -static inline uint16_t fract(uint16_t x) { (void)x; return 0; } -static inline int16_t fract(int16_t x) { (void)x; return 0; } -static inline uint32_t fract(uint32_t x) { (void)x; return 0; } -static inline int32_t fract(int32_t x) { (void)x; return 0; } -static inline uint64_t fract(uint64_t x) { (void)x; return 0; } -static inline int64_t fract(int64_t x) { (void)x; return 0; } -static inline float fract(float x) { return x - std::floor(x); } -static inline double fract(double x) { return x - std::floor(x); } -static inline ldouble fract(ldouble x) { return x - std::floor(x); } - -#define LOL_MIN_MAX_CLAMP(T) \ - static inline T min(T x, T y) { return std::min(x, y); } \ - static inline T max(T x, T y) { return std::max(x, y); } \ - static inline T clamp(T x, T y, T z) { return min(max(x, y), z); } -LOL_MIN_MAX_CLAMP(uint8_t) -LOL_MIN_MAX_CLAMP(int8_t) -LOL_MIN_MAX_CLAMP(uint16_t) -LOL_MIN_MAX_CLAMP(int16_t) -LOL_MIN_MAX_CLAMP(uint32_t) -LOL_MIN_MAX_CLAMP(int32_t) -LOL_MIN_MAX_CLAMP(uint64_t) -LOL_MIN_MAX_CLAMP(int64_t) -LOL_MIN_MAX_CLAMP(float) -LOL_MIN_MAX_CLAMP(double) -LOL_MIN_MAX_CLAMP(ldouble) -#undef LOL_CLAMP - -} /* namespace lol */ +#include +#include +#include +#include +#include #endif // __LOL_MATH_MATH_H__ diff --git a/src/lol/sys/sys.h b/src/lol/sys/sys.h new file mode 100644 index 00000000..95444a06 --- /dev/null +++ b/src/lol/sys/sys.h @@ -0,0 +1,19 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2013 Sam Hocevar +// 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://www.wtfpl.net/ for more details. +// + +#if !defined __LOL_SYS_SYS_H__ +#define __LOL_SYS_SYS_H__ + +#include +#include +#include + +#endif // __LOL_SYS_SYS_H__ + diff --git a/src/lol/sys/thread.h b/src/lol/sys/thread.h index 7e4d4a0a..b95b4314 100644 --- a/src/lol/sys/thread.h +++ b/src/lol/sys/thread.h @@ -13,8 +13,8 @@ // --------------------- // -#if !defined __LOL_THREAD_H__ -#define __LOL_THREAD_H__ +#if !defined __LOL_SYS_THREAD_H__ +#define __LOL_SYS_THREAD_H__ #if defined __CELLOS_LV2__ # include "platform/ps3/threadbase.h" @@ -46,5 +46,5 @@ public: } /* namespace lol */ -#endif // __LOL_THREAD_H__ +#endif // __LOL_SYS_THREAD_H__ diff --git a/src/lolcore.vcxproj b/src/lolcore.vcxproj index c8684da2..8640883d 100644 --- a/src/lolcore.vcxproj +++ b/src/lolcore.vcxproj @@ -570,13 +570,7 @@ - - - - - - @@ -589,12 +583,22 @@ + + + + + + + + + + @@ -602,6 +606,7 @@ +