From 39cf4176915658d7f93fd7ecce5ac6513f1e5568 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 31 Mar 2013 01:16:13 +0100 Subject: [PATCH] Added initial implementation for forward declarations: int and float scalar types, #56 --- glm/core/_detail.hpp | 358 +------------------------------ glm/core/func_packing.hpp | 2 +- glm/core/setup.hpp | 54 ++++- glm/core/type.hpp | 52 +++-- glm/core/type_float.hpp | 78 ++++++- glm/core/type_gentype.hpp | 56 ++++- glm/core/type_half.hpp | 1 - glm/core/type_half.inl | 10 +- glm/core/type_int.hpp | 172 +++++++++++++-- glm/core/type_mat.hpp | 21 +- glm/core/type_vec.hpp | 21 +- glm/fwd.hpp | 58 +++++ glm/glm.hpp | 25 ++- glm/gtx/matrix_interpolation.hpp | 2 +- test/core/core_setup_message.cpp | 8 + test/gtc/gtc_random.cpp | 7 +- 16 files changed, 504 insertions(+), 421 deletions(-) create mode 100644 glm/fwd.hpp diff --git a/glm/core/_detail.hpp b/glm/core/_detail.hpp index 599e4b12..16e4ba02 100644 --- a/glm/core/_detail.hpp +++ b/glm/core/_detail.hpp @@ -28,56 +28,12 @@ #ifndef glm_core_detail #define glm_core_detail - +/* #include "setup.hpp" -#include -#if(((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) -//#if((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) -#include -#endif namespace glm{ namespace detail { -# if((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) - typedef std::int8_t int8; - typedef std::int16_t int16; - typedef std::int32_t int32; - typedef std::int64_t int64; - - typedef std::uint8_t uint8; - typedef std::uint16_t uint16; - typedef std::uint32_t uint32; - typedef std::uint64_t uint64; -# else -# if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available - typedef int64_t sint64; - typedef uint64_t uint64; -# elif(GLM_COMPILER & GLM_COMPILER_VC) - typedef signed __int64 sint64; - typedef unsigned __int64 uint64; -# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC | GLM_COMPILER_CLANG)) - __extension__ typedef signed long long sint64; - __extension__ typedef unsigned long long uint64; -# elif(GLM_COMPILER & GLM_COMPILER_BC) - typedef Int64 sint64; - typedef Uint64 uint64; -# else//unknown compiler - typedef signed long long sint64; - typedef unsigned long long uint64; -# endif//GLM_COMPILER - - typedef signed char int8; - typedef signed short int16; - typedef signed int int32; - typedef sint64 int64; - - typedef unsigned char uint8; - typedef unsigned short uint16; - typedef unsigned int uint32; - typedef uint64 uint64; -#endif// - template struct If { @@ -97,318 +53,8 @@ namespace detail return val; } }; - - //template - //struct traits - //{ - // static const bool is_signed = false; - // static const bool is_float = false; - // static const bool is_vector = false; - // static const bool is_matrix = false; - // static const bool is_genType = false; - // static const bool is_genIType = false; - // static const bool is_genUType = false; - //}; - - //template <> - //struct traits - //{ - // static const bool is_float = true; - // static const bool is_genType = true; - //}; - - //template <> - //struct traits - //{ - // static const bool is_float = true; - // static const bool is_genType = true; - //}; - - //template <> - //struct traits - //{ - // static const bool is_float = true; - // static const bool is_genType = true; - //}; - - //template - //struct desc - //{ - // typedef genType type; - // typedef genType * pointer; - // typedef genType const* const_pointer; - // typedef genType const *const const_pointer_const; - // typedef genType *const pointer_const; - // typedef genType & reference; - // typedef genType const& const_reference; - // typedef genType const& param_type; - - // typedef typename genType::value_type value_type; - // typedef typename genType::size_type size_type; - // static const typename size_type value_size; - //}; - - //template - //const typename desc::size_type desc::value_size = genType::value_size(); - - union uif32 - { - GLM_FUNC_QUALIFIER uif32() : - i(0) - {} - - GLM_FUNC_QUALIFIER uif32(float f) : - f(f) - {} - - GLM_FUNC_QUALIFIER uif32(unsigned int i) : - i(i) - {} - - float f; - unsigned int i; - }; - - union uif64 - { - GLM_FUNC_QUALIFIER uif64() : - i(0) - {} - - GLM_FUNC_QUALIFIER uif64(double f) : - f(f) - {} - - GLM_FUNC_QUALIFIER uif64(uint64 i) : - i(i) - {} - - double f; - uint64 i; - }; - - typedef uif32 uif; - - ////////////////// - // int - - template - struct is_int - { - enum is_int_enum - { - _YES = 0, - _NO = 1 - }; - }; - -#define GLM_DETAIL_IS_INT(T) \ - template <> \ - struct is_int \ - { \ - enum is_int_enum \ - { \ - _YES = 1, \ - _NO = 0 \ - }; \ - } - - ////////////////// - // uint - - template - struct is_uint - { - enum is_uint_enum - { - _YES = 0, - _NO = 1 - }; - }; - -#define GLM_DETAIL_IS_UINT(T) \ - template <> \ - struct is_uint \ - { \ - enum is_uint_enum \ - { \ - _YES = 1, \ - _NO = 0 \ - }; \ - } - - //GLM_DETAIL_IS_UINT(unsigned long long) - - ////////////////// - // float - - template - struct is_float - { - enum is_float_enum - { - _YES = 0, - _NO = 1 - }; - }; - -#define GLM_DETAIL_IS_FLOAT(T) \ - template <> \ - struct is_float \ - { \ - enum is_float_enum \ - { \ - _YES = 1, \ - _NO = 0 \ - }; \ - } - - ////////////////// - // bool - - template - struct is_bool - { - enum is_bool_enum - { - _YES = 0, - _NO = 1 - }; - }; - - template <> - struct is_bool - { - enum is_bool_enum - { - _YES = 1, - _NO = 0 - }; - }; - - ////////////////// - // vector - - template - struct is_vector - { - enum is_vector_enum - { - _YES = 0, - _NO = 1 - }; - }; - -# define GLM_DETAIL_IS_VECTOR(TYPE) \ - template \ - struct is_vector > \ - { \ - enum is_vector_enum \ - { \ - _YES = 1, \ - _NO = 0 \ - }; \ - } - - ////////////////// - // matrix - - template - struct is_matrix - { - enum is_matrix_enum - { - _YES = 0, - _NO = 1 - }; - }; - -#define GLM_DETAIL_IS_MATRIX(T) \ - template <> \ - struct is_matrix \ - { \ - enum is_matrix_enum \ - { \ - _YES = 1, \ - _NO = 0 \ - }; \ - } - - ////////////////// - // type - - template - struct type - { - enum type_enum - { - is_float = is_float::_YES, - is_int = is_int::_YES, - is_uint = is_uint::_YES, - is_bool = is_bool::_YES - }; - }; - ////////////////// - // float_or_int_trait - - struct float_or_int_value - { - enum - { - GLM_ERROR, - GLM_FLOAT, - GLM_INT - }; - }; - - template - struct float_or_int_trait - { - enum{ID = float_or_int_value::GLM_ERROR}; - }; }//namespace detail }//namespace glm - -#if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005)) -# define GLM_DEPRECATED __declspec(deprecated) -# define GLM_ALIGN(x) __declspec(align(x)) -# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct -# define GLM_RESTRICT __declspec(restrict) -# define GLM_RESTRICT_VAR __restrict -# define GLM_CONSTEXPR -#elif(GLM_COMPILER & GLM_COMPILER_INTEL) -# define GLM_DEPRECATED -# define GLM_ALIGN(x) __declspec(align(x)) -# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct -# define GLM_RESTRICT -# define GLM_RESTRICT_VAR __restrict -# define GLM_CONSTEXPR -#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG)) -# define GLM_DEPRECATED __attribute__((__deprecated__)) -# define GLM_ALIGN(x) __attribute__((aligned(x))) -# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x))) -# if(GLM_COMPILER >= GLM_COMPILER_GCC33) -# define GLM_RESTRICT __restrict__ -# define GLM_RESTRICT_VAR __restrict__ -# else -# define GLM_RESTRICT -# define GLM_RESTRICT_VAR -# endif -# define GLM_RESTRICT __restrict__ -# define GLM_RESTRICT_VAR __restrict__ -# if((GLM_COMPILER >= GLM_COMPILER_GCC47) && ((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X)) -# define GLM_CONSTEXPR constexpr -# else -# define GLM_CONSTEXPR -# endif -#else -# define GLM_DEPRECATED -# define GLM_ALIGN -# define GLM_ALIGNED_STRUCT(x) -# define GLM_RESTRICT -# define GLM_RESTRICT_VAR -# define GLM_CONSTEXPR -#endif//GLM_COMPILER - +*/ #endif//glm_core_detail diff --git a/glm/core/func_packing.hpp b/glm/core/func_packing.hpp index 2f68ca2e..7f32ebbc 100644 --- a/glm/core/func_packing.hpp +++ b/glm/core/func_packing.hpp @@ -172,7 +172,7 @@ namespace glm /// /// @see GLSL packHalf2x16 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - uint packHalf2x16(vec2 const & v); + uint packHalf2x16(detail::tvec2 const & v); /// Returns a two-component floating-point vector with components obtained by unpacking a 32-bit unsigned integer into a pair of 16-bit values, /// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification, diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 0a838e55..91188b0d 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -22,12 +22,14 @@ /// /// @ref core /// @file glm/core/setup.hpp -/// @date 2006-11-13 / 2011-06-15 +/// @date 2006-11-13 / 2013-03-30 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_setup -#define glm_setup +#ifndef GLM_SETUP_INCLUDED +#define GLM_SETUP_INCLUDED + +#include /////////////////////////////////////////////////////////////////////////////////////////////////// // Version @@ -726,4 +728,48 @@ # endif #endif//GLM_MESSAGE -#endif//glm_setup +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Qualifiers + +#if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005)) +# define GLM_DEPRECATED __declspec(deprecated) +# define GLM_ALIGN(x) __declspec(align(x)) +# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct +# define GLM_RESTRICT __declspec(restrict) +# define GLM_RESTRICT_VAR __restrict +# define GLM_CONSTEXPR +#elif(GLM_COMPILER & GLM_COMPILER_INTEL) +# define GLM_DEPRECATED +# define GLM_ALIGN(x) __declspec(align(x)) +# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct +# define GLM_RESTRICT +# define GLM_RESTRICT_VAR __restrict +# define GLM_CONSTEXPR +#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG)) +# define GLM_DEPRECATED __attribute__((__deprecated__)) +# define GLM_ALIGN(x) __attribute__((aligned(x))) +# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x))) +# if(GLM_COMPILER >= GLM_COMPILER_GCC33) +# define GLM_RESTRICT __restrict__ +# define GLM_RESTRICT_VAR __restrict__ +# else +# define GLM_RESTRICT +# define GLM_RESTRICT_VAR +# endif +# define GLM_RESTRICT __restrict__ +# define GLM_RESTRICT_VAR __restrict__ +# if((GLM_COMPILER >= GLM_COMPILER_GCC47) && ((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X)) +# define GLM_CONSTEXPR constexpr +# else +# define GLM_CONSTEXPR +# endif +#else +# define GLM_DEPRECATED +# define GLM_ALIGN +# define GLM_ALIGNED_STRUCT(x) +# define GLM_RESTRICT +# define GLM_RESTRICT_VAR +# define GLM_CONSTEXPR +#endif//GLM_COMPILER + +#endif//GLM_SETUP_INCLUDED diff --git a/glm/core/type.hpp b/glm/core/type.hpp index 6361e2e5..c5ddee6d 100644 --- a/glm/core/type.hpp +++ b/glm/core/type.hpp @@ -33,8 +33,6 @@ #include "type_float.hpp" #include "type_int.hpp" -#include "type_gentype.hpp" - #include "type_vec1.hpp" #include "type_vec2.hpp" #include "type_vec3.hpp" @@ -177,7 +175,7 @@ namespace glm ////////////////////////// // Signed integer definition - + #if(defined(GLM_PRECISION_HIGHP_INT)) typedef highp_ivec2 ivec2; typedef highp_ivec3 ivec3; @@ -191,25 +189,25 @@ namespace glm typedef lowp_ivec3 ivec3; typedef lowp_ivec4 ivec4; #else - //! 2 components vector of signed integer numbers. - /// + //! 2 components vector of signed integer numbers. + /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors typedef mediump_ivec2 ivec2; - - //! 3 components vector of signed integer numbers. - /// + + //! 3 components vector of signed integer numbers. + /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors typedef mediump_ivec3 ivec3; - - //! 4 components vector of signed integer numbers. - /// + + //! 4 components vector of signed integer numbers. + /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors typedef mediump_ivec4 ivec4; #endif//GLM_PRECISION - + ////////////////////////// // Unsigned integer definition - + #if(defined(GLM_PRECISION_HIGHP_UINT)) typedef highp_uvec2 uvec2; typedef highp_uvec3 uvec3; @@ -223,22 +221,22 @@ namespace glm typedef lowp_uvec3 uvec3; typedef lowp_uvec4 uvec4; #else - //! 2 components vector of unsigned integer numbers. - /// + /// 2 components vector of unsigned integer numbers. + /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors typedef mediump_uvec2 uvec2; - - //! 3 components vector of unsigned integer numbers. - /// + + /// 3 components vector of unsigned integer numbers. + /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors typedef mediump_uvec3 uvec3; - - //! 4 components vector of unsigned integer numbers. - /// + + /// 4 components vector of unsigned integer numbers. + /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors typedef mediump_uvec4 uvec4; #endif//GLM_PRECISION - + ////////////////////////// // Boolean definition @@ -310,27 +308,27 @@ namespace glm /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices typedef detail::tmat3x2 dmat3x2; - //! 3 * 3 matrix of double-precision floating-point numbers. + /// 3 * 3 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices typedef detail::tmat3x3 dmat3x3; - //! 3 * 4 matrix of double-precision floating-point numbers. + /// 3 * 4 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices typedef detail::tmat3x4 dmat3x4; - //! 4 * 2 matrix of double-precision floating-point numbers. + /// 4 * 2 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices typedef detail::tmat4x2 dmat4x2; - //! 4 * 3 matrix of double-precision floating-point numbers. + /// 4 * 3 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices typedef detail::tmat4x3 dmat4x3; - //! 4 * 4 matrix of double-precision floating-point numbers. + /// 4 * 4 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices typedef detail::tmat4x4 dmat4x4; diff --git a/glm/core/type_float.hpp b/glm/core/type_float.hpp index afdef964..af954270 100644 --- a/glm/core/type_float.hpp +++ b/glm/core/type_float.hpp @@ -29,12 +29,13 @@ #ifndef glm_core_type_float #define glm_core_type_float -#include "type_half.hpp" #include "setup.hpp" namespace glm{ namespace detail { + class half; + typedef detail::half float16; typedef float float32; typedef double float64; @@ -100,6 +101,30 @@ namespace detail namespace detail { + ////////////////// + // float + + template + struct is_float + { + enum is_float_enum + { + _YES = 0, + _NO = 1 + }; + }; + + #define GLM_DETAIL_IS_FLOAT(T) \ + template <> \ + struct is_float \ + { \ + enum is_float_enum \ + { \ + _YES = 1, \ + _NO = 0 \ + }; \ + } + //////////////////// // Mark half to be flaot GLM_DETAIL_IS_FLOAT(detail::half); @@ -124,6 +149,57 @@ namespace detail { enum{ID = float_or_int_value::GLM_FLOAT}; }; + + union uif32 + { + GLM_FUNC_QUALIFIER uif32() : + i(0) + {} + + GLM_FUNC_QUALIFIER uif32(float f) : + f(f) + {} + + GLM_FUNC_QUALIFIER uif32(uint32 i) : + i(i) + {} + + float f; + uint32 i; + }; + + union uif64 + { + GLM_FUNC_QUALIFIER uif64() : + i(0) + {} + + GLM_FUNC_QUALIFIER uif64(double f) : + f(f) + {} + + GLM_FUNC_QUALIFIER uif64(uint64 i) : + i(i) + {} + + double f; + uint64 i; + }; + + ////////////////// + // type + + template + struct type + { + enum type_enum + { + is_float = is_float::_YES, + is_int = is_int::_YES, + is_uint = is_uint::_YES, + is_bool = is_bool::_YES + }; + }; }//namespace detail }//namespace glm diff --git a/glm/core/type_gentype.hpp b/glm/core/type_gentype.hpp index c79152a9..98952423 100644 --- a/glm/core/type_gentype.hpp +++ b/glm/core/type_gentype.hpp @@ -161,7 +161,61 @@ namespace detail class_type& operator-- (); }; */ - }//namespace detail + + //template + //struct traits + //{ + // static const bool is_signed = false; + // static const bool is_float = false; + // static const bool is_vector = false; + // static const bool is_matrix = false; + // static const bool is_genType = false; + // static const bool is_genIType = false; + // static const bool is_genUType = false; + //}; + + //template <> + //struct traits + //{ + // static const bool is_float = true; + // static const bool is_genType = true; + //}; + + //template <> + //struct traits + //{ + // static const bool is_float = true; + // static const bool is_genType = true; + //}; + + //template <> + //struct traits + //{ + // static const bool is_float = true; + // static const bool is_genType = true; + //}; + + //template + //struct desc + //{ + // typedef genType type; + // typedef genType * pointer; + // typedef genType const* const_pointer; + // typedef genType const *const const_pointer_const; + // typedef genType *const pointer_const; + // typedef genType & reference; + // typedef genType const& const_reference; + // typedef genType const& param_type; + + // typedef typename genType::value_type value_type; + // typedef typename genType::size_type size_type; + // static const typename size_type value_size; + //}; + + //template + //const typename desc::size_type desc::value_size = genType::value_size(); + +}//namespace detail }//namespace glm //#include "type_gentype.inl" diff --git a/glm/core/type_half.hpp b/glm/core/type_half.hpp index 13a15961..d0b94cca 100644 --- a/glm/core/type_half.hpp +++ b/glm/core/type_half.hpp @@ -29,7 +29,6 @@ #ifndef glm_core_type_half #define glm_core_type_half -#include #include "_detail.hpp" namespace glm{ diff --git a/glm/core/type_half.inl b/glm/core/type_half.inl index aa465b02..d1fba6e7 100644 --- a/glm/core/type_half.inl +++ b/glm/core/type_half.inl @@ -57,7 +57,7 @@ namespace detail // Plus or minus zero // - detail::uif result; + detail::uif32 result; result.i = (unsigned int)(s << 31); return result.f; } @@ -85,7 +85,7 @@ namespace detail // Positive or negative infinity // - uif result; + uif32 result; result.i = (unsigned int)((s << 31) | 0x7f800000); return result.f; } @@ -95,7 +95,7 @@ namespace detail // Nan -- preserve sign and significand bits // - uif result; + uif32 result; result.i = (unsigned int)((s << 31) | 0x7f800000 | (m << 13)); return result.f; } @@ -112,14 +112,14 @@ namespace detail // Assemble s, e and m. // - uif Result; + uif32 Result; Result.i = (unsigned int)((s << 31) | (e << 23) | m); return Result.f; } GLM_FUNC_QUALIFIER hdata toFloat16(float const & f) { - uif Entry; + uif32 Entry; Entry.f = f; int i = (int)Entry.i; diff --git a/glm/core/type_int.hpp b/glm/core/type_int.hpp index 870dd6a9..16c03f8c 100644 --- a/glm/core/type_int.hpp +++ b/glm/core/type_int.hpp @@ -22,7 +22,7 @@ /// /// @ref core /// @file glm/core/type_int.hpp -/// @date 2008-08-22 / 2011-06-15 +/// @date 2008-08-22 / 2013-03-30 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// @@ -32,27 +32,71 @@ #include "setup.hpp" #include "_detail.hpp" +#if(((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) +//#if((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) +#include +#endif + namespace glm{ namespace detail { +# if((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) + typedef std::int8_t int8; + typedef std::int16_t int16; + typedef std::int32_t int32; + typedef std::int64_t int64; + + typedef std::uint8_t uint8; + typedef std::uint16_t uint16; + typedef std::uint32_t uint32; + typedef std::uint64_t uint64; +# else +# if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available + typedef int64_t sint64; + typedef uint64_t uint64; +# elif(GLM_COMPILER & GLM_COMPILER_VC) + typedef signed __int64 sint64; + typedef unsigned __int64 uint64; +# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC | GLM_COMPILER_CLANG)) + __extension__ typedef signed long long sint64; + __extension__ typedef unsigned long long uint64; +# elif(GLM_COMPILER & GLM_COMPILER_BC) + typedef Int64 sint64; + typedef Uint64 uint64; +# else//unknown compiler + typedef signed long long sint64; + typedef unsigned long long uint64; +# endif//GLM_COMPILER + + typedef signed char int8; + typedef signed short int16; + typedef signed int int32; + typedef sint64 int64; + + typedef unsigned char uint8; + typedef unsigned short uint16; + typedef unsigned int uint32; + typedef uint64 uint64; +#endif// + typedef signed short lowp_int_t; typedef signed int mediump_int_t; typedef int64 highp_int_t; - + typedef unsigned short lowp_uint_t; typedef unsigned int mediump_uint_t; typedef uint64 highp_uint_t; }//namespace detail - typedef detail::int8 int8; - typedef detail::int16 int16; - typedef detail::int32 int32; - typedef detail::int64 int64; + typedef detail::int8 int8; + typedef detail::int16 int16; + typedef detail::int32 int32; + typedef detail::int64 int64; - typedef detail::uint8 uint8; - typedef detail::uint16 uint16; - typedef detail::uint32 uint32; - typedef detail::uint64 uint64; + typedef detail::uint8 uint8; + typedef detail::uint16 uint16; + typedef detail::uint32 uint32; + typedef detail::uint64 uint64; /// @addtogroup core_precision /// @{ @@ -126,7 +170,7 @@ namespace detail /// Unsigned integer type. /// /// @see GLSL 4.20.8 specification, section 4.1.3 Integers - typedef uint_t uint; + typedef uint_t uint; /// @} @@ -146,11 +190,59 @@ namespace detail namespace detail { + ////////////////// + // int + + template + struct is_int + { + enum is_int_enum + { + _YES = 0, + _NO = 1 + }; + }; + + #define GLM_DETAIL_IS_INT(T) \ + template <> \ + struct is_int \ + { \ + enum is_int_enum \ + { \ + _YES = 1, \ + _NO = 0 \ + }; \ + } + GLM_DETAIL_IS_INT(signed char); GLM_DETAIL_IS_INT(signed short); GLM_DETAIL_IS_INT(signed int); GLM_DETAIL_IS_INT(signed long); GLM_DETAIL_IS_INT(highp_int_t); + + ////////////////// + // uint + + template + struct is_uint + { + enum is_uint_enum + { + _YES = 0, + _NO = 1 + }; + }; + + #define GLM_DETAIL_IS_UINT(T) \ + template <> \ + struct is_uint \ + { \ + enum is_uint_enum \ + { \ + _YES = 1, \ + _NO = 0 \ + }; \ + } GLM_DETAIL_IS_UINT(unsigned char); GLM_DETAIL_IS_UINT(unsigned short); @@ -158,50 +250,92 @@ namespace detail GLM_DETAIL_IS_UINT(unsigned long); GLM_DETAIL_IS_UINT(highp_uint_t); + ////////////////// + // bool + + template + struct is_bool + { + enum is_bool_enum + { + _YES = 0, + _NO = 1 + }; + }; + + template <> + struct is_bool + { + enum is_bool_enum + { + _YES = 1, + _NO = 0 + }; + }; + + ////////////////// + // float_or_int_trait + + struct float_or_int_value + { + enum + { + GLM_ERROR, + GLM_FLOAT, + GLM_INT + }; + }; + + template + struct float_or_int_trait + { + enum{ID = float_or_int_value::GLM_ERROR}; + }; + template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; template <> - struct float_or_int_trait + struct float_or_int_trait { enum{ID = float_or_int_value::GLM_INT}; }; diff --git a/glm/core/type_mat.hpp b/glm/core/type_mat.hpp index 1520ad54..e546cd7d 100644 --- a/glm/core/type_mat.hpp +++ b/glm/core/type_mat.hpp @@ -34,7 +34,26 @@ namespace glm{ namespace detail { - + template + struct is_matrix + { + enum is_matrix_enum + { + _YES = 0, + _NO = 1 + }; + }; + + #define GLM_DETAIL_IS_MATRIX(T) \ + template <> \ + struct is_matrix \ + { \ + enum is_matrix_enum \ + { \ + _YES = 1, \ + _NO = 0 \ + }; \ + } }//namespace detail }//namespace glm diff --git a/glm/core/type_vec.hpp b/glm/core/type_vec.hpp index 60e2b705..9f10cab0 100644 --- a/glm/core/type_vec.hpp +++ b/glm/core/type_vec.hpp @@ -34,7 +34,26 @@ namespace glm{ namespace detail { - + template + struct is_vector + { + enum is_vector_enum + { + _YES = 0, + _NO = 1 + }; + }; + +# define GLM_DETAIL_IS_VECTOR(TYPE) \ + template \ + struct is_vector > \ + { \ + enum is_vector_enum \ + { \ + _YES = 1, \ + _NO = 0 \ + }; \ + } }//namespace detail }//namespace glm diff --git a/glm/fwd.hpp b/glm/fwd.hpp new file mode 100644 index 00000000..f2693ce4 --- /dev/null +++ b/glm/fwd.hpp @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/fwd.hpp +/// @date 2013-03-30 / 2013-03-30 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_FWD_INCLUDED +#define GLM_FWD_INCLUDED + +#include "core/type_int.hpp" +#include "core/type_float.hpp" + +namespace glm{ +namespace detail +{ + class half; + + template struct tvec1; + template struct tvec2; + template struct tvec3; + template struct tvec4; + + template struct tmat2x2; + template struct tmat2x3; + template struct tmat2x4; + template struct tmat3x2; + template struct tmat3x3; + template struct tmat3x4; + template struct tmat4x2; + template struct tmat4x3; + template struct tmat4x4; +}//namespace detail + +}//namespace glm + +#endif//GLM_FWD_INCLUDED diff --git a/glm/glm.hpp b/glm/glm.hpp index ec0a55a9..434d3f92 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -84,8 +84,10 @@ #include #include #include -#include +//#include //#include + +#include "fwd.hpp" #include "core/setup.hpp" #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_CORE_INCLUDED_DISPLAYED)) @@ -95,8 +97,28 @@ #include "./core/_detail.hpp" #include "./core/_vectorize.hpp" + +#include "./core/type_half.hpp" +#include "./core/type_float.hpp" +#include "./core/type_int.hpp" + #include "./core/type.hpp" +#include "./core/type_vec1.hpp" +#include "./core/type_vec2.hpp" +#include "./core/type_vec3.hpp" +#include "./core/type_vec4.hpp" + +#include "./core/type_mat2x2.hpp" +#include "./core/type_mat2x3.hpp" +#include "./core/type_mat2x4.hpp" +#include "./core/type_mat3x2.hpp" +#include "./core/type_mat3x3.hpp" +#include "./core/type_mat3x4.hpp" +#include "./core/type_mat4x2.hpp" +#include "./core/type_mat4x3.hpp" +#include "./core/type_mat4x4.hpp" + #include "./core/func_trigonometric.hpp" #include "./core/func_exponential.hpp" #include "./core/func_common.hpp" @@ -106,6 +128,7 @@ #include "./core/func_vector_relational.hpp" #include "./core/func_integer.hpp" #include "./core/func_noise.hpp" + #include "./core/_swizzle.hpp" #endif//glm_glm diff --git a/glm/gtx/matrix_interpolation.hpp b/glm/gtx/matrix_interpolation.hpp index 75f2047e..c863fc5b 100644 --- a/glm/gtx/matrix_interpolation.hpp +++ b/glm/gtx/matrix_interpolation.hpp @@ -39,7 +39,7 @@ #define GLM_GTX_matrix_interpolation GLM_VERSION // Dependency: -//#include "../glm.hpp" +#include "../glm.hpp" #if(defined(GLM_MESSAGES) && !defined(glm_ext)) # pragma message("GLM: GLM_GTX_matrix_interpolation extension included") diff --git a/test/core/core_setup_message.cpp b/test/core/core_setup_message.cpp index 45897887..a9d10a71 100644 --- a/test/core/core_setup_message.cpp +++ b/test/core/core_setup_message.cpp @@ -254,6 +254,13 @@ int test_model() return Error; } +int test_cpp_version() +{ + std::cout << "__cplusplus: " << __cplusplus << std::endl; + + return 0; +} + int test_operators() { glm::vec3 A(1.0f); @@ -268,6 +275,7 @@ int main() { int Error = 0; + Error += test_cpp_version(); Error += test_compiler(); Error += test_model(); Error += test_operators(); diff --git a/test/gtc/gtc_random.cpp b/test/gtc/gtc_random.cpp index 82abd0b9..4985de22 100644 --- a/test/gtc/gtc_random.cpp +++ b/test/gtc/gtc_random.cpp @@ -11,7 +11,7 @@ #include #include #include -#if(GLM_LANG & GLM_LANG_CXX0X) +#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X) # include #endif @@ -139,7 +139,7 @@ int test_ballRand() return Error; } -#if(GLM_LANG & GLM_LANG_CXX0X) +#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X) int test_grid() { int Error = 0; @@ -188,6 +188,9 @@ int main() Error += test_sphericalRand(); Error += test_diskRand(); Error += test_ballRand(); +#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X) + Error += test_grid(); +#endif return Error; }