diff --git a/glm/common.hpp b/glm/common.hpp index 2d787dde..b22e11b0 100644 --- a/glm/common.hpp +++ b/glm/common.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_COMMON_INCLUDED -#define GLM_COMMON_INCLUDED +#pragma once #include "detail/func_common.hpp" - -#endif//GLM_COMMON_INCLUDED diff --git a/glm/detail/_features.hpp b/glm/detail/_features.hpp index 1c7fe8c9..936672fd 100644 --- a/glm/detail/_features.hpp +++ b/glm/detail/_features.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_features -#define glm_core_features +#pragma once // #define GLM_CXX98_EXCEPTIONS // #define GLM_CXX98_RTTI @@ -423,5 +422,3 @@ # endif #endif//(GLM_COMPILER & GLM_COMPILER_CLANG) - -#endif//glm_core_features diff --git a/glm/detail/_literals.hpp b/glm/detail/_literals.hpp index 79780ccf..82220874 100644 --- a/glm/detail/_literals.hpp +++ b/glm/detail/_literals.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_literals -#define glm_core_literals +#pragma once namespace glm { @@ -47,5 +46,3 @@ namespace glm #endif//GLM_CXX11_USER_LITERALS }//namespace glm - -#endif//glm_core_literals diff --git a/glm/detail/_noise.hpp b/glm/detail/_noise.hpp index e366e7c3..583ac0be 100644 --- a/glm/detail/_noise.hpp +++ b/glm/detail/_noise.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_DETAIL_NOISE_INCLUDED -#define GLM_DETAIL_NOISE_INCLUDED +#pragma once namespace glm{ namespace detail @@ -126,5 +125,3 @@ namespace detail }//namespace detail }//namespace glm -#endif//GLM_DETAIL_NOISE_INCLUDED - diff --git a/glm/detail/_swizzle.hpp b/glm/detail/_swizzle.hpp index 407ffb49..ebe37319 100644 --- a/glm/detail/_swizzle.hpp +++ b/glm/detail/_swizzle.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_swizzle -#define glm_core_swizzle +#pragma once namespace glm{ namespace detail @@ -836,5 +835,3 @@ namespace glm struct { _swizzle<4, T, P, V, 3,3,3,1> E3 ## E3 ## E3 ## E1; }; \ struct { _swizzle<4, T, P, V, 3,3,3,2> E3 ## E3 ## E3 ## E2; }; \ struct { _swizzle<4, T, P, V, 3,3,3,3> E3 ## E3 ## E3 ## E3; }; - -#endif//glm_core_swizzle diff --git a/glm/detail/_swizzle_func.hpp b/glm/detail/_swizzle_func.hpp index c287bbf5..a3f6993c 100644 --- a/glm/detail/_swizzle_func.hpp +++ b/glm/detail/_swizzle_func.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_swizzle_func -#define glm_core_swizzle_func +#pragma once #define GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B) \ SWIZZLED_TYPE A ## B() CONST \ @@ -720,5 +719,3 @@ GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t, p, q) //GLM_SWIZZLE_GEN_VEC_FROM_VEC4(valType, detail::vec4, detail::vec2, detail::vec3, detail::vec4) - -#endif//glm_core_swizzle_func diff --git a/glm/detail/_vectorize.hpp b/glm/detail/_vectorize.hpp index b653fa9f..48fe97f3 100644 --- a/glm/detail/_vectorize.hpp +++ b/glm/detail/_vectorize.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_CORE_DETAIL_INCLUDED -#define GLM_CORE_DETAIL_INCLUDED +#pragma once #include "type_vec1.hpp" #include "type_vec2.hpp" @@ -213,5 +212,3 @@ namespace detail }; }//namespace detail }//namespace glm - -#endif//GLM_CORE_DETAIL_INCLUDED diff --git a/glm/detail/dummy.cpp b/glm/detail/dummy.cpp index 98ca022c..69ffa7cf 100644 --- a/glm/detail/dummy.cpp +++ b/glm/detail/dummy.cpp @@ -41,7 +41,8 @@ struct material glm::vec4 diffuse; // Dcm glm::vec4 specular; // Scm float shininess; // Srm -}; +}; + struct light { glm::vec4 ambient; // Acli @@ -58,7 +59,8 @@ struct light float constantAttenuation; // K0 float linearAttenuation; // K1 float quadraticAttenuation;// K2 -}; +}; + // Sample 1 #include // glm::vec3 diff --git a/glm/detail/func_common.hpp b/glm/detail/func_common.hpp index 87734c01..879465d9 100644 --- a/glm/detail/func_common.hpp +++ b/glm/detail/func_common.hpp @@ -33,8 +33,7 @@ /// These all operate component-wise. The description is per component. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_FUNC_COMMON_INCLUDED -#define GLM_FUNC_COMMON_INCLUDED +#pragma once #include "setup.hpp" #include "precision.hpp" @@ -469,4 +468,3 @@ namespace glm #include "func_common.inl" -#endif//GLM_FUNC_COMMON_INCLUDED diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index a788eb4c..4026e0c8 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -716,7 +716,7 @@ namespace detail # if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_INTEL)) return _isnan(x) != 0; # elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) -# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L) return _isnan(x) != 0; # else return std::isnan(x); @@ -787,7 +787,7 @@ namespace detail # if(GLM_COMPILER & (GLM_COMPILER_INTEL | GLM_COMPILER_VC)) return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; # elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) -# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L) return _isinf(x) != 0; # else return std::isinf(x); diff --git a/glm/detail/func_exponential.hpp b/glm/detail/func_exponential.hpp index 93820870..1e1f4418 100644 --- a/glm/detail/func_exponential.hpp +++ b/glm/detail/func_exponential.hpp @@ -33,8 +33,7 @@ /// These all operate component-wise. The description is per component. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_exponential -#define glm_core_func_exponential +#pragma once #include "type_vec1.hpp" #include "type_vec2.hpp" @@ -128,5 +127,3 @@ namespace glm }//namespace glm #include "func_exponential.inl" - -#endif//glm_core_func_exponential diff --git a/glm/detail/func_geometric.hpp b/glm/detail/func_geometric.hpp index 0f83639c..491e867b 100644 --- a/glm/detail/func_geometric.hpp +++ b/glm/detail/func_geometric.hpp @@ -33,8 +33,7 @@ /// These operate on vectors as vectors, not component-wise. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_geometric -#define glm_core_func_geometric +#pragma once #include "type_vec3.hpp" @@ -147,5 +146,3 @@ namespace glm }//namespace glm #include "func_geometric.inl" - -#endif//glm_core_func_geometric diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index 2f8691dd..1e8cd633 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -92,8 +92,7 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length' only accept floating-point inputs"); - genType sqr = x * x; - return sqrt(sqr); + return abs(x); } template diff --git a/glm/detail/func_integer.hpp b/glm/detail/func_integer.hpp index d9fbdfd5..30544947 100644 --- a/glm/detail/func_integer.hpp +++ b/glm/detail/func_integer.hpp @@ -35,8 +35,7 @@ /// b, inclusive. The lowest-order bit is bit 0. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_integer -#define glm_core_func_integer +#pragma once #include "setup.hpp" @@ -198,6 +197,3 @@ namespace glm }//namespace glm #include "func_integer.inl" - -#endif//glm_core_func_integer - diff --git a/glm/detail/func_matrix.hpp b/glm/detail/func_matrix.hpp index 901c196b..f7b392fe 100644 --- a/glm/detail/func_matrix.hpp +++ b/glm/detail/func_matrix.hpp @@ -37,8 +37,7 @@ /// floating point version is shown. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_CORE_func_matrix -#define GLM_CORE_func_matrix +#pragma once // Dependencies #include "../detail/precision.hpp" @@ -175,5 +174,3 @@ namespace detail }//namespace glm #include "func_matrix.inl" - -#endif//GLM_CORE_func_matrix diff --git a/glm/detail/func_noise.hpp b/glm/detail/func_noise.hpp index 7a6ae1c0..f7aca685 100644 --- a/glm/detail/func_noise.hpp +++ b/glm/detail/func_noise.hpp @@ -35,8 +35,7 @@ /// appearance of randomness, but are not truly random. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_noise -#define glm_core_func_noise +#pragma once #include "type_vec1.hpp" #include "type_vec2.hpp" @@ -88,5 +87,3 @@ namespace glm }//namespace glm #include "func_noise.inl" - -#endif//glm_core_func_noise diff --git a/glm/detail/func_packing.hpp b/glm/detail/func_packing.hpp index 454c13ff..98c639e7 100644 --- a/glm/detail/func_packing.hpp +++ b/glm/detail/func_packing.hpp @@ -33,8 +33,7 @@ /// These functions do not operate component-wise, rather as described in each case. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_CORE_func_packing -#define GLM_CORE_func_packing +#pragma once #include "type_vec2.hpp" #include "type_vec4.hpp" @@ -191,5 +190,3 @@ namespace glm }//namespace glm #include "func_packing.inl" - -#endif//GLM_CORE_func_packing diff --git a/glm/detail/func_packing.inl b/glm/detail/func_packing.inl index e5eb0933..60dfc63b 100644 --- a/glm/detail/func_packing.inl +++ b/glm/detail/func_packing.inl @@ -35,7 +35,9 @@ namespace glm GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v) { u16vec2 Topack(round(clamp(v, 0.0f, 1.0f) * 65535.0f)); - return reinterpret_cast(Topack); + // return reinterpret_cast(Topack); + uint* ptr(reinterpret_cast(&Topack)); + return *ptr; } GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint const & p) @@ -47,7 +49,9 @@ namespace glm GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v) { i16vec2 Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f)); - return reinterpret_cast(Topack); + // return reinterpret_cast(Topack); + uint* ptr(reinterpret_cast(&Topack)); + return *ptr; } GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint const & p) diff --git a/glm/detail/func_trigonometric.hpp b/glm/detail/func_trigonometric.hpp index 9c4a7b5d..b3148c14 100644 --- a/glm/detail/func_trigonometric.hpp +++ b/glm/detail/func_trigonometric.hpp @@ -37,8 +37,7 @@ /// These all operate component-wise. The description is per component. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_CORE_func_trigonometric -#define GLM_CORE_func_trigonometric +#pragma once namespace glm { @@ -197,7 +196,3 @@ namespace glm }//namespace glm #include "func_trigonometric.inl" - -#endif//GLM_CORE_func_trigonometric - - diff --git a/glm/detail/func_vector_relational.hpp b/glm/detail/func_vector_relational.hpp index b9139546..94714ab4 100644 --- a/glm/detail/func_vector_relational.hpp +++ b/glm/detail/func_vector_relational.hpp @@ -38,8 +38,7 @@ /// call must match. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_CORE_func_vector_relational -#define GLM_CORE_func_vector_relational +#pragma once #include "precision.hpp" #include "setup.hpp" @@ -141,5 +140,3 @@ namespace glm #endif #include "func_vector_relational.inl" - -#endif//GLM_CORE_func_vector_relational diff --git a/glm/detail/hint.hpp b/glm/detail/hint.hpp index 219f2bd0..2b96c0f6 100644 --- a/glm/detail/hint.hpp +++ b/glm/detail/hint.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type -#define glm_core_type +#pragma once namespace glm { @@ -36,5 +35,3 @@ namespace glm class nicest {}; class fastest {}; }//namespace glm - -#endif//glm_core_type diff --git a/glm/detail/intrinsic_common.hpp b/glm/detail/intrinsic_common.hpp index 378bdd23..405bb59a 100644 --- a/glm/detail/intrinsic_common.hpp +++ b/glm/detail/intrinsic_common.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_detail_intrinsic_common -#define glm_detail_intrinsic_common +#pragma once #include "setup.hpp" @@ -86,4 +85,3 @@ namespace detail #include "intrinsic_common.inl" #endif//GLM_ARCH -#endif//glm_detail_intrinsic_common diff --git a/glm/detail/intrinsic_exponential.hpp b/glm/detail/intrinsic_exponential.hpp index 60a7f628..7194c3cf 100644 --- a/glm/detail/intrinsic_exponential.hpp +++ b/glm/detail/intrinsic_exponential.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_detail_intrinsic_exponential -#define glm_detail_intrinsic_exponential +#pragma once #include "setup.hpp" @@ -76,4 +75,3 @@ GLM_FUNC_QUALIFIER __m128 sse_normalize_fast_ps( float * RESTRICT vOut, float * }//namespace glm #endif//GLM_ARCH -#endif//glm_detail_intrinsic_exponential diff --git a/glm/detail/intrinsic_geometric.hpp b/glm/detail/intrinsic_geometric.hpp index d229dcf9..e2175389 100644 --- a/glm/detail/intrinsic_geometric.hpp +++ b/glm/detail/intrinsic_geometric.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_intrinsic_geometric -#define glm_core_intrinsic_geometric +#pragma once #include "setup.hpp" @@ -73,4 +72,3 @@ namespace detail #include "intrinsic_geometric.inl" #endif//GLM_ARCH -#endif//glm_core_intrinsic_geometric diff --git a/glm/detail/intrinsic_integer.hpp b/glm/detail/intrinsic_integer.hpp index ec25e23c..b542ac4a 100644 --- a/glm/detail/intrinsic_integer.hpp +++ b/glm/detail/intrinsic_integer.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_detail_intrinsic_integer -#define glm_detail_intrinsic_integer +#pragma once #include "glm/glm.hpp" @@ -47,4 +46,3 @@ namespace detail #include "intrinsic_integer.inl" #endif//GLM_ARCH -#endif//glm_detail_intrinsic_integer diff --git a/glm/detail/intrinsic_matrix.hpp b/glm/detail/intrinsic_matrix.hpp index 5cfb7d2f..082f4980 100644 --- a/glm/detail/intrinsic_matrix.hpp +++ b/glm/detail/intrinsic_matrix.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_detail_intrinsic_matrix -#define glm_detail_intrinsic_matrix +#pragma once #include "setup.hpp" @@ -66,4 +65,3 @@ namespace detail #include "intrinsic_matrix.inl" #endif//GLM_ARCH -#endif//glm_detail_intrinsic_matrix diff --git a/glm/detail/intrinsic_trigonometric.hpp b/glm/detail/intrinsic_trigonometric.hpp index 3bb8e672..9176291c 100644 --- a/glm/detail/intrinsic_trigonometric.hpp +++ b/glm/detail/intrinsic_trigonometric.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_detail_intrinsic_trigonometric -#define glm_detail_intrinsic_trigonometric +#pragma once #include "setup.hpp" @@ -45,4 +44,3 @@ namespace detail #include "intrinsic_trigonometric.inl" #endif//GLM_ARCH -#endif//glm_detail_intrinsic_trigonometric diff --git a/glm/detail/intrinsic_vector_relational.hpp b/glm/detail/intrinsic_vector_relational.hpp index 9fcbb55c..af6620d6 100644 --- a/glm/detail/intrinsic_vector_relational.hpp +++ b/glm/detail/intrinsic_vector_relational.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_detail_intrinsic_vector_relational -#define glm_detail_intrinsic_vector_relational +#pragma once #include "setup.hpp" @@ -45,4 +44,3 @@ namespace detail #include "intrinsic_vector_relational.inl" #endif//GLM_ARCH -#endif//glm_detail_intrinsic_vector_relational diff --git a/glm/detail/precision.hpp b/glm/detail/precision.hpp index 983fc8ee..6be15a34 100644 --- a/glm/detail/precision.hpp +++ b/glm/detail/precision.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_CORE_PRECISION_INCLUDED -#define GLM_CORE_PRECISION_INCLUDED +#pragma once namespace glm { @@ -39,5 +38,3 @@ namespace glm defaultp = highp }; }//namespace glm - -#endif//GLM_CORE_PRECISION_INCLUDED diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 34188c66..ed254fb6 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_SETUP_INCLUDED -#define GLM_SETUP_INCLUDED +#pragma once #include @@ -578,16 +577,19 @@ #define GLM_ARCH_PURE 0x0000 #define GLM_ARCH_SSE2 0x0001 -#define GLM_ARCH_SSE3 0x0002// | GLM_ARCH_SSE2 -#define GLM_ARCH_AVX 0x0008// | GLM_ARCH_SSE3 | GLM_ARCH_SSE2 -#define GLM_ARCH_AVX2 0x0010// | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2 +#define GLM_ARCH_SSE3 0x0002 +#define GLM_ARCH_SSE4 0x0004 +#define GLM_ARCH_AVX 0x0008 +#define GLM_ARCH_AVX2 0x0010 #if(defined(GLM_FORCE_PURE)) # define GLM_ARCH GLM_ARCH_PURE #elif(defined(GLM_FORCE_AVX2)) -# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) #elif(defined(GLM_FORCE_AVX)) -# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +#elif(defined(GLM_FORCE_SSE4)) +# define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) #elif(defined(GLM_FORCE_SSE3)) # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) #elif(defined(GLM_FORCE_SSE2)) @@ -606,14 +608,26 @@ # endif #elif(GLM_COMPILER & GLM_COMPILER_VC) # if _M_IX86_FP == 2 && defined(__AVX__) -# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) # elif _M_IX86_FP == 2 # define GLM_ARCH (GLM_ARCH_SSE2) # else # define GLM_ARCH (GLM_ARCH_PURE) # endif -#elif((GLM_PLATFORM & GLM_PLATFORM_APPLE) && (GLM_COMPILER & GLM_COMPILER_GCC)) -# define GLM_ARCH GLM_ARCH_PURE +#elif(((GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__))) || (GLM_COMPILER & GLM_COMPILER_LLVM_GCC) || (GLM_COMPILER & GLM_COMPILER_CLANG)) +# if defined(__AVX2__) +# define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__AVX__) +# define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__SSE4_1__ ) +# define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__SSE3__) +# define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2) +# elif defined(__SSE2__) +# define GLM_ARCH (GLM_ARCH_SSE2) +# else +# define GLM_ARCH (GLM_ARCH_PURE) +# endif #else # define GLM_ARCH GLM_ARCH_PURE #endif @@ -786,5 +800,3 @@ namespace glm #else # define GLM_CONSTEXPR #endif - -#endif//GLM_SETUP_INCLUDED diff --git a/glm/detail/type_float.hpp b/glm/detail/type_float.hpp index 0b93517b..495dbc92 100644 --- a/glm/detail/type_float.hpp +++ b/glm/detail/type_float.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_float -#define glm_core_type_float +#pragma once #include "setup.hpp" @@ -91,5 +90,3 @@ namespace detail /// @} }//namespace glm - -#endif//glm_core_type_float diff --git a/glm/detail/type_gentype.hpp b/glm/detail/type_gentype.hpp index f3571f5d..59882e4c 100644 --- a/glm/detail/type_gentype.hpp +++ b/glm/detail/type_gentype.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_gentype -#define glm_core_type_gentype +#pragma once namespace glm { @@ -219,5 +218,3 @@ namespace detail }//namespace glm //#include "type_gentype.inl" - -#endif//glm_core_type_gentype diff --git a/glm/detail/type_half.hpp b/glm/detail/type_half.hpp index 559c5673..827c28cb 100644 --- a/glm/detail/type_half.hpp +++ b/glm/detail/type_half.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_half -#define glm_core_type_half +#pragma once #include "setup.hpp" @@ -47,5 +46,3 @@ namespace detail }//namespace glm #include "type_half.inl" - -#endif//glm_core_type_half diff --git a/glm/detail/type_int.hpp b/glm/detail/type_int.hpp index b8b65c00..fcf99a3f 100644 --- a/glm/detail/type_int.hpp +++ b/glm/detail/type_int.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_int -#define glm_core_type_int +#pragma once #include "setup.hpp" @@ -187,5 +186,3 @@ namespace detail #endif//GLM_STATIC_ASSERT_NULL }//namespace glm - -#endif//glm_core_type_int diff --git a/glm/detail/type_mat.hpp b/glm/detail/type_mat.hpp index 94105240..8e2b8bb6 100644 --- a/glm/detail/type_mat.hpp +++ b/glm/detail/type_mat.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat -#define glm_core_type_mat +#pragma once #include "precision.hpp" @@ -791,5 +790,3 @@ namespace detail /// @} }//namespace glm - -#endif//glm_core_type_mat diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index e547825e..baa6288f 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat2x2 -#define glm_core_type_mat2x2 +#pragma once #include "../fwd.hpp" #include "type_vec2.hpp" @@ -259,5 +258,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat2x2.inl" #endif - -#endif //glm_core_type_mat2x2 diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index e9e91883..6be15b34 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat2x3 -#define glm_core_type_mat2x3 +#pragma once #include "../fwd.hpp" #include "type_vec2.hpp" @@ -223,5 +222,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat2x3.inl" #endif - -#endif //glm_core_type_mat2x3 diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index 45e0a150..3c900278 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat2x4 -#define glm_core_type_mat2x4 +#pragma once #include "../fwd.hpp" #include "type_vec2.hpp" @@ -225,5 +224,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat2x4.inl" #endif - -#endif //glm_core_type_mat2x4 diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index 45b98b20..f2c23f35 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat3x2 -#define glm_core_type_mat3x2 +#pragma once #include "../fwd.hpp" #include "type_vec2.hpp" @@ -229,5 +228,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat3x2.inl" #endif - -#endif //glm_core_type_mat3x2 diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index fa4bb7a2..82c595e7 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat3x3 -#define glm_core_type_mat3x3 +#pragma once #include "../fwd.hpp" #include "type_vec3.hpp" @@ -263,5 +262,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat3x3.inl" #endif - -#endif //glm_core_type_mat3x3 diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 7da8a19d..af704eb9 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat3x4 -#define glm_core_type_mat3x4 +#pragma once #include "../fwd.hpp" #include "type_vec3.hpp" @@ -229,5 +228,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat3x4.inl" #endif - -#endif //glm_core_type_mat3x4 diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index eb826950..2adc36fd 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat4x2 -#define glm_core_type_mat4x2 +#pragma once #include "../fwd.hpp" #include "type_vec2.hpp" @@ -236,5 +235,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat4x2.inl" #endif - -#endif //glm_core_type_mat4x2 diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index 636572b3..03103d77 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat4x3 -#define glm_core_type_mat4x3 +#pragma once #include "../fwd.hpp" #include "type_vec3.hpp" @@ -236,5 +235,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat4x3.inl" #endif //GLM_EXTERNAL_TEMPLATE - -#endif//glm_core_type_mat4x3 diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index 30e0a548..d5b24ba2 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_mat4x4 -#define glm_core_type_mat4x4 +#pragma once #include "../fwd.hpp" #include "type_vec4.hpp" @@ -59,6 +58,7 @@ namespace detail private: /// @cond DETAIL col_type value[4]; + /// @endcond public: // Constructors @@ -263,5 +263,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_mat4x4.inl" #endif//GLM_EXTERNAL_TEMPLATE - -#endif//glm_core_type_mat4x4 diff --git a/glm/detail/type_vec.hpp b/glm/detail/type_vec.hpp index 5a87170a..b12b8718 100644 --- a/glm/detail/type_vec.hpp +++ b/glm/detail/type_vec.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_vec -#define glm_core_type_vec +#pragma once #include "precision.hpp" #include "type_int.hpp" @@ -512,5 +511,3 @@ namespace detail /// @} }//namespace glm - -#endif//glm_core_type_vec diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 5f319469..4d0d23c8 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_gentype1 -#define glm_core_type_gentype1 +#pragma once #include "../fwd.hpp" #include "type_vec.hpp" @@ -273,5 +272,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_vec1.inl" #endif//GLM_EXTERNAL_TEMPLATE - -#endif//glm_core_type_gentype1 diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 42599342..95365538 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_gentype2 -#define glm_core_type_gentype2 +#pragma once //#include "../fwd.hpp" #include "type_vec.hpp" @@ -311,5 +310,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_vec2.inl" #endif//GLM_EXTERNAL_TEMPLATE - -#endif//glm_core_type_gentype2 diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index c4872139..465e1f4c 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_gentype3 -#define glm_core_type_gentype3 +#pragma once //#include "../fwd.hpp" #include "type_vec.hpp" @@ -329,5 +328,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_vec3.inl" #endif//GLM_EXTERNAL_TEMPLATE - -#endif//glm_core_type_gentype3 diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index a82a4aa6..dd9756e6 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_type_gentype4 -#define glm_core_type_gentype4 +#pragma once //#include "../fwd.hpp" #include "setup.hpp" @@ -245,13 +244,13 @@ namespace detail GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator+=(T s); + GLM_FUNC_DECL tvec4 & operator+=(T v); GLM_FUNC_DECL tvec4 & operator+=(tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator-=(T s); + GLM_FUNC_DECL tvec4 & operator-=(T v); GLM_FUNC_DECL tvec4 & operator-=(tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator*=(T s); + GLM_FUNC_DECL tvec4 & operator*=(T v); GLM_FUNC_DECL tvec4 & operator*=(tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator/=(T s); + GLM_FUNC_DECL tvec4 & operator/=(T v); GLM_FUNC_DECL tvec4 & operator/=(tvec4 const & v); template @@ -418,5 +417,3 @@ namespace detail #ifndef GLM_EXTERNAL_TEMPLATE #include "type_vec4.inl" #endif//GLM_EXTERNAL_TEMPLATE - -#endif//glm_core_type_gentype4 diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 009b8e98..ef631b3a 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -295,12 +295,12 @@ namespace detail #endif template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (T s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (T v) { - this->x += s; - this->y += s; - this->z += s; - this->w += s; + this->x += v; + this->y += v; + this->z += v; + this->w += v; return *this; } @@ -331,12 +331,12 @@ namespace detail } template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (T s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (T v) { - this->x -= s; - this->y -= s; - this->z -= s; - this->w -= s; + this->x -= v; + this->y -= v; + this->z -= v; + this->w -= v; return *this; } @@ -351,12 +351,12 @@ namespace detail } template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (T s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (T v) { - this->x *= s; - this->y *= s; - this->z *= s; - this->w *= s; + this->x *= v; + this->y *= v; + this->z *= v; + this->w *= v; return *this; } @@ -371,12 +371,12 @@ namespace detail } template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (T s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (T v) { - this->x /= s; - this->y /= s; - this->z /= s; - this->w /= s; + this->x /= v; + this->y /= v; + this->z /= v; + this->w /= v; return *this; } @@ -390,9 +390,6 @@ namespace detail return *this; } - - - template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) diff --git a/glm/exponential.hpp b/glm/exponential.hpp index 4d2c9b8f..d11f58ff 100644 --- a/glm/exponential.hpp +++ b/glm/exponential.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_EXPONENTIAL_INCLUDED -#define GLM_EXPONENTIAL_INCLUDED +#pragma once #include "detail/func_exponential.hpp" - -#endif//GLM_EXPONENTIAL_INCLUDED diff --git a/glm/ext.hpp b/glm/ext.hpp index ce13a663..206cd1d7 100644 --- a/glm/ext.hpp +++ b/glm/ext.hpp @@ -55,8 +55,7 @@ /// (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showprofile&User=22660). /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_EXT_INCLUDED -#define GLM_EXT_INCLUDED +#pragma once #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_EXT_INCLUDED_DISPLAYED)) # define GLM_MESSAGE_EXT_INCLUDED_DISPLAYED @@ -133,5 +132,3 @@ # include "./gtx/simd_vec4.hpp" # include "./gtx/simd_mat4.hpp" #endif - -#endif //GLM_EXT_INCLUDED diff --git a/glm/fwd.hpp b/glm/fwd.hpp index 9fba848c..3471fb3b 100644 --- a/glm/fwd.hpp +++ b/glm/fwd.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_FWD_INCLUDED -#define GLM_FWD_INCLUDED +#pragma once #include "detail/type_int.hpp" #include "detail/type_float.hpp" @@ -2594,5 +2593,3 @@ namespace glm typedef highp_f64quat f64quat; #endif }//namespace glm - -#endif//GLM_FWD_INCLUDED diff --git a/glm/geometric.hpp b/glm/geometric.hpp index df025ea8..98a411a6 100644 --- a/glm/geometric.hpp +++ b/glm/geometric.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GEOMETRIC_INCLUDED -#define GLM_GEOMETRIC_INCLUDED +#pragma once #include "detail/func_geometric.hpp" - -#endif//GLM_GEOMETRIC_INCLUDED diff --git a/glm/glm.hpp b/glm/glm.hpp index b5103807..5526a1fd 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -77,8 +77,7 @@ #include "detail/_fixes.hpp" -#ifndef GLM_INCLUDED -#define GLM_INCLUDED +#pragma once #include #include @@ -113,5 +112,3 @@ #include "matrix.hpp" #include "vector_relational.hpp" #include "integer.hpp" - -#endif//GLM_INCLUDED diff --git a/glm/gtc/constants.hpp b/glm/gtc/constants.hpp index c0160861..76fc1eb4 100644 --- a/glm/gtc/constants.hpp +++ b/glm/gtc/constants.hpp @@ -36,8 +36,7 @@ /// need to be included to use these features. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_constants -#define GLM_GTC_constants +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -181,5 +180,3 @@ namespace glm } //namespace glm #include "constants.inl" - -#endif//GLM_GTC_constants diff --git a/glm/gtc/epsilon.hpp b/glm/gtc/epsilon.hpp index 58a2cae5..4befdb5c 100644 --- a/glm/gtc/epsilon.hpp +++ b/glm/gtc/epsilon.hpp @@ -37,8 +37,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_epsilon -#define GLM_GTC_epsilon +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -97,5 +96,3 @@ namespace glm }//namespace glm #include "epsilon.inl" - -#endif//GLM_GTC_epsilon diff --git a/glm/gtc/matrix_access.hpp b/glm/gtc/matrix_access.hpp index df614cc7..b78a018b 100644 --- a/glm/gtc/matrix_access.hpp +++ b/glm/gtc/matrix_access.hpp @@ -34,8 +34,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_matrix_access -#define GLM_GTC_matrix_access +#pragma once // Dependency: #include "../detail/setup.hpp" @@ -83,5 +82,3 @@ namespace glm }//namespace glm #include "matrix_access.inl" - -#endif//GLM_GTC_matrix_access diff --git a/glm/gtc/matrix_integer.hpp b/glm/gtc/matrix_integer.hpp index c96fad1b..76e31c0e 100644 --- a/glm/gtc/matrix_integer.hpp +++ b/glm/gtc/matrix_integer.hpp @@ -34,8 +34,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_matrix_integer -#define GLM_GTC_matrix_integer +#pragma once // Dependency: #include "../mat2x2.hpp" @@ -510,5 +509,3 @@ namespace glm /// @} }//namespace glm - -#endif//GLM_GTC_matrix_integer diff --git a/glm/gtc/matrix_inverse.hpp b/glm/gtc/matrix_inverse.hpp index 53e4918f..803825f0 100644 --- a/glm/gtc/matrix_inverse.hpp +++ b/glm/gtc/matrix_inverse.hpp @@ -34,8 +34,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_matrix_inverse -#define GLM_GTC_matrix_inverse +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -70,5 +69,3 @@ namespace glm }//namespace glm #include "matrix_inverse.inl" - -#endif//GLM_GTC_matrix_inverse diff --git a/glm/gtc/matrix_transform.hpp b/glm/gtc/matrix_transform.hpp index 2b4dade2..a3277a2c 100644 --- a/glm/gtc/matrix_transform.hpp +++ b/glm/gtc/matrix_transform.hpp @@ -43,14 +43,14 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_matrix_transform -#define GLM_GTC_matrix_transform +#pragma once // Dependencies #include "../mat4x4.hpp" #include "../vec2.hpp" #include "../vec3.hpp" #include "../vec4.hpp" +#include "../gtc/constants.hpp" #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) # pragma message("GLM: GLM_GTC_matrix_transform extension included") @@ -164,8 +164,8 @@ namespace glm /// @param far /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. /// @see gtc_matrix_transform - template - GLM_FUNC_DECL detail::tmat4x4 frustum( + template + GLM_FUNC_DECL detail::tmat4x4 frustum( T const & left, T const & right, T const & bottom, @@ -181,8 +181,8 @@ namespace glm /// @param far /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. /// @see gtc_matrix_transform - template - GLM_FUNC_DECL detail::tmat4x4 perspective( + template + GLM_FUNC_DECL detail::tmat4x4 perspective( T const & fovy, T const & aspect, T const & near, @@ -197,8 +197,8 @@ namespace glm /// @param far /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. /// @see gtc_matrix_transform - template - GLM_FUNC_DECL detail::tmat4x4 perspectiveFov( + template + GLM_FUNC_DECL detail::tmat4x4 perspectiveFov( T const & fov, T const & width, T const & height, @@ -212,8 +212,8 @@ namespace glm /// @param near /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. /// @see gtc_matrix_transform - template - GLM_FUNC_DECL detail::tmat4x4 infinitePerspective( + template + GLM_FUNC_DECL detail::tmat4x4 infinitePerspective( T fovy, T aspect, T near); /// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping. @@ -223,10 +223,21 @@ namespace glm /// @param near /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. /// @see gtc_matrix_transform - template - GLM_FUNC_DECL detail::tmat4x4 tweakedInfinitePerspective( + template + GLM_FUNC_DECL detail::tmat4x4 tweakedInfinitePerspective( T fovy, T aspect, T near); + /// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping. + /// + /// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. + /// @param aspect + /// @param near + /// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double. + /// @see gtc_matrix_transform + template + GLM_FUNC_DECL detail::tmat4x4 tweakedInfinitePerspective( + T fovy, T aspect, T near, T ep); + /// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates. /// /// @param obj @@ -290,5 +301,3 @@ namespace glm }//namespace glm #include "matrix_transform.inl" - -#endif//GLM_GTC_matrix_transform diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index 25f13751..15009358 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -167,7 +167,7 @@ namespace glm detail::tmat4x4 Result(1); Result[0][0] = static_cast(2) / (right - left); Result[1][1] = static_cast(2) / (top - bottom); - Result[2][2] = - T(2) / (zFar - zNear); + Result[2][2] = - static_cast(2) / (zFar - zNear); Result[3][0] = - (right + left) / (right - left); Result[3][1] = - (top + bottom) / (top - bottom); Result[3][2] = - (zFar + zNear) / (zFar - zNear); @@ -186,93 +186,93 @@ namespace glm detail::tmat4x4 Result(1); Result[0][0] = static_cast(2) / (right - left); Result[1][1] = static_cast(2) / (top - bottom); - Result[2][2] = - T(1); + Result[2][2] = - static_cast(1); Result[3][0] = - (right + left) / (right - left); Result[3][1] = - (top + bottom) / (top - bottom); return Result; } - template - GLM_FUNC_QUALIFIER detail::tmat4x4 frustum + template + GLM_FUNC_QUALIFIER detail::tmat4x4 frustum ( - valType const & left, - valType const & right, - valType const & bottom, - valType const & top, - valType const & nearVal, - valType const & farVal + T const & left, + T const & right, + T const & bottom, + T const & top, + T const & nearVal, + T const & farVal ) { - detail::tmat4x4 Result(0); - Result[0][0] = (valType(2) * nearVal) / (right - left); - Result[1][1] = (valType(2) * nearVal) / (top - bottom); + detail::tmat4x4 Result(0); + Result[0][0] = (static_cast(2) * nearVal) / (right - left); + Result[1][1] = (static_cast(2) * nearVal) / (top - bottom); Result[2][0] = (right + left) / (right - left); Result[2][1] = (top + bottom) / (top - bottom); Result[2][2] = -(farVal + nearVal) / (farVal - nearVal); - Result[2][3] = valType(-1); - Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal); + Result[2][3] = static_cast(-1); + Result[3][2] = -(static_cast(2) * farVal * nearVal) / (farVal - nearVal); return Result; } - template - GLM_FUNC_QUALIFIER detail::tmat4x4 perspective + template + GLM_FUNC_QUALIFIER detail::tmat4x4 perspective ( - valType const & fovy, - valType const & aspect, - valType const & zNear, - valType const & zFar + T const & fovy, + T const & aspect, + T const & zNear, + T const & zFar ) { - assert(aspect != valType(0)); + assert(aspect != static_cast(0)); assert(zFar != zNear); #ifdef GLM_FORCE_RADIANS - valType const rad = fovy; + T const rad = fovy; #else # pragma message("GLM: perspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.") - valType const rad = glm::radians(fovy); + T const rad = glm::radians(fovy); #endif - valType tanHalfFovy = tan(rad / valType(2)); + T tanHalfFovy = tan(rad / static_cast(2)); - detail::tmat4x4 Result(valType(0)); - Result[0][0] = valType(1) / (aspect * tanHalfFovy); - Result[1][1] = valType(1) / (tanHalfFovy); + detail::tmat4x4 Result(static_cast(0)); + Result[0][0] = static_cast(1) / (aspect * tanHalfFovy); + Result[1][1] = static_cast(1) / (tanHalfFovy); Result[2][2] = - (zFar + zNear) / (zFar - zNear); - Result[2][3] = - valType(1); - Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear); + Result[2][3] = - static_cast(1); + Result[3][2] = - (static_cast(2) * zFar * zNear) / (zFar - zNear); return Result; } - template - GLM_FUNC_QUALIFIER detail::tmat4x4 perspectiveFov + template + GLM_FUNC_QUALIFIER detail::tmat4x4 perspectiveFov ( - valType const & fov, - valType const & width, - valType const & height, - valType const & zNear, - valType const & zFar + T const & fov, + T const & width, + T const & height, + T const & zNear, + T const & zFar ) { - assert(width > valType(0)); - assert(height > valType(0)); - assert(fov > valType(0)); + assert(width > static_cast(0)); + assert(height > static_cast(0)); + assert(fov > static_cast(0)); #ifdef GLM_FORCE_RADIANS - valType rad = fov; + T rad = fov; #else # pragma message("GLM: perspectiveFov function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.") - valType rad = glm::radians(fov); + T rad = glm::radians(fov); #endif - valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad); - valType w = h * height / width; ///todo max(width , Height) / min(width , Height)? + T h = glm::cos(static_cast(0.5) * rad) / glm::sin(static_cast(0.5) * rad); + T w = h * height / width; ///todo max(width , Height) / min(width , Height)? - detail::tmat4x4 Result(valType(0)); + detail::tmat4x4 Result(static_cast(0)); Result[0][0] = w; Result[1][1] = h; Result[2][2] = - (zFar + zNear) / (zFar - zNear); - Result[2][3] = - valType(1); - Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear); + Result[2][3] = - static_cast(1); + Result[3][2] = - (static_cast(2) * zFar * zNear) / (zFar - zNear); return Result; } @@ -304,12 +304,14 @@ namespace glm return Result; } + // Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf template GLM_FUNC_QUALIFIER detail::tmat4x4 tweakedInfinitePerspective ( T fovy, T aspect, - T zNear + T zNear, + T ep ) { #ifdef GLM_FORCE_RADIANS @@ -324,14 +326,25 @@ namespace glm T top = range; detail::tmat4x4 Result(T(0)); - Result[0][0] = (T(2) * zNear) / (right - left); - Result[1][1] = (T(2) * zNear) / (top - bottom); - Result[2][2] = static_cast(0.0001) - T(1); + Result[0][0] = (static_cast(2) * zNear) / (right - left); + Result[1][1] = (static_cast(2) * zNear) / (top - bottom); + Result[2][2] = ep - static_cast(1); Result[2][3] = static_cast(-1); - Result[3][2] = - (T(0.0001) - T(2)) * zNear; + Result[3][2] = (ep - static_cast(2)) * zNear; return Result; } + template + GLM_FUNC_QUALIFIER detail::tmat4x4 tweakedInfinitePerspective + ( + T fovy, + T aspect, + T zNear + ) + { + return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon()); + } + template GLM_FUNC_QUALIFIER detail::tvec3 project ( diff --git a/glm/gtc/noise.hpp b/glm/gtc/noise.hpp index bde9987b..6450129e 100644 --- a/glm/gtc/noise.hpp +++ b/glm/gtc/noise.hpp @@ -38,8 +38,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_noise -#define GLM_GTC_noise +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -77,5 +76,3 @@ namespace glm }//namespace glm #include "noise.inl" - -#endif//GLM_GTC_noise diff --git a/glm/gtc/packing.hpp b/glm/gtc/packing.hpp index b7fb5648..1233e349 100644 --- a/glm/gtc/packing.hpp +++ b/glm/gtc/packing.hpp @@ -36,8 +36,7 @@ /// need to be included to use these features. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_packing -#define GLM_GTC_packing +#pragma once // Dependency: #include "type_precision.hpp" @@ -62,7 +61,7 @@ namespace glm /// @see uint32 packUnorm4x8(vec4 const & v) /// @see GLSL packUnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL uint8 packUnorm1x8(float const & v); + GLM_FUNC_DECL uint8 packUnorm1x8(float v); /// Convert a single 8-bit integer to a normalized floating-point value. /// @@ -74,7 +73,7 @@ namespace glm /// @see vec4 unpackUnorm4x8(uint32 p) /// @see GLSL unpackUnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL float unpackUnorm1x8(uint8 const & p); + GLM_FUNC_DECL float unpackUnorm1x8(uint8 p); /// First, converts each component of the normalized floating-point value v into 8-bit integer values. /// Then, the results are packed into the returned 16-bit unsigned integer. @@ -106,7 +105,7 @@ namespace glm /// @see vec4 unpackUnorm4x8(uint32 p) /// @see GLSL unpackUnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 const & p); + GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 p); /// First, converts the normalized floating-point value v into 8-bit integer value. /// Then, the results are packed into the returned 8-bit unsigned integer. @@ -119,7 +118,7 @@ namespace glm /// @see uint32 packSnorm4x8(vec4 const & v) /// @see GLSL packSnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL uint8 packSnorm1x8(float const & s); + GLM_FUNC_DECL uint8 packSnorm1x8(float s); /// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers. /// Then, the value is converted to a normalized floating-point value to generate the returned scalar. @@ -132,7 +131,7 @@ namespace glm /// @see vec4 unpackSnorm4x8(uint32 p) /// @see GLSL unpackSnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL float unpackSnorm1x8(uint8 const & p); + GLM_FUNC_DECL float unpackSnorm1x8(uint8 p); /// First, converts each component of the normalized floating-point value v into 8-bit integer values. /// Then, the results are packed into the returned 16-bit unsigned integer. @@ -164,7 +163,7 @@ namespace glm /// @see vec4 unpackSnorm4x8(uint32 p) /// @see GLSL unpackSnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 const & p); + GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 p); /// First, converts the normalized floating-point value v into a 16-bit integer value. /// Then, the results are packed into the returned 16-bit unsigned integer. @@ -177,7 +176,7 @@ namespace glm /// @see uint64 packSnorm4x16(vec4 const & v) /// @see GLSL packUnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL uint16 packUnorm1x16(float const & v); + GLM_FUNC_DECL uint16 packUnorm1x16(float v); /// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers. /// Then, the value is converted to a normalized floating-point value to generate the returned scalar. @@ -190,7 +189,7 @@ namespace glm /// @see vec4 unpackUnorm4x16(uint64 p) /// @see GLSL unpackUnorm2x16 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL float unpackUnorm1x16(uint16 const & p); + GLM_FUNC_DECL float unpackUnorm1x16(uint16 p); /// First, converts each component of the normalized floating-point value v into 16-bit integer values. /// Then, the results are packed into the returned 64-bit unsigned integer. @@ -222,7 +221,7 @@ namespace glm /// @see vec2 unpackUnorm2x16(uint32 p) /// @see GLSL unpackUnorm2x16 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 const & p); + GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 p); /// First, converts the normalized floating-point value v into 16-bit integer value. /// Then, the results are packed into the returned 16-bit unsigned integer. @@ -235,7 +234,7 @@ namespace glm /// @see uint64 packSnorm4x16(vec4 const & v) /// @see GLSL packSnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL uint16 packSnorm1x16(float const & v); + GLM_FUNC_DECL uint16 packSnorm1x16(float v); /// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers. /// Then, each component is converted to a normalized floating-point value to generate the returned scalar. @@ -248,7 +247,7 @@ namespace glm /// @see vec4 unpackSnorm4x16(uint64 p) /// @see GLSL unpackSnorm4x8 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL float unpackSnorm1x16(uint16 const & p); + GLM_FUNC_DECL float unpackSnorm1x16(uint16 p); /// First, converts each component of the normalized floating-point value v into 16-bit integer values. /// Then, the results are packed into the returned 64-bit unsigned integer. @@ -291,7 +290,7 @@ namespace glm /// @see uint64 packHalf4x16(vec4 const & v) /// @see GLSL packHalf2x16 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL uint16 packHalf1x16(float const & v); + GLM_FUNC_DECL uint16 packHalf1x16(float v); /// Returns a floating-point scalar with components obtained by unpacking a 16-bit unsigned integer into a 16-bit value, /// interpreted as a 16-bit floating-point number according to the OpenGL Specification, @@ -302,7 +301,7 @@ namespace glm /// @see vec4 unpackHalf4x16(uint64 const & v) /// @see GLSL unpackHalf2x16 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL float unpackHalf1x16(uint16 const & v); + GLM_FUNC_DECL float unpackHalf1x16(uint16 v); /// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector /// to the 16-bit floating-point representation found in the OpenGL Specification, @@ -328,7 +327,7 @@ namespace glm /// @see vec2 unpackHalf2x16(uint32 const & v) /// @see GLSL unpackHalf2x16 man page /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 const & p); + GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 p); /// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector /// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification, @@ -352,7 +351,7 @@ namespace glm /// @see uint32 packU3x10_1x2(uvec4 const & v) /// @see vec4 unpackSnorm3x10_1x2(uint32 const & p); /// @see uvec4 unpackI3x10_1x2(uint32 const & p); - GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 const & p); + GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 p); /// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector /// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification, @@ -376,7 +375,7 @@ namespace glm /// @see uint32 packU3x10_1x2(uvec4 const & v) /// @see vec4 unpackSnorm3x10_1x2(uint32 const & p); /// @see uvec4 unpackI3x10_1x2(uint32 const & p); - GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 const & p); + GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 p); /// First, converts the first three components of the normalized floating-point value v into 10-bit signed integer values. /// Then, converts the forth component of the normalized floating-point value v into 2-bit signed integer values. @@ -411,7 +410,7 @@ namespace glm /// @see vec4 unpackUnorm3x10_1x2(uint32 const & p)) /// @see uvec4 unpackI3x10_1x2(uint32 const & p) /// @see uvec4 unpackU3x10_1x2(uint32 const & p) - GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 const & p); + GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 p); /// First, converts the first three components of the normalized floating-point value v into 10-bit unsigned integer values. /// Then, converts the forth component of the normalized floating-point value v into 2-bit signed uninteger values. @@ -446,7 +445,7 @@ namespace glm /// @see vec4 unpackInorm3x10_1x2(uint32 const & p)) /// @see uvec4 unpackI3x10_1x2(uint32 const & p) /// @see uvec4 unpackU3x10_1x2(uint32 const & p) - GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 const & p); + GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 p); /// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values. /// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value. @@ -467,12 +466,9 @@ namespace glm /// /// @see gtc_packing /// @see uint32 packF2x11_1x10(vec3 const & v) - GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 const & p); + GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p); /// @} }// namespace glm #include "packing.inl" - -#endif//GLM_GTC_packing - diff --git a/glm/gtc/packing.inl b/glm/gtc/packing.inl index 537e4648..571d0f4d 100644 --- a/glm/gtc/packing.inl +++ b/glm/gtc/packing.inl @@ -31,11 +31,12 @@ #include "../vec3.hpp" #include "../vec4.hpp" #include "../detail/type_half.hpp" +#include namespace glm{ namespace detail { - GLM_FUNC_QUALIFIER glm::uint16 float2half(glm::uint32 const & f) + GLM_FUNC_QUALIFIER glm::uint16 float2half(glm::uint32 f) { // 10 bits => EE EEEFFFFF // 11 bits => EEE EEFFFFFF @@ -53,7 +54,7 @@ namespace detail ((f >> 13) & 0x03ff); // Mantissa } - GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 const & f) + GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 f) { // 10 bits => EE EEEFFFFF // 11 bits => EEE EEFFFFFF @@ -71,7 +72,7 @@ namespace detail ((f >> 17) & 0x003f); // Mantissa } - GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 const & p) + GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 p) { // 10 bits => EE EEEFFFFF // 11 bits => EEE EEFFFFFF @@ -89,7 +90,7 @@ namespace detail ((p & 0x003f) << 17); // Mantissa } - GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 const & f) + GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 f) { // 10 bits => EE EEEFFFFF // 11 bits => EEE EEFFFFFF @@ -110,7 +111,7 @@ namespace detail ((f >> 18) & 0x001f); // Mantissa } - GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 const & p) + GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 p) { // 10 bits => EE EEEFFFFF // 11 bits => EEE EEFFFFFF @@ -131,7 +132,7 @@ namespace detail ((p & 0x001f) << 18); // Mantissa } - GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint const & h) + GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint h) { return ((h & 0x8000) << 16) | ((( h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13); } @@ -145,7 +146,14 @@ namespace detail else if(glm::isinf(x)) return 0x1f << 6; - return float2packed11(reinterpret_cast(x)); +# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG) + uint Pack = 0; + memcpy(&Pack, &x, sizeof(Pack)); +# else + uint Pack = reinterpret_cast(x); +# endif + + return float2packed11(Pack); } GLM_FUNC_QUALIFIER float packed11bitToFloat(glm::uint x) @@ -157,8 +165,15 @@ namespace detail else if(x == (0x1f << 6)) return ~0;//Inf - uint result = packed11ToFloat(x); - return reinterpret_cast(result); + uint Result = packed11ToFloat(x); + +# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG) + float Temp = 0; + memcpy(&Temp, &Result, sizeof(Temp)); + return Temp; +# else + return reinterpret_cast(Result); +# endif } GLM_FUNC_QUALIFIER glm::uint floatTo10bit(float x) @@ -170,7 +185,14 @@ namespace detail else if(glm::isinf(x)) return 0x1f << 5; - return float2packed10(reinterpret_cast(x)); +# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG) + uint Pack = 0; + memcpy(&Pack, &x, sizeof(Pack)); +# else + uint Pack = reinterpret_cast(x); +# endif + + return float2packed10(Pack); } GLM_FUNC_QUALIFIER float packed10bitToFloat(glm::uint x) @@ -182,8 +204,15 @@ namespace detail else if(x == (0x1f << 5)) return ~0;//Inf - uint result = packed10ToFloat(x); - return reinterpret_cast(result); + uint Result = packed10ToFloat(x); + +# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG) + float Temp = 0; + memcpy(&Temp, &Result, sizeof(Temp)); + return Temp; +# else + return reinterpret_cast(Result); +# endif } // GLM_FUNC_QUALIFIER glm::uint f11_f11_f10(float x, float y, float z) @@ -217,12 +246,12 @@ namespace detail }//namespace detail - GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float const & v) + GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float v) { return static_cast(round(clamp(v, 0.0f, 1.0f) * 255.0f)); } - GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 const & p) + GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 p) { float Unpack(static_cast(p)); return Unpack * static_cast(0.0039215686274509803921568627451); // 1 / 255 @@ -235,20 +264,20 @@ namespace detail return *Packed; } - GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 const & p) + GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 p) { u8vec2* Unpacked = reinterpret_cast(const_cast(&p)); return vec2(*Unpacked) * float(0.0039215686274509803921568627451); // 1 / 255 } - GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float const & v) + GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float v) { int8 Topack(static_cast(round(clamp(v ,-1.0f, 1.0f) * 127.0f))); uint8* Packed = reinterpret_cast(&Topack); return *Packed; } - GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 const & p) + GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 p) { float Unpack(static_cast(*const_cast(&p))); return clamp( @@ -263,7 +292,7 @@ namespace detail return *Packed; } - GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 const & p) + GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 p) { i8vec2* Unpack = reinterpret_cast(const_cast(&p)); return clamp( @@ -271,12 +300,12 @@ namespace detail -1.0f, 1.0f); } - GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float const & s) + GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float s) { return static_cast(round(clamp(s, 0.0f, 1.0f) * 65535.0f)); } - GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 const & p) + GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 p) { float Unpack = static_cast(*const_cast(&p)); return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0 @@ -289,20 +318,20 @@ namespace detail return *Packed; } - GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 const & p) + GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 p) { u16vec4* Unpack = reinterpret_cast(const_cast(&p)); return vec4(*Unpack) * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0 } - GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float const & v) + GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float v) { int16 Topack = static_cast(round(clamp(v ,-1.0f, 1.0f) * 32767.0f)); uint16* Packed = reinterpret_cast(&Topack); return *Packed; } - GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 const & p) + GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 p) { float Unpack = static_cast(*const_cast(&p)); return clamp( @@ -317,7 +346,7 @@ namespace detail return *Packed; } - GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 const & p) + GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 p) { i16vec4* Unpack(reinterpret_cast(const_cast(&p))); return clamp( @@ -325,14 +354,14 @@ namespace detail -1.0f, 1.0f); } - GLM_FUNC_QUALIFIER uint16 packHalf1x16(float const & v) + GLM_FUNC_QUALIFIER uint16 packHalf1x16(float v) { int16 Topack = detail::toFloat16(v); uint16* Packed = reinterpret_cast(&Topack); return *Packed; } - GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 const & v) + GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 v) { int16* Unpack = reinterpret_cast(const_cast(&v)); return detail::toFloat32(*Unpack); @@ -350,7 +379,7 @@ namespace detail return *Packed; } - GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 const & v) + GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 v) { i16vec4* p = reinterpret_cast(const_cast(&v)); i16vec4 Unpack(*p); @@ -372,7 +401,7 @@ namespace detail return Result.pack; } - GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 const & v) + GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 v) { detail::i10i10i10i2 Unpack; Unpack.pack = v; @@ -393,7 +422,7 @@ namespace detail return Result.pack; } - GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 const & v) + GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 v) { detail::u10u10u10u2 Unpack; Unpack.pack = v; @@ -414,7 +443,7 @@ namespace detail return Result.pack; } - GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 const & v) + GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 v) { detail::i10i10i10i2 Unpack; Unpack.pack = v; @@ -436,7 +465,7 @@ namespace detail return Result.pack; } - GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 const & v) + GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v) { detail::i10i10i10i2 Unpack; Unpack.pack = v; @@ -456,7 +485,7 @@ namespace detail ((detail::floatTo10bit(v.z) & ((1 << 10) - 1)) << 22); } - GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 const & v) + GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 v) { return vec3( detail::packed11bitToFloat(v >> 0), diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 44474573..6cbb3326 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -37,8 +37,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_quaternion -#define GLM_GTC_quaternion +#pragma once // Dependency: #include "../mat3x3.hpp" @@ -59,6 +58,7 @@ namespace detail { enum ctor{null}; + typedef T value_type; typedef tvec4 bool_type; public: @@ -399,5 +399,3 @@ namespace detail } //namespace glm #include "quaternion.inl" - -#endif//GLM_GTC_quaternion diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 951b62c4..122cdc42 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -114,9 +114,9 @@ namespace detail detail::tvec3 const & v ) { - detail::tvec3 w = cross(u, v); + detail::tvec3 const LocalW(cross(u, v)); T Dot = detail::compute_dot::call(u, v); - detail::tquat q(T(1) + Dot, w.x, w.y, w.z); + detail::tquat q(T(1) + Dot, LocalW.x, LocalW.y, LocalW.z); *this = normalize(q); } @@ -255,7 +255,7 @@ namespace detail template struct compute_dot { - static T call(tquat const & x, tquat const & y) + static GLM_FUNC_QUALIFIER T call(tquat const & x, tquat const & y) { tvec4 tmp(x.x * y.x, x.y * y.y, x.z * y.z, x.w * y.w); return (tmp.x + tmp.y) + (tmp.z + tmp.w); @@ -302,16 +302,11 @@ namespace detail detail::tvec3 const & v ) { - T Two(2); + detail::tvec3 const QuatVector(q.x, q.y, q.z); + detail::tvec3 const uv(glm::cross(QuatVector, v)); + detail::tvec3 const uuv(glm::cross(QuatVector, uv)); - detail::tvec3 uv, uuv; - detail::tvec3 QuatVector(q.x, q.y, q.z); - uv = glm::cross(QuatVector, v); - uuv = glm::cross(QuatVector, uv); - uv *= (Two * q.w); - uuv *= Two; - - return v + uv + uuv; + return v + ((uv * q.w) + uuv) * static_cast(2); } template @@ -587,10 +582,10 @@ namespace detail { // Linear interpolation return detail::tquat( - mix(x.w, y.w, a), - mix(x.x, y.x, a), - mix(x.y, y.y, a), - mix(x.z, y.z, a)); + mix(x.w, z.w, a), + mix(x.x, z.x, a), + mix(x.y, z.y, a), + mix(x.z, z.z, a)); } else { diff --git a/glm/gtc/random.hpp b/glm/gtc/random.hpp index 252bf1c7..395bf6a4 100644 --- a/glm/gtc/random.hpp +++ b/glm/gtc/random.hpp @@ -37,8 +37,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_random -#define GLM_GTC_random +#pragma once // Dependency: #include "../vec2.hpp" @@ -110,5 +109,3 @@ namespace glm }//namespace glm #include "random.inl" - -#endif//GLM_GTC_random diff --git a/glm/gtc/reciprocal.hpp b/glm/gtc/reciprocal.hpp index 428788ec..eb976575 100644 --- a/glm/gtc/reciprocal.hpp +++ b/glm/gtc/reciprocal.hpp @@ -35,8 +35,7 @@ /// need to be included to use these features. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_reciprocal -#define GLM_GTC_reciprocal +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -129,5 +128,3 @@ namespace glm }//namespace glm #include "reciprocal.inl" - -#endif//GLM_GTC_reciprocal diff --git a/glm/gtc/type_precision.hpp b/glm/gtc/type_precision.hpp index 63370856..5e035052 100644 --- a/glm/gtc/type_precision.hpp +++ b/glm/gtc/type_precision.hpp @@ -40,8 +40,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_type_precision -#define GLM_GTC_type_precision +#pragma once // Dependency: #include "../gtc/quaternion.hpp" @@ -870,5 +869,3 @@ namespace glm }//namespace glm #include "type_precision.inl" - -#endif//GLM_GTC_type_precision diff --git a/glm/gtc/type_ptr.hpp b/glm/gtc/type_ptr.hpp index d33de141..314cca44 100644 --- a/glm/gtc/type_ptr.hpp +++ b/glm/gtc/type_ptr.hpp @@ -56,8 +56,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_type_ptr -#define GLM_GTC_type_ptr +#pragma once // Dependency: #include "../gtc/quaternion.hpp" @@ -174,6 +173,3 @@ namespace glm }//namespace glm #include "type_ptr.inl" - -#endif//GLM_GTC_type_ptr - diff --git a/glm/gtc/ulp.hpp b/glm/gtc/ulp.hpp index ee67ac61..ee7a1f0a 100644 --- a/glm/gtc/ulp.hpp +++ b/glm/gtc/ulp.hpp @@ -36,8 +36,7 @@ /// need to be included to use these features. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTC_ulp -#define GLM_GTC_ulp +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -87,6 +86,3 @@ namespace glm }// namespace glm #include "ulp.inl" - -#endif//GLM_GTC_ulp - diff --git a/glm/gtc/ulp.inl b/glm/gtc/ulp.inl index 19ac7b47..91846b22 100644 --- a/glm/gtc/ulp.inl +++ b/glm/gtc/ulp.inl @@ -199,10 +199,12 @@ namespace glm template <> GLM_FUNC_QUALIFIER float next_float(float const & x) { -# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) +# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID)) return std::nextafter(x, std::numeric_limits::max()); # elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return detail::nextafterf(x, FLT_MAX); +# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) + return _nextafterf(x, FLT_MAX); # else return nextafterf(x, FLT_MAX); # endif @@ -211,7 +213,7 @@ namespace glm template <> GLM_FUNC_QUALIFIER double next_float(double const & x) { -# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) +# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID)) return std::nextafter(x, std::numeric_limits::max()); # elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return detail::nextafter(x, std::numeric_limits::max()); @@ -231,10 +233,12 @@ namespace glm GLM_FUNC_QUALIFIER float prev_float(float const & x) { -# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) +# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID)) return std::nextafter(x, std::numeric_limits::min()); # elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return detail::nextafterf(x, FLT_MIN); +# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) + return _nextafterf(x, FLT_MIN); # else return nextafterf(x, FLT_MIN); # endif @@ -242,9 +246,9 @@ namespace glm GLM_FUNC_QUALIFIER double prev_float(double const & x) { -# if((GLM_LANG & GLM_LANG_CXX11_FLAG)) +# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID)) return std::nextafter(x, std::numeric_limits::min()); -# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) +# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return _nextafter(x, DBL_MIN); # else return nextafter(x, DBL_MIN); diff --git a/glm/gtx/associated_min_max.hpp b/glm/gtx/associated_min_max.hpp index 247c7f3b..23f37ca9 100644 --- a/glm/gtx/associated_min_max.hpp +++ b/glm/gtx/associated_min_max.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_associated_min_max -#define GLM_GTX_associated_min_max +#pragma once // Dependency: #include "../glm.hpp" @@ -102,5 +101,3 @@ namespace glm } //namespace glm #include "associated_min_max.inl" - -#endif//GLM_GTX_associated_min_max diff --git a/glm/gtx/bit.hpp b/glm/gtx/bit.hpp index 28a8e6c8..f358bcc4 100644 --- a/glm/gtx/bit.hpp +++ b/glm/gtx/bit.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_bit -#define GLM_GTX_bit +#pragma once // Dependencies #include "../detail/type_int.hpp" @@ -230,5 +229,3 @@ namespace glm } //namespace glm #include "bit.inl" - -#endif//GLM_GTX_bit diff --git a/glm/gtx/bit.inl b/glm/gtx/bit.inl index e8ef509f..f34a9833 100644 --- a/glm/gtx/bit.inl +++ b/glm/gtx/bit.inl @@ -287,7 +287,7 @@ namespace glm assert(ToBit <= sizeof(genIUType) * std::size_t(8)); genIUType Result = Value; - for(std::size_t i = 0; i <= ToBit; ++i) + for(signed i = 0; i <= ToBit; ++i) Result |= (1 << i); return Result; } @@ -304,7 +304,7 @@ namespace glm assert(ToBit <= sizeof(genIUType) * std::size_t(8)); genIUType Result = Value; - for(std::size_t i = 0; i <= ToBit; ++i) + for(signed i = 0; i <= ToBit; ++i) Result &= ~(1 << i); return Result; } diff --git a/glm/gtx/closest_point.hpp b/glm/gtx/closest_point.hpp index c2568060..d0f17155 100644 --- a/glm/gtx/closest_point.hpp +++ b/glm/gtx/closest_point.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_closest_point -#define GLM_GTX_closest_point +#pragma once // Dependency: #include "../glm.hpp" @@ -62,5 +61,3 @@ namespace glm }// namespace glm #include "closest_point.inl" - -#endif//GLM_GTX_closest_point diff --git a/glm/gtx/color_space.hpp b/glm/gtx/color_space.hpp index 44e2dd13..d714b627 100644 --- a/glm/gtx/color_space.hpp +++ b/glm/gtx/color_space.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_color_space -#define GLM_GTX_color_space +#pragma once // Dependency: #include "../glm.hpp" @@ -92,5 +91,3 @@ namespace glm }//namespace glm #include "color_space.inl" - -#endif//GLM_GTX_color_space diff --git a/glm/gtx/color_space_YCoCg.hpp b/glm/gtx/color_space_YCoCg.hpp index 1f6578cf..ea2abbf3 100644 --- a/glm/gtx/color_space_YCoCg.hpp +++ b/glm/gtx/color_space_YCoCg.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_gtx_color_space_YCoCg -#define glm_gtx_color_space_YCoCg +#pragma once // Dependency: #include "../glm.hpp" @@ -80,5 +79,3 @@ namespace glm }//namespace glm #include "color_space_YCoCg.inl" - -#endif//glm_gtx_color_space_YCoCg diff --git a/glm/gtx/compatibility.hpp b/glm/gtx/compatibility.hpp index c262e3fc..3435405d 100644 --- a/glm/gtx/compatibility.hpp +++ b/glm/gtx/compatibility.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_compatibility -#define GLM_GTX_compatibility +#pragma once // Dependency: #include "../glm.hpp" @@ -155,6 +154,3 @@ namespace glm }//namespace glm #include "compatibility.inl" - -#endif//GLM_GTX_compatibility - diff --git a/glm/gtx/component_wise.hpp b/glm/gtx/component_wise.hpp index 335b3b97..0e4c0e2b 100644 --- a/glm/gtx/component_wise.hpp +++ b/glm/gtx/component_wise.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_component_wise -#define GLM_GTX_component_wise +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -78,5 +77,3 @@ namespace glm }//namespace glm #include "component_wise.inl" - -#endif//GLM_GTX_component_wise diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index c7c6c50a..459b00a1 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -38,8 +38,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_dual_quaternion -#define GLM_GTX_dual_quaternion +#pragma once // Dependency: #include "../glm.hpp" @@ -57,13 +56,13 @@ namespace detail struct tdualquat { enum ctor{null}; - + typedef T value_type; typedef glm::detail::tquat part_type; public: glm::detail::tquat real, dual; - GLM_FUNC_DECL GLM_CONSTEXPR int length() const; + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; // Constructors GLM_FUNC_DECL tdualquat(); @@ -291,5 +290,3 @@ namespace detail } //namespace glm #include "dual_quaternion.inl" - -#endif//GLM_GTX_dual_quaternion diff --git a/glm/gtx/dual_quaternion.inl b/glm/gtx/dual_quaternion.inl index 7f4aadd6..bd69f537 100644 --- a/glm/gtx/dual_quaternion.inl +++ b/glm/gtx/dual_quaternion.inl @@ -33,7 +33,7 @@ namespace glm{ namespace detail { template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR int tdualquat::length() const + GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tdualquat::length() const { return 8; } diff --git a/glm/gtx/euler_angles.hpp b/glm/gtx/euler_angles.hpp index d3d6be05..d213a839 100644 --- a/glm/gtx/euler_angles.hpp +++ b/glm/gtx/euler_angles.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_euler_angles -#define GLM_GTX_euler_angles +#pragma once // Dependency: #include "../glm.hpp" @@ -151,5 +150,3 @@ namespace glm }//namespace glm #include "euler_angles.inl" - -#endif//GLM_GTX_euler_angles diff --git a/glm/gtx/euler_angles.inl b/glm/gtx/euler_angles.inl index b3102242..a1afcf3a 100644 --- a/glm/gtx/euler_angles.inl +++ b/glm/gtx/euler_angles.inl @@ -250,7 +250,7 @@ namespace glm detail::tvec3 const & angles ) { - return detail::tmat3x3(yawPitchRoll(angles.x, angles.y, angles.z)); + return detail::tmat3x3(yawPitchRoll(angles.z, angles.x, angles.y)); } template diff --git a/glm/gtx/extend.hpp b/glm/gtx/extend.hpp index 499a5ee1..dea53d99 100644 --- a/glm/gtx/extend.hpp +++ b/glm/gtx/extend.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_extend -#define GLM_GTX_extend +#pragma once // Dependency: #include "../glm.hpp" @@ -62,5 +61,3 @@ namespace glm }//namespace glm #include "extend.inl" - -#endif//GLM_GTX_extend diff --git a/glm/gtx/extented_min_max.hpp b/glm/gtx/extented_min_max.hpp index 5b4e74e6..ab5eb33b 100644 --- a/glm/gtx/extented_min_max.hpp +++ b/glm/gtx/extented_min_max.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_extented_min_max -#define GLM_GTX_extented_min_max +#pragma once // Dependency: #include "../glm.hpp" @@ -157,5 +156,3 @@ namespace glm }//namespace glm #include "extented_min_max.inl" - -#endif//GLM_GTX_extented_min_max diff --git a/glm/gtx/fast_exponential.hpp b/glm/gtx/fast_exponential.hpp index 8b3762cb..cc151457 100644 --- a/glm/gtx/fast_exponential.hpp +++ b/glm/gtx/fast_exponential.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_fast_exponential -#define GLM_GTX_fast_exponential +#pragma once // Dependency: #include "../glm.hpp" @@ -94,5 +93,3 @@ namespace glm }//namespace glm #include "fast_exponential.inl" - -#endif//GLM_GTX_fast_exponential diff --git a/glm/gtx/fast_square_root.hpp b/glm/gtx/fast_square_root.hpp index 0a5d030f..f62bc278 100644 --- a/glm/gtx/fast_square_root.hpp +++ b/glm/gtx/fast_square_root.hpp @@ -37,8 +37,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_fast_square_root -#define GLM_GTX_fast_square_root +#pragma once // Dependency: #include "../glm.hpp" @@ -86,5 +85,3 @@ namespace glm }// namespace glm #include "fast_square_root.inl" - -#endif//GLM_GTX_fast_square_root diff --git a/glm/gtx/fast_square_root.inl b/glm/gtx/fast_square_root.inl index a08bdbf2..198e03ab 100644 --- a/glm/gtx/fast_square_root.inl +++ b/glm/gtx/fast_square_root.inl @@ -101,13 +101,43 @@ namespace glm template GLM_FUNC_QUALIFIER genType fastDistance ( - genType const & x, + genType const & x, genType const & y ) { return fastLength(y - x); } + template + GLM_FUNC_QUALIFIER valType fastDistance + ( + detail::tvec2 const & x, + detail::tvec2 const & y + ) + { + return fastLength(y - x); + } + + template + GLM_FUNC_QUALIFIER valType fastDistance + ( + detail::tvec3 const & x, + detail::tvec3 const & y + ) + { + return fastLength(y - x); + } + + template + GLM_FUNC_QUALIFIER valType fastDistance + ( + detail::tvec4 const & x, + detail::tvec4 const & y + ) + { + return fastLength(y - x); + } + // fastNormalize template GLM_FUNC_QUALIFIER genType fastNormalize diff --git a/glm/gtx/fast_trigonometry.hpp b/glm/gtx/fast_trigonometry.hpp index a95e7809..f89a6df6 100644 --- a/glm/gtx/fast_trigonometry.hpp +++ b/glm/gtx/fast_trigonometry.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_fast_trigonometry -#define GLM_GTX_fast_trigonometry +#pragma once // Dependency: #include "../glm.hpp" @@ -96,5 +95,3 @@ namespace glm }//namespace glm #include "fast_trigonometry.inl" - -#endif//GLM_GTX_fast_trigonometry diff --git a/glm/gtx/gradient_paint.hpp b/glm/gtx/gradient_paint.hpp index 2a47e51c..a057ea80 100644 --- a/glm/gtx/gradient_paint.hpp +++ b/glm/gtx/gradient_paint.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_gradient_paint -#define GLM_GTX_gradient_paint +#pragma once // Dependency: #include "../glm.hpp" @@ -72,5 +71,3 @@ namespace glm }// namespace glm #include "gradient_paint.inl" - -#endif//GLM_GTX_gradient_paint diff --git a/glm/gtx/handed_coordinate_space.hpp b/glm/gtx/handed_coordinate_space.hpp index fb046327..72837d60 100644 --- a/glm/gtx/handed_coordinate_space.hpp +++ b/glm/gtx/handed_coordinate_space.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_handed_coordinate_space -#define GLM_GTX_handed_coordinate_space +#pragma once // Dependency: #include "../glm.hpp" @@ -70,5 +69,3 @@ namespace glm }// namespace glm #include "handed_coordinate_space.inl" - -#endif//GLM_GTX_handed_coordinate_space diff --git a/glm/gtx/inertia.hpp b/glm/gtx/inertia.hpp index c796bfa6..0e9f5f0d 100644 --- a/glm/gtx/inertia.hpp +++ b/glm/gtx/inertia.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_inertia -#define GLM_GTX_inertia +#pragma once // Dependency: #include "../glm.hpp" @@ -112,5 +111,3 @@ namespace glm }// namespace glm #include "inertia.inl" - -#endif//GLM_GTX_inertia diff --git a/glm/gtx/integer.hpp b/glm/gtx/integer.hpp index 21c3912f..00f1fd4a 100644 --- a/glm/gtx/integer.hpp +++ b/glm/gtx/integer.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_integer -#define GLM_GTX_integer +#pragma once // Dependency: #include "../glm.hpp" @@ -100,5 +99,3 @@ namespace glm }//namespace glm #include "integer.inl" - -#endif//GLM_GTX_integer diff --git a/glm/gtx/intersect.hpp b/glm/gtx/intersect.hpp index 0a27b02c..d7d64920 100644 --- a/glm/gtx/intersect.hpp +++ b/glm/gtx/intersect.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_intersect -#define GLM_GTX_intersect +#pragma once // Dependency: #include "../glm.hpp" @@ -107,5 +106,3 @@ namespace glm }//namespace glm #include "intersect.inl" - -#endif//GLM_GTX_intersect diff --git a/glm/gtx/io.hpp b/glm/gtx/io.hpp index e97d27fb..0ddeb490 100644 --- a/glm/gtx/io.hpp +++ b/glm/gtx/io.hpp @@ -1,7 +1,7 @@ /////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// -/// Copyright (c) 2005 - 2014 G-Truc Creation (www.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 @@ -26,125 +26,198 @@ /// @author Jan P Springer (regnirpsj@gmail.com) /// /// @see core (dependence) -/// @see gtx_quaternion (dependence) +/// @see gtc_quaternion (dependence) /// /// @defgroup gtx_io GLM_GTX_io /// @ingroup gtx /// /// @brief std::[w]ostream support for glm types /// +/// std::[w]ostream support for glm types + precision/width/etc. manipulators +/// based on howard hinnant's std::chrono io proposal +/// [http://home.roadrunner.com/~hinnant/bloomington/chrono_io.html] +/// /// needs to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_io -#define GLM_GTX_io +#pragma once // Dependency: -#include "../detail/setup.hpp" -#include "../gtc/quaternion.hpp" +#include "../glm.hpp" +#include "../gtx/quaternion.hpp" -#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) -# pragma message("GLM: GLM_GTX_io extension included") +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_io extension included") #endif #include // std::basic_ostream<> (fwd) +#include // std::locale, std::locale::facet, std::locale::id #include // std::pair<> namespace glm { /// @addtogroup gtx_io /// @{ - - namespace io - { - - class precision_guard { - public: - - GLM_FUNC_DECL explicit precision_guard(); - GLM_FUNC_DECL ~precision_guard(); - - private: - - unsigned precision_; - unsigned value_width_; - - }; - - class format_guard + namespace io { - public: - enum order_t { column_major, row_major, }; + enum order_type { column_major, row_major}; - GLM_FUNC_DECL explicit format_guard(); - GLM_FUNC_DECL ~format_guard(); + template + class format_punct : public std::locale::facet + { + typedef CTy char_type; - private: + public: - order_t order_; - char cr_; - }; + static std::locale::id id; - // decimal places (dflt: 3) - GLM_FUNC_DECL unsigned& precision(); + bool formatted; + unsigned precision; + unsigned width; + char_type separator; + char_type delim_left; + char_type delim_right; + char_type space; + char_type newline; + order_type order; - // sign + value + '.' + decimals (dflt: 1 + 4 + 1 + precision()) - GLM_FUNC_DECL unsigned& value_width(); + explicit format_punct(size_t a = 0); + explicit format_punct(format_punct const&); + }; - // matrix output order (dflt: row_major) - GLM_FUNC_DECL format_guard::order_t& order(); + template > + class basic_state_saver { - // carriage/return char (dflt: '\n') - GLM_FUNC_DECL char& cr(); + public: - // matrix output order -> column_major - GLM_FUNC_DECL std::ios_base& column_major(std::ios_base&); + explicit basic_state_saver(std::basic_ios&); + ~basic_state_saver(); - // matrix output order -> row_major - GLM_FUNC_DECL std::ios_base& row_major (std::ios_base&); + private: - // carriage/return char -> '\n' - GLM_FUNC_DECL std::ios_base& formatted (std::ios_base&); + typedef ::std::basic_ios state_type; + typedef typename state_type::char_type char_type; + typedef ::std::ios_base::fmtflags flags_type; + typedef ::std::streamsize streamsize_type; + typedef ::std::locale const locale_type; - // carriage/return char -> ' ' - GLM_FUNC_DECL std::ios_base& unformatted (std::ios_base&); + state_type& state_; + flags_type flags_; + streamsize_type precision_; + streamsize_type width_; + char_type fill_; + locale_type locale_; - }//namespace io + basic_state_saver& operator=(basic_state_saver const&); + }; - namespace detail - { - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tquat const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec4 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x4 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x4 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x2 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x3 const&); - template - GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x4 const&); + typedef basic_state_saver state_saver; + typedef basic_state_saver wstate_saver; - /// @} -}//namespace detail + template > + class basic_format_saver + { + public: + + explicit basic_format_saver(std::basic_ios&); + ~basic_format_saver(); + + private: + + basic_state_saver const bss_; + + basic_format_saver& operator=(basic_format_saver const&); + }; + + typedef basic_format_saver format_saver; + typedef basic_format_saver wformat_saver; + + struct precision + { + unsigned value; + + explicit precision(unsigned); + }; + + struct width + { + unsigned value; + + explicit width(unsigned); + }; + + template + struct delimeter + { + CTy value[3]; + + explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ','); + }; + + struct order + { + order_type value; + + explicit order(order_type); + }; + + // functions, inlined (inline) + + template + FTy const& get_facet(std::basic_ios&); + template + std::basic_ios& formatted(std::basic_ios&); + template + std::basic_ios& unformattet(std::basic_ios&); + + template + std::basic_ostream& operator<<(std::basic_ostream&, precision const&); + template + std::basic_ostream& operator<<(std::basic_ostream&, width const&); + template + std::basic_ostream& operator<<(std::basic_ostream&, delimeter const&); + template + std::basic_ostream& operator<<(std::basic_ostream&, order const&); + }//namespace io + + namespace detail + { + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tquat const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tvec4 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat2x4 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat3x4 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x2 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x3 const&); + template + GLM_FUNC_DECL std::basic_ostream& operator<<(std::basic_ostream&, tmat4x4 const&); + + template + GLM_FUNC_DECL std::basic_ostream & operator<<( + std::basic_ostream &, + std::pair const, + tmat4x4 const> const &); + }//namespace detail + + /// @} }//namespace glm #include "io.inl" - -#endif//GLM_GTX_io diff --git a/glm/gtx/io.inl b/glm/gtx/io.inl index 2329ffd8..dbad163c 100644 --- a/glm/gtx/io.inl +++ b/glm/gtx/io.inl @@ -1,328 +1,598 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2013-11-22 -// Updated : 2013-11-22 +// Updated : 2013-12-18 // Licence : This source is under MIT License // File : glm/gtx/inl.inl /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "../matrix.hpp" -// #include // boost::io::ios_all_saver -#include // std::setfill<>, std::fixed, std::setprecision, std::right, - // std::setw -#include // std::basic_ostream<> +#include // std::setfill<>, std::fixed, std::setprecision, std::right, std::setw +#include // std::basic_ostream<> namespace glm{ namespace io { - - /* explicit */ GLM_FUNC_QUALIFIER - precision_guard::precision_guard() - : precision_ (precision()), - value_width_(value_width()) - {} + template + /* explicit */ GLM_FUNC_QUALIFIER + format_punct::format_punct(size_t a) + : std::locale::facet(a), + formatted (true), + precision (3), + width (1 + 4 + 1 + precision), + separator (','), + delim_left ('['), + delim_right (']'), + space (' '), + newline ('\n'), + order (row_major) + {} - GLM_FUNC_QUALIFIER - precision_guard::~precision_guard() - { - value_width() = value_width_; - precision() = precision_; - } + template + /* explicit */ GLM_FUNC_QUALIFIER + format_punct::format_punct(format_punct const& a) + : std::locale::facet(0), + formatted (a.formatted), + precision (a.precision), + width (a.width), + separator (a.separator), + delim_left (a.delim_left), + delim_right (a.delim_right), + space (a.space), + newline (a.newline), + order (a.order) + {} - /* explicit */ GLM_FUNC_QUALIFIER - format_guard::format_guard() - : order_(order()), - cr_ (cr()) - {} + template std::locale::id format_punct::id; - GLM_FUNC_QUALIFIER - format_guard::~format_guard() - { - cr() = cr_; - order() = order_; - } + template + /* explicit */ GLM_FUNC_QUALIFIER basic_state_saver::basic_state_saver(std::basic_ios& a) + : state_ (a), + flags_ (a.flags()), + precision_(a.precision()), + width_ (a.width()), + fill_ (a.fill()), + locale_ (a.getloc()) + {} - GLM_FUNC_QUALIFIER unsigned& precision() - { - static unsigned p(3); + template + GLM_FUNC_QUALIFIER basic_state_saver::~basic_state_saver() + { + state_.imbue(locale_); + state_.fill(fill_); + state_.width(width_); + state_.precision(precision_); + state_.flags(flags_); + } - return p; - } - - GLM_FUNC_QUALIFIER unsigned& value_width() - { - static unsigned p(9); + template + /* explicit */ GLM_FUNC_QUALIFIER basic_format_saver::basic_format_saver(std::basic_ios& a) + : bss_(a) + { + a.imbue(std::locale(a.getloc(), new format_punct(get_facet >(a)))); + } - return p; - } - - GLM_FUNC_QUALIFIER format_guard::order_t& order() - { - static format_guard::order_t p(format_guard::row_major); + template + GLM_FUNC_QUALIFIER + basic_format_saver::~basic_format_saver() + {} - return p; - } - - GLM_FUNC_QUALIFIER char& - cr() - { - static char p('\n'); return p; - } - - GLM_FUNC_QUALIFIER std::ios_base& column_major(std::ios_base& os) - { - order() = format_guard::column_major; - - return os; - } - - GLM_FUNC_QUALIFIER std::ios_base& row_major(std::ios_base& os) - { - order() = format_guard::row_major; - - return os; - } + /* explicit */ GLM_FUNC_QUALIFIER precision::precision(unsigned a) + : value(a) + {} - GLM_FUNC_QUALIFIER std::ios_base& formatted(std::ios_base& os) - { - cr() = '\n'; - - return os; - } - - GLM_FUNC_QUALIFIER std::ios_base& unformatted(std::ios_base& os) - { - cr() = ' '; - - return os; - } - + /* explicit */ GLM_FUNC_QUALIFIER width::width(unsigned a) + : value(a) + {} + + template + /* explicit */ GLM_FUNC_QUALIFIER delimeter::delimeter(CTy a, CTy b, CTy c) + : value() + { + value[0] = a; + value[1] = b; + value[2] = c; + } + + /* explicit */ GLM_FUNC_QUALIFIER + order::order(order_type a) + : value(a) + {} + + template + GLM_FUNC_QUALIFIER FTy const& get_facet(std::basic_ios& ios) + { + if (!std::has_facet(ios.getloc())) { + ios.imbue(std::locale(ios.getloc(), new FTy)); + } + + return std::use_facet(ios.getloc()); + } + + template + GLM_FUNC_QUALIFIER std::basic_ios& formatted(std::basic_ios& ios) + { + const_cast&>(get_facet >(ios)).formatted = true; + + return ios; + } + + template + GLM_FUNC_QUALIFIER std::basic_ios& unformatted(std::basic_ios& ios) + { + const_cast&>(get_facet >(ios)).formatted = false; + + return ios; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, precision const& a) + { + const_cast&>(get_facet >(os)).precision = a.value; + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, width const& a) + { + const_cast&>(get_facet >(os)).width = a.value; + + return os; + } + + template + std::basic_ostream& operator<<(std::basic_ostream& os, delimeter const& a) + { + format_punct & fmt(const_cast&>(get_facet >(os))); + + fmt.delim_left = a.value[0]; + fmt.delim_right = a.value[1]; + fmt.separator = a.value[2]; + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, order const& a) + { + const_cast&>(get_facet >(os)).order = a.value; + + return os; + } } // namespace io + namespace detail { - // functions, inlined (inline) + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tquat const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tquat const& a) - { - typename std::basic_ostream::sentry const cerberus(os); + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); - if (cerberus) { - // boost::io::ios_all_saver const ias(os); - - os << std::fixed << std::setprecision(io::precision()) - << '[' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.w << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.x << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.y << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.z - << ']'; - } + if(fmt.formatted) + { + io::basic_state_saver const bss(os); - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec2 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.w << fmt.separator + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y << fmt.separator + << std::setw(fmt.width) << a.z + << fmt.delim_right; + } + else + { + os << a.w << fmt.space << a.x << fmt.space << a.y << fmt.space << a.z; + } + } - if (cerberus) { - // boost::io::ios_all_saver const ias(os); - - os << std::fixed << std::setprecision(io::precision()) - << '[' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.x << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.y - << ']'; - } + return os; + } - return os; - } - - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec3 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - if (cerberus) { - // boost::io::ios_all_saver const ias(os); - - os << std::fixed << std::setprecision(io::precision()) - << '[' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.x << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.y << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.z - << ']'; - } + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); - return os; - } + if(fmt.formatted) + { + io::basic_state_saver const bss(os); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec4 const& a) - { - typename std::basic_ostream::sentry const cerberus(os); + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y + << fmt.delim_right; + } + else + { + os << a.x << fmt.space << a.y; + } + } - if (cerberus) { - // boost::io::ios_all_saver const ias(os); - - os << std::fixed << std::setprecision(io::precision()) - << '[' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.x << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.y << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.z << ',' - << std::right << std::setfill(' ') << std::setw(io::value_width()) << a.w - << ']'; - } + return os; + } - return os; - } + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x2 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); - if (cerberus) { - - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << ']'; - } + if(fmt.formatted) + { + io::basic_state_saver const bss(os); - return os; - } + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y << fmt.separator + << std::setw(fmt.width) << a.z + << fmt.delim_right; + } + else + { + os << a.x << fmt.space << a.y << fmt.space << a.z; + } + } - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x3 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + return os; + } - if (cerberus) { + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tvec4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << ']'; - } + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); - return os; - } + if(fmt.formatted) + { + io::basic_state_saver const bss(os); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x4 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + os << std::fixed + << std::right + << std::setprecision(fmt.precision) + << std::setfill(fmt.space) + << fmt.delim_left + << std::setw(fmt.width) << a.x << fmt.separator + << std::setw(fmt.width) << a.y << fmt.separator + << std::setw(fmt.width) << a.z << fmt.separator + << std::setw(fmt.width) << a.w + << fmt.delim_right; + } + else + { + os << a.x << fmt.space << a.y << fmt.space << a.z << fmt.space << a.w; + } + } - if (cerberus) { + return os; + } - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << ']'; - } + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - return os; - } + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat2x2 m(a); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat3x2 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + if(io::row_major == fmt.order) + m = transpose(a); - if (cerberus) { + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1]; + } + } - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << io::cr() - << ' ' << m[2] << ']'; - } + return os; + } - return os; - } + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat3x3 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat3x2 m(a); - if (cerberus) { + if(io::row_major == fmt.order) + m = transpose(a); - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << io::cr() - << ' ' << m[2] << ']'; - } + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2]; + } + } - return os; - } + return os; + } - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat3x4 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat2x4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - if (cerberus) { + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x2 m(a); - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << io::cr() - << ' ' << m[2] << ']'; - } + if(io::row_major == fmt.order) + m = transpose(a); - return os; - } - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat4x2 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.newline + << fmt.space << m[3] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; + } + } - if (cerberus) { + return os; + } - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << io::cr() - << ' ' << m[2] << io::cr() - << ' ' << m[3] << ']'; - } + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat3x2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - return os; - } + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat2x3 m(a); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat4x3 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + if(io::row_major == fmt.order) + m = transpose(a); - if (cerberus) { + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1]; + } + } - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << io::cr() - << ' ' << m[2] << io::cr() - << ' ' << m[3] << ']'; - } + return os; + } - return os; - } + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat3x3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); - template - GLM_FUNC_QUALIFIER std::basic_ostream& operator<<(std::basic_ostream& os, tmat4x4 const& m) - { - typename std::basic_ostream::sentry const cerberus(os); + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat3x3 m(a); - if (cerberus) { + if(io::row_major == fmt.order) + m = transpose(a); - os << io::cr() - << '[' << m[0] << io::cr() - << ' ' << m[1] << io::cr() - << ' ' << m[2] << io::cr() - << ' ' << m[3] << ']'; - } + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2]; + } + } - return os; - } + return os; + } + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat3x4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x3 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if (fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.newline + << fmt.space << m[3] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat4x2 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat2x4 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if (fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat4x3 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat3x4 m(a); + + if(io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream & operator<<(std::basic_ostream& os, tmat4x4 const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x4 m(a); + + if (io::row_major == fmt.order) + m = transpose(a); + + if(fmt.formatted) + { + os << fmt.newline + << fmt.delim_left << m[0] << fmt.newline + << fmt.space << m[1] << fmt.newline + << fmt.space << m[2] << fmt.newline + << fmt.space << m[3] << fmt.delim_right; + } + else + { + os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3]; + } + } + + return os; + } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<( + std::basic_ostream & os, + std::pair const, tmat4x4 const> const& a) + { + typename std::basic_ostream::sentry const cerberus(os); + + if(cerberus) + { + io::format_punct const & fmt(io::get_facet >(os)); + tmat4x4 ml(a.first); + tmat4x4 mr(a.second); + + if(io::row_major == fmt.order) + { + ml = transpose(a.first); + mr = transpose(a.second); + } + + if(fmt.formatted) + { + CTy const & l(fmt.delim_left); + CTy const & r(fmt.delim_right); + CTy const & s(fmt.space); + + os << fmt.newline + << l << ml[0] << s << s << l << mr[0] << fmt.newline + << s << ml[1] << s << s << s << mr[1] << fmt.newline + << s << ml[2] << s << s << s << mr[2] << fmt.newline + << s << ml[3] << r << s << s << mr[3] << r; + } + else + { + os << ml << fmt.space << mr; + } + } + + return os; + } }//namespace detail }//namespace glm diff --git a/glm/gtx/log_base.hpp b/glm/gtx/log_base.hpp index 2e2f95a7..7662ed04 100644 --- a/glm/gtx/log_base.hpp +++ b/glm/gtx/log_base.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_log_base -#define GLM_GTX_log_base +#pragma once // Dependency: #include "../glm.hpp" @@ -61,5 +60,3 @@ namespace glm }//namespace glm #include "log_base.inl" - -#endif//GLM_GTX_log_base diff --git a/glm/gtx/matrix_cross_product.hpp b/glm/gtx/matrix_cross_product.hpp index e4cc31ae..8dca0dda 100644 --- a/glm/gtx/matrix_cross_product.hpp +++ b/glm/gtx/matrix_cross_product.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_matrix_cross_product -#define GLM_GTX_matrix_cross_product +#pragma once // Dependency: #include "../glm.hpp" @@ -67,5 +66,3 @@ namespace glm }//namespace glm #include "matrix_cross_product.inl" - -#endif//GLM_GTX_matrix_cross_product diff --git a/glm/gtx/matrix_interpolation.hpp b/glm/gtx/matrix_interpolation.hpp index 60dec748..8b21814b 100644 --- a/glm/gtx/matrix_interpolation.hpp +++ b/glm/gtx/matrix_interpolation.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_matrix_interpolation -#define GLM_GTX_matrix_interpolation +#pragma once // Dependency: #include "../glm.hpp" @@ -84,5 +83,3 @@ namespace glm }//namespace glm #include "matrix_interpolation.inl" - -#endif//GLM_GTX_matrix_interpolation diff --git a/glm/gtx/matrix_major_storage.hpp b/glm/gtx/matrix_major_storage.hpp index 330fde9c..a7ea3537 100644 --- a/glm/gtx/matrix_major_storage.hpp +++ b/glm/gtx/matrix_major_storage.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_matrix_major_storage -#define GLM_GTX_matrix_major_storage +#pragma once // Dependency: #include "../glm.hpp" @@ -139,5 +138,3 @@ namespace glm }//namespace glm #include "matrix_major_storage.inl" - -#endif//GLM_GTX_matrix_major_storage diff --git a/glm/gtx/matrix_operation.hpp b/glm/gtx/matrix_operation.hpp index 8e0729ac..a0850c81 100644 --- a/glm/gtx/matrix_operation.hpp +++ b/glm/gtx/matrix_operation.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_matrix_operation -#define GLM_GTX_matrix_operation +#pragma once // Dependency: #include "../glm.hpp" @@ -108,5 +107,3 @@ namespace glm }//namespace glm #include "matrix_operation.inl" - -#endif//GLM_GTX_matrix_operation diff --git a/glm/gtx/matrix_query.hpp b/glm/gtx/matrix_query.hpp index 257f33f1..7b2f648f 100644 --- a/glm/gtx/matrix_query.hpp +++ b/glm/gtx/matrix_query.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_matrix_query -#define GLM_GTX_matrix_query +#pragma once // Dependency: #include "../glm.hpp" @@ -97,5 +96,3 @@ namespace glm }//namespace glm #include "matrix_query.inl" - -#endif//GLM_GTX_matrix_query diff --git a/glm/gtx/matrix_transform_2d.hpp b/glm/gtx/matrix_transform_2d.hpp index 302d2655..2a71c94f 100644 --- a/glm/gtx/matrix_transform_2d.hpp +++ b/glm/gtx/matrix_transform_2d.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_matrix_transform_2d -#define GLM_GTX_matrix_transform_2d +#pragma once // Dependency: #include "../mat3x3.hpp" @@ -101,5 +100,3 @@ namespace glm }//namespace glm #include "matrix_transform_2d.inl" - -#endif//GLM_GTX_matrix_transform_2d diff --git a/glm/gtx/mixed_product.hpp b/glm/gtx/mixed_product.hpp index fc37b489..2e858cde 100644 --- a/glm/gtx/mixed_product.hpp +++ b/glm/gtx/mixed_product.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_mixed_product -#define GLM_GTX_mixed_product +#pragma once // Dependency: #include "../glm.hpp" @@ -61,5 +60,3 @@ namespace glm }// namespace glm #include "mixed_product.inl" - -#endif//GLM_GTX_mixed_product diff --git a/glm/gtx/multiple.hpp b/glm/gtx/multiple.hpp index df03a6f0..a1e485b5 100644 --- a/glm/gtx/multiple.hpp +++ b/glm/gtx/multiple.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_multiple -#define GLM_GTX_multiple +#pragma once // Dependency: #include "../glm.hpp" @@ -79,5 +78,3 @@ namespace glm }//namespace glm #include "multiple.inl" - -#endif//GLM_GTX_multiple diff --git a/glm/gtx/norm.hpp b/glm/gtx/norm.hpp index 2bdc0c8d..c7c4d830 100644 --- a/glm/gtx/norm.hpp +++ b/glm/gtx/norm.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_norm -#define GLM_GTX_norm +#pragma once // Dependency: #include "../glm.hpp" @@ -123,5 +122,3 @@ namespace glm }//namespace glm #include "norm.inl" - -#endif//GLM_GTX_norm diff --git a/glm/gtx/normal.hpp b/glm/gtx/normal.hpp index 00966669..c948b8a2 100644 --- a/glm/gtx/normal.hpp +++ b/glm/gtx/normal.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_normal -#define GLM_GTX_normal +#pragma once // Dependency: #include "../glm.hpp" @@ -63,5 +62,3 @@ namespace glm }//namespace glm #include "normal.inl" - -#endif//GLM_GTX_normal diff --git a/glm/gtx/normalize_dot.hpp b/glm/gtx/normalize_dot.hpp index 1d12f6be..2fcb4a54 100644 --- a/glm/gtx/normalize_dot.hpp +++ b/glm/gtx/normalize_dot.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_normalize_dot -#define GLM_GTX_normalize_dot +#pragma once // Dependency: #include "../glm.hpp" @@ -72,5 +71,3 @@ namespace glm }//namespace glm #include "normalize_dot.inl" - -#endif//GLM_GTX_normalize_dot diff --git a/glm/gtx/number_precision.hpp b/glm/gtx/number_precision.hpp index bc3b6a7c..62f95a9d 100644 --- a/glm/gtx/number_precision.hpp +++ b/glm/gtx/number_precision.hpp @@ -37,8 +37,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_number_precision -#define GLM_GTX_number_precision +#pragma once // Dependency: #include "../glm.hpp" @@ -81,5 +80,3 @@ namespace gtx }//namespace glm #include "number_precision.inl" - -#endif//GLM_GTX_number_precision diff --git a/glm/gtx/optimum_pow.hpp b/glm/gtx/optimum_pow.hpp index e825d68c..96e72d78 100644 --- a/glm/gtx/optimum_pow.hpp +++ b/glm/gtx/optimum_pow.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_optimum_pow -#define GLM_GTX_optimum_pow +#pragma once // Dependency: #include "../glm.hpp" @@ -90,5 +89,3 @@ namespace gtx }//namespace glm #include "optimum_pow.inl" - -#endif//GLM_GTX_optimum_pow diff --git a/glm/gtx/orthonormalize.hpp b/glm/gtx/orthonormalize.hpp index d9a6446f..9db33cf6 100644 --- a/glm/gtx/orthonormalize.hpp +++ b/glm/gtx/orthonormalize.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_orthonormalize -#define GLM_GTX_orthonormalize +#pragma once // Dependency: #include "../glm.hpp" @@ -68,5 +67,3 @@ namespace glm }//namespace glm #include "orthonormalize.inl" - -#endif//GLM_GTX_orthonormalize diff --git a/glm/gtx/perpendicular.hpp b/glm/gtx/perpendicular.hpp index ff621449..d5989517 100644 --- a/glm/gtx/perpendicular.hpp +++ b/glm/gtx/perpendicular.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_perpendicular -#define GLM_GTX_perpendicular +#pragma once // Dependency: #include "../glm.hpp" @@ -63,5 +62,3 @@ namespace glm }//namespace glm #include "perpendicular.inl" - -#endif//GLM_GTX_perpendicular diff --git a/glm/gtx/polar_coordinates.hpp b/glm/gtx/polar_coordinates.hpp index c6e43143..87859c18 100644 --- a/glm/gtx/polar_coordinates.hpp +++ b/glm/gtx/polar_coordinates.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_polar_coordinates -#define GLM_GTX_polar_coordinates +#pragma once // Dependency: #include "../glm.hpp" @@ -68,5 +67,3 @@ namespace glm }//namespace glm #include "polar_coordinates.inl" - -#endif//GLM_GTX_polar_coordinates diff --git a/glm/gtx/projection.hpp b/glm/gtx/projection.hpp index 306be6cb..072a9d64 100644 --- a/glm/gtx/projection.hpp +++ b/glm/gtx/projection.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_projection -#define GLM_GTX_projection +#pragma once // Dependency: #include "../glm.hpp" @@ -61,5 +60,3 @@ namespace glm }//namespace glm #include "projection.inl" - -#endif//GLM_GTX_projection diff --git a/glm/gtx/quaternion.hpp b/glm/gtx/quaternion.hpp index 7b056234..ae01043a 100644 --- a/glm/gtx/quaternion.hpp +++ b/glm/gtx/quaternion.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_quaternion -#define GLM_GTX_quaternion +#pragma once // Dependency: #include "../glm.hpp" @@ -209,5 +208,3 @@ namespace glm }//namespace glm #include "quaternion.inl" - -#endif//GLM_GTX_quaternion diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index 2d1a6c13..0dc95b0f 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -8,6 +8,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include +#include "../gtc/constants.hpp" namespace glm { @@ -40,7 +41,7 @@ namespace glm detail::tquat const & s2, T const & h) { - return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * (T(1) - h) * h); + return mix(mix(q1, q2, h), mix(s1, s2, h), static_cast(2) * (static_cast(1) - h) * h); } template @@ -52,7 +53,7 @@ namespace glm ) { detail::tquat invQuat = inverse(curr); - return exp((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr; + return exp((log(next + invQuat) + log(prev + invQuat)) / static_cast(-4)) * curr; } template @@ -62,7 +63,10 @@ namespace glm ) { detail::tvec3 u(q.x, q.y, q.z); - float Angle = glm::length(u); + T Angle = glm::length(u); + if (Angle < epsilon()) + return detail::tquat(); + detail::tvec3 v(u / Angle); return detail::tquat(cos(Angle), sin(Angle) * v); } @@ -73,18 +77,20 @@ namespace glm detail::tquat const & q ) { - if((q.x == static_cast(0)) && (q.y == static_cast(0)) && (q.z == static_cast(0))) + detail::tvec3 u(q.x, q.y, q.z); + T Vec3Len = length(u); + + if (Vec3Len < epsilon()) { - if(q.w > T(0)) - return detail::tquat(log(q.w), T(0), T(0), T(0)); - else if(q.w < T(0)) - return detail::tquat(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0)); + if(q.w > static_cast(0)) + return detail::tquat(log(q.w), static_cast(0), static_cast(0), static_cast(0)); + else if(q.w < static_cast(0)) + return detail::tquat(log(-q.w), pi(), static_cast(0), static_cast(0)); else return detail::tquat(std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()); } else { - T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z); T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w); T t = atan(Vec3Len, T(q.w)) / Vec3Len; return detail::tquat(log(QuatLen), t * q.x, t * q.y, t * q.z); @@ -98,11 +104,11 @@ namespace glm T const & y ) { - if(abs(x.w) > T(0.9999)) + if(abs(x.w) > (static_cast(1) - epsilon())) return x; - float Angle = acos(y); - float NewAngle = Angle * y; - float Div = sin(NewAngle) / sin(Angle); + T Angle = acos(y); + T NewAngle = Angle * y; + T Div = sin(NewAngle) / sin(Angle); return detail::tquat( cos(NewAngle), x.x * Div, @@ -146,7 +152,7 @@ namespace glm detail::tquat const & q ) { - T w = static_cast(1.0) - q.x * q.x - q.y * q.y - q.z * q.z; + T w = static_cast(1) - q.x * q.x - q.y * q.y - q.z * q.z; if(w < T(0)) return T(0); else @@ -170,12 +176,12 @@ namespace glm T const & a ) { - if(a <= T(0)) return x; - if(a >= T(1)) return y; + if(a <= static_cast(0)) return x; + if(a >= static_cast(1)) return y; T fCos = dot(x, y); detail::tquat y2(y); //BUG!!! tquat y2; - if(fCos < T(0)) + if(fCos < static_cast(0)) { y2 = -y; fCos = -fCos; @@ -183,7 +189,7 @@ namespace glm //if(fCos > 1.0f) // problem T k0, k1; - if(fCos > T(0.9999)) + if(fCos > (static_cast(1) - epsilon())) { k0 = static_cast(1) - a; k1 = static_cast(0) + a; //BUG!!! 1.0f + a; @@ -193,8 +199,8 @@ namespace glm T fSin = sqrt(T(1) - fCos * fCos); T fAngle = atan(fSin, fCos); T fOneOverSin = static_cast(1) / fSin; - k0 = sin((T(1) - a) * fAngle) * fOneOverSin; - k1 = sin((T(0) + a) * fAngle) * fOneOverSin; + k0 = sin((static_cast(1) - a) * fAngle) * fOneOverSin; + k1 = sin((static_cast(0) + a) * fAngle) * fOneOverSin; } return detail::tquat( @@ -212,7 +218,7 @@ namespace glm T const & a ) { - return glm::normalize(x * (T(1) - a) + (y * a)); + return glm::normalize(x * (static_cast(1) - a) + (y * a)); } template @@ -225,7 +231,7 @@ namespace glm T cosTheta = dot(orig, dest); detail::tvec3 rotationAxis; - if(cosTheta < T(-1) + epsilon()) + if(cosTheta < static_cast(-1) + epsilon()) { // special case when vectors in opposite directions : // there is no "ideal" rotation axis @@ -243,11 +249,11 @@ namespace glm // Implementation from Stan Melax's Game Programming Gems 1 article rotationAxis = cross(orig, dest); - T s = sqrt((T(1) + cosTheta) * T(2)); + T s = sqrt((T(1) + cosTheta) * static_cast(2)); T invs = static_cast(1) / s; return detail::tquat( - s * T(0.5f), + s * static_cast(0.5f), rotationAxis.x * invs, rotationAxis.y * invs, rotationAxis.z * invs); diff --git a/glm/gtx/raw_data.hpp b/glm/gtx/raw_data.hpp index 71641d14..d36a11fd 100644 --- a/glm/gtx/raw_data.hpp +++ b/glm/gtx/raw_data.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_raw_data -#define GLM_GTX_raw_data +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -71,5 +70,3 @@ namespace glm }// namespace glm #include "raw_data.inl" - -#endif//GLM_GTX_raw_data diff --git a/glm/gtx/rotate_normalized_axis.hpp b/glm/gtx/rotate_normalized_axis.hpp index c5113231..bb7890ae 100644 --- a/glm/gtx/rotate_normalized_axis.hpp +++ b/glm/gtx/rotate_normalized_axis.hpp @@ -37,8 +37,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_rotate_normalized_axis -#define GLM_GTX_rotate_normalized_axis +#pragma once // Dependency: #include "../glm.hpp" @@ -88,5 +87,3 @@ namespace glm }//namespace glm #include "rotate_normalized_axis.inl" - -#endif//GLM_GTX_rotate_normalized_axis diff --git a/glm/gtx/rotate_vector.hpp b/glm/gtx/rotate_vector.hpp index d5644056..06eaee01 100644 --- a/glm/gtx/rotate_vector.hpp +++ b/glm/gtx/rotate_vector.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_rotate_vector -#define GLM_GTX_rotate_vector +#pragma once // Dependency: #include "../glm.hpp" @@ -128,5 +127,3 @@ namespace glm }//namespace glm #include "rotate_vector.inl" - -#endif//GLM_GTX_rotate_vector diff --git a/glm/gtx/scalar_relational.hpp b/glm/gtx/scalar_relational.hpp index 487c5ca2..08c7470e 100644 --- a/glm/gtx/scalar_relational.hpp +++ b/glm/gtx/scalar_relational.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_scalar_relational -#define GLM_GTX_scalar_relational +#pragma once // Dependency: #include "../glm.hpp" @@ -56,5 +55,3 @@ namespace glm }//namespace glm #include "scalar_relational.inl" - -#endif//GLM_GTX_scalar_relational diff --git a/glm/gtx/simd_mat4.hpp b/glm/gtx/simd_mat4.hpp index 07794c9f..e4857c83 100644 --- a/glm/gtx/simd_mat4.hpp +++ b/glm/gtx/simd_mat4.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_simd_mat4 -#define GLM_GTX_simd_mat4 +#pragma once // Dependencies #include "../detail/setup.hpp" @@ -201,5 +200,3 @@ namespace detail #include "simd_mat4.inl" #endif//(GLM_ARCH != GLM_ARCH_PURE) - -#endif//GLM_GTX_simd_mat4 diff --git a/glm/gtx/simd_quat.hpp b/glm/gtx/simd_quat.hpp index 1658cca4..a023c988 100644 --- a/glm/gtx/simd_quat.hpp +++ b/glm/gtx/simd_quat.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_simd_quat -#define GLM_GTX_simd_quat +#pragma once // Dependency: #include "../glm.hpp" @@ -114,14 +113,14 @@ namespace detail ////////////////////////////////////// // Unary arithmetic operators - fquatSIMD& operator =(fquatSIMD const & q); - fquatSIMD& operator*=(float const & s); + fquatSIMD& operator =(fquatSIMD const & q); + fquatSIMD& operator*=(float const & s); fquatSIMD& operator/=(float const & s); }; - ////////////////////////////////////// - // Arithmetic operators + ////////////////////////////////////// + // Arithmetic operators detail::fquatSIMD operator- ( detail::fquatSIMD const & q); @@ -161,37 +160,37 @@ namespace detail /// @addtogroup gtx_simd_quat /// @{ - //! Convert a simdQuat to a quat. + //! Convert a simdQuat to a quat. //! (From GLM_GTX_simd_quat extension) quat quat_cast( detail::fquatSIMD const & x); - //! Convert a simdMat4 to a simdQuat. - //! (From GLM_GTX_simd_quat extension) - detail::fquatSIMD quatSIMD_cast( - detail::fmat4x4SIMD const & m); + //! Convert a simdMat4 to a simdQuat. + //! (From GLM_GTX_simd_quat extension) + detail::fquatSIMD quatSIMD_cast( + detail::fmat4x4SIMD const & m); - //! Converts a mat4 to a simdQuat. - //! (From GLM_GTX_simd_quat extension) - template - detail::fquatSIMD quatSIMD_cast( - detail::tmat4x4 const & m); + //! Converts a mat4 to a simdQuat. + //! (From GLM_GTX_simd_quat extension) + template + detail::fquatSIMD quatSIMD_cast( + detail::tmat4x4 const & m); - //! Converts a mat3 to a simdQuat. - //! (From GLM_GTX_simd_quat extension) - template - detail::fquatSIMD quatSIMD_cast( - detail::tmat3x3 const & m); + //! Converts a mat3 to a simdQuat. + //! (From GLM_GTX_simd_quat extension) + template + detail::fquatSIMD quatSIMD_cast( + detail::tmat3x3 const & m); - //! Convert a simdQuat to a simdMat4 - //! (From GLM_GTX_simd_quat extension) - detail::fmat4x4SIMD mat4SIMD_cast( - detail::fquatSIMD const & q); + //! Convert a simdQuat to a simdMat4 + //! (From GLM_GTX_simd_quat extension) + detail::fmat4x4SIMD mat4SIMD_cast( + detail::fquatSIMD const & q); - //! Converts a simdQuat to a standard mat4. - //! (From GLM_GTX_simd_quat extension) - mat4 mat4_cast( - detail::fquatSIMD const & q); + //! Converts a simdQuat to a standard mat4. + //! (From GLM_GTX_simd_quat extension) + mat4 mat4_cast( + detail::fquatSIMD const & q); /// Returns the length of the quaternion. @@ -206,14 +205,14 @@ namespace detail detail::fquatSIMD normalize( detail::fquatSIMD const & x); - /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... + /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... /// /// @see gtc_quaternion float dot( detail::fquatSIMD const & q1, detail::fquatSIMD const & q2); - /// Spherical linear interpolation of two quaternions. + /// Spherical linear interpolation of two quaternions. /// The interpolation is oriented and the rotation is performed at constant speed. /// For short path spherical linear interpolation, use the slerp function. /// @@ -228,7 +227,7 @@ namespace detail detail::fquatSIMD const & y, float const & a); - /// Linear interpolation of two quaternions. + /// Linear interpolation of two quaternions. /// The interpolation is oriented. /// /// @param x A quaternion @@ -255,14 +254,14 @@ namespace detail float const & a); - /// Faster spherical linear interpolation of two unit length quaternions. - /// - /// This is the same as mix(), except for two rules: - /// 1) The two quaternions must be unit length. - /// 2) The interpolation factor (a) must be in the range [0, 1]. - /// - /// This will use the equivalent to fastAcos() and fastSin(). - /// + /// Faster spherical linear interpolation of two unit length quaternions. + /// + /// This is the same as mix(), except for two rules: + /// 1) The two quaternions must be unit length. + /// 2) The interpolation factor (a) must be in the range [0, 1]. + /// + /// This will use the equivalent to fastAcos() and fastSin(). + /// /// @see gtc_quaternion /// @see - mix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) detail::fquatSIMD fastMix( @@ -270,14 +269,14 @@ namespace detail detail::fquatSIMD const & y, float const & a); - /// Identical to fastMix() except takes the shortest path. - /// - /// The same rules apply here as those in fastMix(). Both quaternions must be unit length and 'a' must be - /// in the range [0, 1]. - /// + /// Identical to fastMix() except takes the shortest path. + /// + /// The same rules apply here as those in fastMix(). Both quaternions must be unit length and 'a' must be + /// in the range [0, 1]. + /// /// @see - fastMix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) /// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) - detail::fquatSIMD fastSlerp( + detail::fquatSIMD fastSlerp( detail::fquatSIMD const & x, detail::fquatSIMD const & y, float const & a); @@ -295,7 +294,7 @@ namespace detail detail::fquatSIMD inverse( detail::fquatSIMD const & q); - /// Build a quaternion from an angle and a normalized axis. + /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. /// @param axis Axis of the quaternion, must be normalized. @@ -305,7 +304,7 @@ namespace detail float const & angle, vec3 const & axis); - /// Build a quaternion from an angle and a normalized axis. + /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. /// @param x x component of the x-axis, x, y, z must be a normalized axis @@ -320,9 +319,9 @@ namespace detail float const & z); - // TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp(). - /// Performs the equivalent of glm::fastSin() on each component of the given __m128. - __m128 fastSin(__m128 x); + // TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp(). + /// Performs the equivalent of glm::fastSin() on each component of the given __m128. + __m128 fastSin(__m128 x); /// @} @@ -337,5 +336,3 @@ namespace detail #endif//(GLM_ARCH != GLM_ARCH_PURE) - -#endif//GLM_GTX_simd_quat diff --git a/glm/gtx/simd_vec4.hpp b/glm/gtx/simd_vec4.hpp index 6259b629..cc117a4b 100644 --- a/glm/gtx/simd_vec4.hpp +++ b/glm/gtx/simd_vec4.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_simd_vec4 -#define GLM_GTX_simd_vec4 +#pragma once // Dependency: #include "../glm.hpp" @@ -570,5 +569,3 @@ namespace detail #endif #endif//(GLM_ARCH != GLM_ARCH_PURE) - -#endif//GLM_GTX_simd_vec4 diff --git a/glm/gtx/spline.hpp b/glm/gtx/spline.hpp index d610bf7b..07d07b34 100644 --- a/glm/gtx/spline.hpp +++ b/glm/gtx/spline.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_spline -#define GLM_GTX_spline +#pragma once // Dependency: #include "../glm.hpp" @@ -85,6 +84,3 @@ namespace glm }//namespace glm #include "spline.inl" - -#endif//GLM_GTX_spline - diff --git a/glm/gtx/std_based_type.hpp b/glm/gtx/std_based_type.hpp index e13a17cb..f8597770 100644 --- a/glm/gtx/std_based_type.hpp +++ b/glm/gtx/std_based_type.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_std_based_type -#define GLM_GTX_std_based_type +#pragma once // Dependency: #include "../glm.hpp" @@ -79,5 +78,3 @@ namespace glm }//namespace glm #include "std_based_type.inl" - -#endif//GLM_GTX_std_based_type diff --git a/glm/gtx/string_cast.hpp b/glm/gtx/string_cast.hpp index bf73e7d3..9d2217bb 100644 --- a/glm/gtx/string_cast.hpp +++ b/glm/gtx/string_cast.hpp @@ -39,8 +39,7 @@ /// This extension is not supported with CUDA /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_string_cast -#define GLM_GTX_string_cast +#pragma once // Dependency: #include "../glm.hpp" @@ -70,5 +69,3 @@ namespace glm }//namespace glm #include "string_cast.inl" - -#endif//GLM_GTX_string_cast diff --git a/glm/gtx/transform.hpp b/glm/gtx/transform.hpp index bd932d03..03743c75 100644 --- a/glm/gtx/transform.hpp +++ b/glm/gtx/transform.hpp @@ -38,8 +38,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_transform -#define GLM_GTX_transform +#pragma once // Dependency: #include "../glm.hpp" @@ -80,5 +79,3 @@ namespace glm }// namespace glm #include "transform.inl" - -#endif//GLM_GTX_transform diff --git a/glm/gtx/transform2.hpp b/glm/gtx/transform2.hpp index 5c6adb24..4f8204ef 100644 --- a/glm/gtx/transform2.hpp +++ b/glm/gtx/transform2.hpp @@ -36,8 +36,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_transform2 -#define GLM_GTX_transform2 +#pragma once // Dependency: #include "../glm.hpp" @@ -131,5 +130,3 @@ namespace glm }// namespace glm #include "transform2.inl" - -#endif//GLM_GTX_transform2 diff --git a/glm/gtx/vec1.hpp b/glm/gtx/vec1.hpp index 035fc360..57e59e5e 100644 --- a/glm/gtx/vec1.hpp +++ b/glm/gtx/vec1.hpp @@ -34,8 +34,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_vec1 -#define GLM_GTX_vec1 +#pragma once // Dependency: #include "../glm.hpp" @@ -161,6 +160,3 @@ namespace glm }// namespace glm #include "vec1.inl" - -#endif//GLM_GTX_vec1 - diff --git a/glm/gtx/vector_angle.hpp b/glm/gtx/vector_angle.hpp index 0647bef2..ea663dfb 100644 --- a/glm/gtx/vector_angle.hpp +++ b/glm/gtx/vector_angle.hpp @@ -37,8 +37,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_vector_angle -#define GLM_GTX_vector_angle +#pragma once // Dependency: #include "../glm.hpp" @@ -84,5 +83,3 @@ namespace glm }// namespace glm #include "vector_angle.inl" - -#endif//GLM_GTX_vector_angle diff --git a/glm/gtx/vector_query.hpp b/glm/gtx/vector_query.hpp index e4ac2b5a..3d1dbfd0 100644 --- a/glm/gtx/vector_query.hpp +++ b/glm/gtx/vector_query.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_vector_query -#define GLM_GTX_vector_query +#pragma once // Dependency: #include "../glm.hpp" @@ -86,5 +85,3 @@ namespace glm }// namespace glm #include "vector_query.inl" - -#endif//GLM_GTX_vector_query diff --git a/glm/gtx/wrap.hpp b/glm/gtx/wrap.hpp index 8a157a51..2a11a9b7 100644 --- a/glm/gtx/wrap.hpp +++ b/glm/gtx/wrap.hpp @@ -35,8 +35,7 @@ /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_wrap -#define GLM_GTX_wrap +#pragma once // Dependency: #include "../glm.hpp" @@ -69,5 +68,3 @@ namespace glm }// namespace glm #include "wrap.inl" - -#endif//GLM_GTX_wrap diff --git a/glm/integer.hpp b/glm/integer.hpp index aa3f8e87..5f7c00a4 100644 --- a/glm/integer.hpp +++ b/glm/integer.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_INTEGER_INCLUDED -#define GLM_INTEGER_INCLUDED +#pragma once #include "detail/func_integer.hpp" - -#endif//GLM_INTEGER_INCLUDED diff --git a/glm/mat2x2.hpp b/glm/mat2x2.hpp index 57f7f808..b0870446 100644 --- a/glm/mat2x2.hpp +++ b/glm/mat2x2.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT2X2_INCLUDED -#define GLM_MAT2X2_INCLUDED +#pragma once #include "detail/type_mat2x2.hpp" @@ -76,5 +75,3 @@ namespace glm typedef detail::tmat2x2 highp_mat2x2; }//namespace glm - -#endif//GLM_MAT2X2_INCLUDED diff --git a/glm/mat2x3.hpp b/glm/mat2x3.hpp index ea020b06..0f50d57b 100644 --- a/glm/mat2x3.hpp +++ b/glm/mat2x3.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT2X3_INCLUDED -#define GLM_MAT2X3_INCLUDED +#pragma once #include "detail/type_mat2x3.hpp" @@ -56,4 +55,3 @@ namespace glm }//namespace glm -#endif//GLM_MAT2X3_INCLUDED diff --git a/glm/mat2x4.hpp b/glm/mat2x4.hpp index 24997012..8c8d136f 100644 --- a/glm/mat2x4.hpp +++ b/glm/mat2x4.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT2X4_INCLUDED -#define GLM_MAT2X4_INCLUDED +#pragma once #include "detail/type_mat2x4.hpp" @@ -55,5 +54,3 @@ namespace glm typedef detail::tmat2x4 highp_mat2x4; }//namespace glm - -#endif//GLM_MAT2X4_INCLUDED diff --git a/glm/mat3x2.hpp b/glm/mat3x2.hpp index 47c1ca4e..836829c7 100644 --- a/glm/mat3x2.hpp +++ b/glm/mat3x2.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT3X2_INCLUDED -#define GLM_MAT3X2_INCLUDED +#pragma once #include "detail/type_mat3x2.hpp" @@ -55,5 +54,3 @@ namespace glm typedef detail::tmat3x2 highp_mat3x2; }//namespace - -#endif//GLM_MAT3X2_INCLUDED diff --git a/glm/mat3x3.hpp b/glm/mat3x3.hpp index 5d7659c9..2ea61b7a 100644 --- a/glm/mat3x3.hpp +++ b/glm/mat3x3.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT3X3_INCLUDED -#define GLM_MAT3X3_INCLUDED +#pragma once #include "detail/type_mat3x3.hpp" @@ -76,5 +75,3 @@ namespace glm typedef detail::tmat3x3 highp_mat3x3; }//namespace glm - -#endif//GLM_MAT3X3_INCLUDED diff --git a/glm/mat3x4.hpp b/glm/mat3x4.hpp index 03b5fee3..66afb7fa 100644 --- a/glm/mat3x4.hpp +++ b/glm/mat3x4.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT3X4_INCLUDED -#define GLM_MAT3X4_INCLUDED +#pragma once #include "detail/type_mat3x4.hpp" @@ -55,5 +54,3 @@ namespace glm typedef detail::tmat3x4 highp_mat3x4; }//namespace glm - -#endif//GLM_MAT3X4_INCLUDED diff --git a/glm/mat4x2.hpp b/glm/mat4x2.hpp index 1e4671a0..1dc272e0 100644 --- a/glm/mat4x2.hpp +++ b/glm/mat4x2.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT4X2_INCLUDED -#define GLM_MAT4X2_INCLUDED +#pragma once #include "detail/type_mat4x2.hpp" @@ -55,5 +54,3 @@ namespace glm typedef detail::tmat4x2 highp_mat4x2; }//namespace glm - -#endif//GLM_MAT4X2_INCLUDED diff --git a/glm/mat4x3.hpp b/glm/mat4x3.hpp index 14ecee92..1d28b517 100644 --- a/glm/mat4x3.hpp +++ b/glm/mat4x3.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT4X3_INCLUDED -#define GLM_MAT4X3_INCLUDED +#pragma once #include "detail/type_mat4x3.hpp" @@ -55,5 +54,3 @@ namespace glm typedef detail::tmat4x3 highp_mat4x3; }//namespace glm - -#endif//GLM_MAT4X3_INCLUDED diff --git a/glm/mat4x4.hpp b/glm/mat4x4.hpp index 7e97af69..1d22846e 100644 --- a/glm/mat4x4.hpp +++ b/glm/mat4x4.hpp @@ -26,8 +26,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MAT4X4_INCLUDED -#define GLM_MAT4X4_INCLUDED +#pragma once #include "detail/type_mat4x4.hpp" @@ -76,5 +75,3 @@ namespace glm typedef detail::tmat4x4 highp_mat4x4; }//namespace glm - -#endif//GLM_MAT4X4_INCLUDED diff --git a/glm/matrix.hpp b/glm/matrix.hpp index 6758d81e..3b4bbb3f 100644 --- a/glm/matrix.hpp +++ b/glm/matrix.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_MATRIX_INCLUDED -#define GLM_MATRIX_INCLUDED +#pragma once #include "detail/func_matrix.hpp" - -#endif//GLM_MATRIX_INCLUDED diff --git a/glm/packing.hpp b/glm/packing.hpp index e7aa7888..d62de952 100644 --- a/glm/packing.hpp +++ b/glm/packing.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_PACKING_INCLUDED -#define GLM_PACKING_INCLUDED +#pragma once #include "detail/func_packing.hpp" - -#endif//GLM_PACKING_INCLUDED diff --git a/glm/trigonometric.hpp b/glm/trigonometric.hpp index 37a79130..51edc935 100644 --- a/glm/trigonometric.hpp +++ b/glm/trigonometric.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_TRIGONOMETRIC_INCLUDED -#define GLM_TRIGONOMETRIC_INCLUDED +#pragma once #include "detail/func_trigonometric.hpp" - -#endif//GLM_TRIGONOMETRIC_INCLUDED diff --git a/glm/vec2.hpp b/glm/vec2.hpp index 6c8df7a5..6d7e17c2 100644 --- a/glm/vec2.hpp +++ b/glm/vec2.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_VEC2_INCLUDED -#define GLM_VEC2_INCLUDED +#pragma once #include "detail/type_vec2.hpp" - -#endif//GLM_VEC2_INCLUDED diff --git a/glm/vec3.hpp b/glm/vec3.hpp index 2d017e1b..9e3a8fc0 100644 --- a/glm/vec3.hpp +++ b/glm/vec3.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_VEC3_INCLUDED -#define GLM_VEC3_INCLUDED +#pragma once #include "detail/type_vec3.hpp" - -#endif//GLM_VEC3_INCLUDED diff --git a/glm/vec4.hpp b/glm/vec4.hpp index 6d7e4199..6b58a2ee 100644 --- a/glm/vec4.hpp +++ b/glm/vec4.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_VEC4_INCLUDED -#define GLM_VEC4_INCLUDED +#pragma once #include "detail/type_vec4.hpp" - -#endif//GLM_VEC4_INCLUDED diff --git a/glm/vector_relational.hpp b/glm/vector_relational.hpp index 86faf394..a0f3fd5f 100644 --- a/glm/vector_relational.hpp +++ b/glm/vector_relational.hpp @@ -26,9 +26,6 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_VECTOR_RELATIONAL_INCLUDED -#define GLM_VECTOR_RELATIONAL_INCLUDED +#pragma once #include "detail/func_vector_relational.hpp" - -#endif//GLM_VECTOR_RELATIONAL_INCLUDED diff --git a/glm/virtrev/xstream.hpp b/glm/virtrev/xstream.hpp deleted file mode 100644 index 2d16c1ac..00000000 --- a/glm/virtrev/xstream.hpp +++ /dev/null @@ -1,166 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -/// 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 virtrev_xstream -/// @file glm/virtrev/xstream.hpp -/// @date 2008-05-24 / 2008-05-26 -/// @author Mathieu Roumillac (matrem84.free.fr) -/// -/// @see core (dependence) -/// @see gtc_matrix_access (dependence) -/// -/// @defgroup virtrev_xstream GLM_VIRTREV_xstream: xml like output -/// @ingroup virtrev -/// -/// @brief Streaming vector and matrix in a xml way. -/// -/// Include for this functionality. -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLM_VIRTREV_xstream -#define GLM_VIRTREV_xstream GLM_VERSION - -#include "../glm.hpp" -#include "../gtc/matrix_access.hpp" -#include - -#if(defined(GLM_MESSAGES) && !defined(glm_ext)) -# pragma message("GLM: GLM_VIRTREV_xstream extension included") -#endif -/* -namespace glm{ -namespace detail -{ - template - std::ostream & operator << (std::ostream & stream, glm::detail::tvec2 const & vec) - { - stream << ""; - - return stream; - } - - template - std::ostream & operator << (std::ostream & stream, glm::detail::tvec3 const & vec) - { - stream << ""; - - return stream; - } - - template - std::ostream & operator << (std::ostream & stream, glm::detail::tvec4 const & vec) - { - stream << ""; - - return stream; - } - - template - std::ostream & operator << (std::ostream & stream, glm::detail::tmat2x2 const & mat) - { - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << ""; - - return stream; - } - - template - std::ostream & operator << (std::ostream & stream, glm::detail::tmat3x3 const & mat) - { - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << ""; - - return stream; - } - - template - std::ostream & operator << (std::ostream & stream, glm::detail::tmat4x4 const & mat) - { - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << "" << std::endl; - stream << ""; - - return stream; - } - -}//namespace detail -}//namespace glm -*/ -#endif//GLM_VIRTREV_xstream diff --git a/readme.txt b/readme.txt index 5d77323e..9dc64ad1 100644 --- a/readme.txt +++ b/readme.txt @@ -43,13 +43,37 @@ GLM 0.9.6.0: 2014-XX-XX - Removed degrees for function parameters - Removed GLM_FORCE_RADIANS, active by default - Added move contructors and assignment operators (#141) +- Use pragma once +- Fixed Visual Studio 14 compiler warnings ================================================================================ -GLM 0.9.5.4: 2014-0X-XX +GLM 0.9.5.5: 2014-XX-XX +-------------------------------------------------------------------------------- +- Fixed std::nextafter not supported with C++11 on Android #213 +- Fixed missing value_type for dual quaternion +- Fixed return type of dual quaternion length + +================================================================================ +GLM 0.9.5.4: 2014-06-21 -------------------------------------------------------------------------------- - Fixed non-utf8 character #196 - Added FindGLM install for CMake #189 - Fixed GTX_color_space - saturation #195 +- Fixed glm::isinf and glm::isnan for with Android NDK 9d #191 +- Fixed builtin GLM_ARCH_SSE4 #204 +- Optimized Quaternion vector rotation #205 +- Fixed missing doxygen @endcond tag #211 +- Fixed instruction set detection with Clang #158 +- Fixed orientate3 function #207 +- Fixed lerp when cosTheta is close to 1 in quaternion slerp #210 +- Added GTX_io for io with #144 +- Fixed fastDistance ambiguity #215 +- Fixed tweakedInfinitePerspective #208 and added user-defined epsilon to + tweakedInfinitePerspective +- Fixed std::copy and std::vector with GLM types #214 +- Fixed strict aliasing issues #212, #152 +- Fixed std::nextafter not supported with C++11 on Android #213 +- Fixed corner cases in exp and log functions for quaternions #199 ================================================================================ GLM 0.9.5.3: 2014-04-02 diff --git a/test/core/core_func_matrix.cpp b/test/core/core_func_matrix.cpp index 1b609f32..5c95672c 100644 --- a/test/core/core_func_matrix.cpp +++ b/test/core/core_func_matrix.cpp @@ -228,10 +228,10 @@ int test_inverse_perf(std::size_t Instance, char const * Message) //glm::uint Ulp = 0; //Ulp = glm::max(glm::float_distance(*Dst, *Src), Ulp); - printf("inverse<%s>(%f): %d\n", Message, Diff, EndTime - StartTime); + printf("inverse<%s>(%f): %lu\n", Message, Diff, EndTime - StartTime); return 0; -}; +} int main() { diff --git a/test/core/core_type_cast.cpp b/test/core/core_type_cast.cpp index 7c002886..97e2fdd6 100644 --- a/test/core/core_type_cast.cpp +++ b/test/core/core_type_cast.cpp @@ -9,6 +9,9 @@ #define GLM_FORCE_RADIANS #include +#include +#include +#include struct my_vec2 { @@ -86,10 +89,63 @@ int test_vec4_cast() return Error; } +int test_std_copy() +{ + int Error = 0; + + { + std::vector High; + High.resize(64); + std::vector Medium(High.size()); + + std::copy(High.begin(), High.end(), Medium.begin()); + + *Medium.begin() = *High.begin(); + } + + { + std::vector High4; + High4.resize(64); + std::vector Medium4(High4.size()); + + std::copy(High4.begin(), High4.end(), Medium4.begin()); + + *Medium4.begin() = *High4.begin(); + } + + { + std::vector High3; + High3.resize(64); + std::vector Medium3(High3.size()); + + std::copy(High3.begin(), High3.end(), Medium3.begin()); + + *Medium3.begin() = *High3.begin(); + } + + { + std::vector High2; + High2.resize(64); + std::vector Medium2(High2.size()); + + std::copy(High2.begin(), High2.end(), Medium2.begin()); + + *Medium2.begin() = *High2.begin(); + } + + glm::dvec4 v1; + glm::vec4 v2; + + v2 = v1; + + return Error; +} + int main() { int Error = 0; + Error += test_std_copy(); Error += test_vec2_cast(); Error += test_vec3_cast(); Error += test_vec4_cast(); diff --git a/test/gtc/gtc_matrix_transform.cpp b/test/gtc/gtc_matrix_transform.cpp index 05d5f50e..0ea54598 100644 --- a/test/gtc/gtc_matrix_transform.cpp +++ b/test/gtc/gtc_matrix_transform.cpp @@ -11,16 +11,54 @@ #include #include -int main() +int test_perspective() { int Error = 0; - + glm::mat4 Projection = glm::perspective(glm::pi() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); + + return Error; +} + +int test_pick() +{ + int Error = 0; + glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240)); + return Error; +} + +int test_tweakedInfinitePerspective() +{ + int Error = 0; + + glm::mat4 ProjectionA = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f); + glm::mat4 ProjectionB = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f, 0.001f); + + + return Error; +} + +int test_translate() +{ + int Error = 0; + glm::lowp_vec3 v(1.0); glm::lowp_mat4 m(0); glm::lowp_mat4 t = glm::translate(m, v); return Error; } + +int main() +{ + int Error = 0; + + Error += test_translate(); + Error += test_tweakedInfinitePerspective(); + Error += test_pick(); + Error += test_perspective(); + + return Error; +} diff --git a/test/gtc/gtc_packing.cpp b/test/gtc/gtc_packing.cpp index 8acfb74f..ceec3dd2 100644 --- a/test/gtc/gtc_packing.cpp +++ b/test/gtc/gtc_packing.cpp @@ -100,7 +100,7 @@ int test_Half1x16() glm::uint32 p0 = glm::packHalf1x16(Tests[i]); float v0 = glm::unpackHalf1x16(p0); glm::uint32 p1 = glm::packHalf1x16(v0); - float v1 = glm::unpackHalf1x16(p0); + float v1 = glm::unpackHalf1x16(p1); Error += (v0 == v1) ? 0 : 1; } @@ -124,7 +124,7 @@ int test_Half4x16() glm::uint64 p0 = glm::packHalf4x16(Tests[i]); glm::vec4 v0 = glm::unpackHalf4x16(p0); glm::uint64 p1 = glm::packHalf4x16(v0); - glm::vec4 v1 = glm::unpackHalf4x16(p0); + glm::vec4 v1 = glm::unpackHalf4x16(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } @@ -148,7 +148,7 @@ int test_I3x10_1x2() glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]); glm::ivec4 v0 = glm::unpackI3x10_1x2(p0); glm::uint32 p1 = glm::packI3x10_1x2(v0); - glm::ivec4 v1 = glm::unpackI3x10_1x2(p0); + glm::ivec4 v1 = glm::unpackI3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } @@ -172,7 +172,7 @@ int test_U3x10_1x2() glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]); glm::uvec4 v0 = glm::unpackU3x10_1x2(p0); glm::uint32 p1 = glm::packU3x10_1x2(v0); - glm::uvec4 v1 = glm::unpackU3x10_1x2(p0); + glm::uvec4 v1 = glm::unpackU3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } @@ -196,7 +196,7 @@ int test_Snorm3x10_1x2() glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]); glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0); glm::uint32 p1 = glm::packSnorm3x10_1x2(v0); - glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0); + glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } @@ -220,7 +220,7 @@ int test_Unorm3x10_1x2() glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]); glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0); glm::uint32 p1 = glm::packSnorm3x10_1x2(v0); - glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0); + glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } @@ -244,7 +244,7 @@ int test_F2x11_1x10() glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]); glm::vec3 v0 = glm::unpackF2x11_1x10(p0); glm::uint32 p1 = glm::packF2x11_1x10(v0); - glm::vec3 v1 = glm::unpackF2x11_1x10(p0); + glm::vec3 v1 = glm::unpackF2x11_1x10(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 4346e8fc..fab238af 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -196,6 +196,15 @@ int test_quat_slerp() // Must be 0 0.00X 0 0.99999 glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, glm::vec3(0.0f, 1.0f, 0.0f)), 0.5f); + // Testing quaternions with opposite sign + { + glm::quat a(-1, 0, 0, 0); + + glm::quat result = glm::slerp(a, id, 0.5f); + + Error += glm::epsilonEqual(glm::pow(glm::dot(id, result), 2.f), 1.f, 0.01f) ? 0 : 1; + } + return Error; } @@ -247,6 +256,20 @@ int test_quat_type() return 0; } +int test_quat_mul_vec() +{ + int Error(0); + + glm::quat q = glm::angleAxis(glm::pi() * 0.5f, glm::vec3(0, 0, 1)); + glm::vec3 v(1, 0, 0); + glm::vec3 u(q * v); + glm::vec3 w(u * q); + + Error += glm::all(glm::epsilonEqual(v, w, 0.01f)) ? 0 : 1; + + return Error; +} + int test_quat_ctr() { int Error(0); @@ -269,6 +292,7 @@ int main() int Error(0); Error += test_quat_ctr(); + Error += test_quat_mul_vec(); Error += test_quat_two_axis_ctr(); Error += test_quat_mul(); Error += test_quat_precision(); diff --git a/test/gtx/gtx_fast_square_root.cpp b/test/gtx/gtx_fast_square_root.cpp index 788b341c..b9d41dcd 100644 --- a/test/gtx/gtx_fast_square_root.cpp +++ b/test/gtx/gtx_fast_square_root.cpp @@ -27,11 +27,29 @@ int test_fastInverseSqrt() return 0; } +int test_fastDistance() +{ + int Error(0); + + glm::mediump_f32 A = glm::fastDistance(glm::mediump_f32(0.0f), glm::mediump_f32(1.0f)); + glm::mediump_f32 B = glm::fastDistance(glm::mediump_f32vec2(0.0f), glm::mediump_f32vec2(1.0f, 0.0f)); + glm::mediump_f32 C = glm::fastDistance(glm::mediump_f32vec3(0.0f), glm::mediump_f32vec3(1.0f, 0.0f, 0.0f)); + glm::mediump_f32 D = glm::fastDistance(glm::mediump_f32vec4(0.0f), glm::mediump_f32vec4(1.0f, 0.0f, 0.0f, 0.0f)); + + Error += glm::epsilonEqual(A, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; + Error += glm::epsilonEqual(B, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; + Error += glm::epsilonEqual(C, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; + Error += glm::epsilonEqual(D, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; + + return Error; +} + int main() { int Error(0); Error += test_fastInverseSqrt(); + Error += test_fastDistance(); return Error; } diff --git a/test/gtx/gtx_io.cpp b/test/gtx/gtx_io.cpp index 05ba8e9b..6fcaa60e 100644 --- a/test/gtx/gtx_io.cpp +++ b/test/gtx/gtx_io.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace { @@ -32,8 +33,60 @@ namespace { return os; } + template + std::basic_string + type_name(std::basic_ostream& os, T const&) + { + std::basic_ostringstream ostr; + + if (typeid(T) == typeid(glm::detail::tquat)) { ostr << "quat"; } + else if (typeid(T) == typeid(glm::detail::tvec2)) { ostr << "vec2"; } + else if (typeid(T) == typeid(glm::detail::tvec3)) { ostr << "vec3"; } + else if (typeid(T) == typeid(glm::detail::tvec4)) { ostr << "vec4"; } + else if (typeid(T) == typeid(glm::detail::tmat2x2)) { ostr << "mat2x2"; } + else if (typeid(T) == typeid(glm::detail::tmat2x3)) { ostr << "mat2x3"; } + else if (typeid(T) == typeid(glm::detail::tmat2x4)) { ostr << "mat2x4"; } + else if (typeid(T) == typeid(glm::detail::tmat3x2)) { ostr << "mat3x2"; } + else if (typeid(T) == typeid(glm::detail::tmat3x3)) { ostr << "mat3x3"; } + else if (typeid(T) == typeid(glm::detail::tmat3x4)) { ostr << "mat3x4"; } + else if (typeid(T) == typeid(glm::detail::tmat4x2)) { ostr << "mat4x2"; } + else if (typeid(T) == typeid(glm::detail::tmat4x3)) { ostr << "mat4x3"; } + else if (typeid(T) == typeid(glm::detail::tmat4x4)) { ostr << "mat4x4"; } + else { ostr << "unknown"; } + + ostr << '<' << typeid(U).name() << ',' << P << '>'; + + return ostr.str(); + } + } // namespace { +template +int test_io_quat(OS& os) +{ + os << '\n' + << typeid(OS).name() + << '\n'; + + glm::detail::tquat const q(1, 0, 0, 0); + + { + glm::io::basic_format_saver const iofs(os); + + os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2) + << type_name(os, q) << ": " << q << '\n'; + } + + { + glm::io::basic_format_saver const iofs(os); + + os << glm::io::unformatted + << type_name(os, q) << ": " << q << '\n'; + } + + return 0; +} + template int test_io_vec(OS& os) { @@ -45,18 +98,16 @@ int test_io_vec(OS& os) glm::detail::tvec3 const v3(2, 3, 4); glm::detail::tvec4 const v4(5, 6, 7, 8); - os << "vec2<" << typeid(T).name() << ',' << P << ">: " << v2 << '\n' - << "vec3<" << typeid(T).name() << ',' << P << ">: " << v3 << '\n' - << "vec4<" << typeid(T).name() << ',' << P << ">: " << v4 << '\n'; + os << type_name(os, v2) << ": " << v2 << '\n' + << type_name(os, v3) << ": " << v3 << '\n' + << type_name(os, v4) << ": " << v4 << '\n'; - glm::io::precision_guard const iopg; + glm::io::basic_format_saver const iofs(os); - glm::io::precision() = 2; - glm::io::value_width() = 1 + 2 + 1 + glm::io::precision(); - - os << "vec2<" << typeid(T).name() << ',' << P << ">: " << v2 << '\n' - << "vec3<" << typeid(T).name() << ',' << P << ">: " << v3 << '\n' - << "vec4<" << typeid(T).name() << ',' << P << ">: " << v4 << '\n'; + os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2) + << type_name(os, v2) << ": " << v2 << '\n' + << type_name(os, v3) << ": " << v3 << '\n' + << type_name(os, v4) << ": " << v4 << '\n'; return 0; } @@ -93,12 +144,10 @@ int test_io_mat(OS& os) << "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat4x4(v4_1, v4_2, v4_3, v4_4) << '\n'; #endif - glm::io::precision_guard const iopg; + glm::io::basic_format_saver const iofs(os); - glm::io::precision() = 2; - glm::io::value_width() = 1 + 2 + 1 + glm::io::precision(); - - os << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x2(v2_1, v2_2) << '\n' + os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2) + << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x2(v2_1, v2_2) << '\n' << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x3(v3_1, v3_2) << '\n' << "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x4(v4_1, v4_2) << '\n' << "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat3x2(v2_1, v2_2, v2_3) << '\n' @@ -108,7 +157,8 @@ int test_io_mat(OS& os) << "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat4x3(v3_1, v3_2, v3_3, v3_4) << '\n' << "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat4x4(v4_1, v4_2, v4_3, v4_4) << '\n'; - os << glm::io::column_major + os << glm::io::unformatted + << glm::io::order(glm::io::column_major) << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x2(v2_1, v2_2) << '\n' << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x3(v3_1, v3_2) << '\n' << "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x4(v4_1, v4_2) << '\n' @@ -126,6 +176,13 @@ int main() { int Error(0); + Error += test_io_quat(std::cout); + Error += test_io_quat(std::wcout); + Error += test_io_quat(std::cout); + Error += test_io_quat(std::wcout); + Error += test_io_quat(std::cout); + Error += test_io_quat(std::wcout); + Error += test_io_vec(std::cout); Error += test_io_vec(std::wcout); Error += test_io_vec(std::cout);