diff --git a/doc/glm.docx b/doc/glm.docx index 9195d3b6..56eb20b2 100644 Binary files a/doc/glm.docx and b/doc/glm.docx differ diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 01d4525e..25b4212b 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -133,8 +133,6 @@ // GCC defines #define GLM_COMPILER_GCC 0x02000000 -#define GLM_COMPILER_GCC_LLVM 0x02000001 -#define GLM_COMPILER_GCC_CLANG 0x02000002 #define GLM_COMPILER_GCC34 0x02000050 #define GLM_COMPILER_GCC35 0x02000060 #define GLM_COMPILER_GCC40 0x02000070 @@ -588,49 +586,6 @@ # endif//GLM_ARCH #endif//GLM_MESSAGE -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Support check macros - -#define GLM_SUPPORT_ANONYMOUS_UNION() \ - (GLM_LANG & GLM_LANG_CXX98_FLAG) - -#define GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() \ - ((GLM_LANG & GLM_LANG_CXXMS_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC)) - -#define GLM_SUPPORT_SWIZZLE_OPERATOR() \ - (defined(GLM_SWIZZLE) && GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE()) - -#define GLM_SUPPORT_SWIZZLE_FUNCTION() defined(GLM_SWIZZLE) - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Components - -//#define GLM_FORCE_ONLY_XYZW -#define GLM_COMPONENT_ONLY_XYZW 0 // To disable multiple vector component names access. -#define GLM_COMPONENT_CXX98 1 // -#define GLM_COMPONENT_CXXMS 2 // To use anonymous union to provide multiple component names access for class valType. Visual C++ only. - -#if(GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() && !defined(GLM_FORCE_ONLY_XYZW)) -# define GLM_COMPONENT GLM_COMPONENT_CXXMS -#elif(GLM_SUPPORT_ANONYMOUS_UNION() && !defined(GLM_FORCE_ONLY_XYZW)) -# define GLM_COMPONENT GLM_COMPONENT_CXX98 -#else -# define GLM_COMPONENT GLM_COMPONENT_ONLY_XYZW -#endif - -#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPONENT_DISPLAYED)) -# define GLM_MESSAGE_COMPONENT_DISPLAYED -# if(GLM_COMPONENT == GLM_COMPONENT_CXX98) -# pragma message("GLM: x,y,z,w; r,g,b,a; s,t,p,q component names except of half based vector types") -# elif(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) -# pragma message("GLM: x,y,z,w component names for all vector types") -# elif(GLM_COMPONENT == GLM_COMPONENT_CXXMS) -# pragma message("GLM: x,y,z,w; r,g,b,a; s,t,p,q component names for all vector types") -# else -# error "GLM: GLM_COMPONENT value unknown" -# endif//GLM_MESSAGE_COMPONENT_DISPLAYED -#endif//GLM_MESSAGE - /////////////////////////////////////////////////////////////////////////////////////////////////// // Radians @@ -693,10 +648,8 @@ #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) # define GLM_MESSAGE_SWIZZLE_DISPLAYED -# if(GLM_SUPPORT_SWIZZLE_OPERATOR()) +# if defined(GLM_SWIZZLE) # pragma message("GLM: Swizzling operators enabled") -# elif(GLM_SUPPORT_SWIZZLE_FUNCTION()) -# pragma message("GLM: Swizzling operators supported through swizzling functions") # else # pragma message("GLM: Swizzling operators disabled") # endif @@ -719,7 +672,7 @@ # define GLM_RESTRICT # define GLM_RESTRICT_VAR __restrict # define GLM_CONSTEXPR -#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG)) +#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC34)) || (GLM_COMPILER & GLM_COMPILER_CLANG)) # define GLM_DEPRECATED __attribute__((__deprecated__)) # define GLM_ALIGN(x) __attribute__((aligned(x))) # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x))) diff --git a/glm/core/type_mat2x2.hpp b/glm/core/type_mat2x2.hpp index 638e848b..38ec7214 100644 --- a/glm/core/type_mat2x2.hpp +++ b/glm/core/type_mat2x2.hpp @@ -65,8 +65,9 @@ namespace detail ////////////////////////////////////// // Constructors GLM_FUNC_DECL tmat2x2(); - GLM_FUNC_DECL tmat2x2( - tmat2x2 const & m); + GLM_FUNC_DECL tmat2x2(tmat2x2 const & m); + template + GLM_FUNC_DECL tmat2x2(tmat2x2 const & m); GLM_FUNC_DECL explicit tmat2x2( ctor Null); diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index 12e40677..2271ff7e 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -92,6 +92,15 @@ namespace detail this->value[1] = m.value[1]; } + template + template + GLM_FUNC_QUALIFIER tmat2x2::tmat2x2( + tmat2x2 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + } + template GLM_FUNC_QUALIFIER tmat2x2::tmat2x2 ( @@ -133,7 +142,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat2x2::tmat2x2 diff --git a/glm/core/type_mat2x3.hpp b/glm/core/type_mat2x3.hpp index 57576039..f1d8f9cb 100644 --- a/glm/core/type_mat2x3.hpp +++ b/glm/core/type_mat2x3.hpp @@ -58,7 +58,9 @@ namespace detail public: // Constructors GLM_FUNC_DECL tmat2x3(); - GLM_FUNC_DECL tmat2x3(tmat2x3 const & m); + GLM_FUNC_DECL tmat2x3(tmat2x3 const & m); + template + GLM_FUNC_DECL tmat2x3(tmat2x3 const & m); GLM_FUNC_DECL explicit tmat2x3( ctor); diff --git a/glm/core/type_mat2x3.inl b/glm/core/type_mat2x3.inl index 4f6d1934..c0343dae 100644 --- a/glm/core/type_mat2x3.inl +++ b/glm/core/type_mat2x3.inl @@ -92,6 +92,15 @@ namespace detail this->value[1] = m.value[1]; } + template + template + GLM_FUNC_QUALIFIER tmat2x3::tmat2x3( + tmat2x3 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + } + template GLM_FUNC_QUALIFIER tmat2x3::tmat2x3 ( @@ -132,7 +141,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat2x3::tmat2x3 diff --git a/glm/core/type_mat2x4.hpp b/glm/core/type_mat2x4.hpp index a3218da5..30d48b9b 100644 --- a/glm/core/type_mat2x4.hpp +++ b/glm/core/type_mat2x4.hpp @@ -58,7 +58,9 @@ namespace detail public: // Constructors GLM_FUNC_DECL tmat2x4(); - GLM_FUNC_DECL tmat2x4(tmat2x4 const & m); + GLM_FUNC_DECL tmat2x4(tmat2x4 const & m); + template + GLM_FUNC_DECL tmat2x4(tmat2x4 const & m); GLM_FUNC_DECL explicit tmat2x4( ctor); diff --git a/glm/core/type_mat2x4.inl b/glm/core/type_mat2x4.inl index 75069041..f0cd3ad1 100644 --- a/glm/core/type_mat2x4.inl +++ b/glm/core/type_mat2x4.inl @@ -94,6 +94,15 @@ namespace detail this->value[1] = m.value[1]; } + template + template + GLM_FUNC_QUALIFIER tmat2x4::tmat2x4( + tmat2x4 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + } + template GLM_FUNC_QUALIFIER tmat2x4::tmat2x4 ( @@ -135,7 +144,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat2x4::tmat2x4 diff --git a/glm/core/type_mat3x2.hpp b/glm/core/type_mat3x2.hpp index 22d5a7e1..afbf9f03 100644 --- a/glm/core/type_mat3x2.hpp +++ b/glm/core/type_mat3x2.hpp @@ -59,6 +59,8 @@ namespace detail // Constructors GLM_FUNC_DECL tmat3x2(); GLM_FUNC_DECL tmat3x2(tmat3x2 const & m); + template + GLM_FUNC_DECL tmat3x2(tmat3x2 const & m); GLM_FUNC_DECL explicit tmat3x2( ctor); diff --git a/glm/core/type_mat3x2.inl b/glm/core/type_mat3x2.inl index ad174850..624f7587 100644 --- a/glm/core/type_mat3x2.inl +++ b/glm/core/type_mat3x2.inl @@ -94,6 +94,16 @@ namespace detail this->value[2] = m.value[2]; } + template + template + GLM_FUNC_QUALIFIER tmat3x2::tmat3x2( + tmat3x2 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + this->value[2] = m.value[2]; + } + template GLM_FUNC_QUALIFIER tmat3x2::tmat3x2 ( @@ -139,7 +149,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat3x2::tmat3x2 diff --git a/glm/core/type_mat3x3.hpp b/glm/core/type_mat3x3.hpp index 2384e35e..4fa8bff4 100644 --- a/glm/core/type_mat3x3.hpp +++ b/glm/core/type_mat3x3.hpp @@ -65,6 +65,8 @@ namespace detail // Constructors GLM_FUNC_DECL tmat3x3(); GLM_FUNC_DECL tmat3x3(tmat3x3 const & m); + template + GLM_FUNC_DECL tmat3x3(tmat3x3 const & m); GLM_FUNC_DECL explicit tmat3x3( ctor Null); diff --git a/glm/core/type_mat3x3.inl b/glm/core/type_mat3x3.inl index d36518f3..c9ef9dc0 100644 --- a/glm/core/type_mat3x3.inl +++ b/glm/core/type_mat3x3.inl @@ -103,6 +103,16 @@ namespace detail ) {} + template + template + GLM_FUNC_QUALIFIER tmat3x3::tmat3x3( + tmat3x3 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + this->value[2] = m.value[2]; + } + template GLM_FUNC_QUALIFIER tmat3x3::tmat3x3 ( @@ -142,7 +152,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat3x3::tmat3x3 diff --git a/glm/core/type_mat3x4.hpp b/glm/core/type_mat3x4.hpp index fb0242a2..2d72d2fb 100644 --- a/glm/core/type_mat3x4.hpp +++ b/glm/core/type_mat3x4.hpp @@ -58,7 +58,9 @@ namespace detail public: // Constructors GLM_FUNC_DECL tmat3x4(); - GLM_FUNC_DECL tmat3x4(tmat3x4 const & m); + GLM_FUNC_DECL tmat3x4(tmat3x4 const & m); + template + GLM_FUNC_DECL tmat3x4(tmat3x4 const & m); GLM_FUNC_DECL explicit tmat3x4( ctor Null); diff --git a/glm/core/type_mat3x4.inl b/glm/core/type_mat3x4.inl index 2a3839cf..e014da41 100644 --- a/glm/core/type_mat3x4.inl +++ b/glm/core/type_mat3x4.inl @@ -94,6 +94,16 @@ namespace detail this->value[2] = m.value[2]; } + template + template + GLM_FUNC_QUALIFIER tmat3x4::tmat3x4( + tmat3x4 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + this->value[2] = m.value[2]; + } + template GLM_FUNC_QUALIFIER tmat3x4::tmat3x4 ( @@ -140,7 +150,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat3x4::tmat3x4 diff --git a/glm/core/type_mat4x2.hpp b/glm/core/type_mat4x2.hpp index ce6557a4..80ba7da8 100644 --- a/glm/core/type_mat4x2.hpp +++ b/glm/core/type_mat4x2.hpp @@ -58,7 +58,9 @@ namespace detail public: // Constructors GLM_FUNC_DECL tmat4x2(); - GLM_FUNC_DECL tmat4x2(tmat4x2 const & m); + GLM_FUNC_DECL tmat4x2(tmat4x2 const & m); + template + GLM_FUNC_DECL tmat4x2(tmat4x2 const & m); GLM_FUNC_DECL explicit tmat4x2( ctor Null); diff --git a/glm/core/type_mat4x2.inl b/glm/core/type_mat4x2.inl index 0d93542a..0a64b922 100644 --- a/glm/core/type_mat4x2.inl +++ b/glm/core/type_mat4x2.inl @@ -87,10 +87,8 @@ namespace detail } template - GLM_FUNC_QUALIFIER tmat4x2::tmat4x2 - ( - tmat4x2 const & m - ) + GLM_FUNC_QUALIFIER tmat4x2::tmat4x2( + tmat4x2 const & m) { this->value[0] = m.value[0]; this->value[1] = m.value[1]; @@ -99,10 +97,18 @@ namespace detail } template - GLM_FUNC_QUALIFIER tmat4x2::tmat4x2 - ( - ctor - ) + template + GLM_FUNC_QUALIFIER tmat4x2::tmat4x2( + tmat4x2 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + this->value[2] = m.value[2]; + this->value[3] = m.value[3]; + } + + template + GLM_FUNC_QUALIFIER tmat4x2::tmat4x2(ctor) {} template @@ -149,7 +155,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat4x2::tmat4x2 diff --git a/glm/core/type_mat4x3.hpp b/glm/core/type_mat4x3.hpp index 536f9286..795cbec7 100644 --- a/glm/core/type_mat4x3.hpp +++ b/glm/core/type_mat4x3.hpp @@ -58,7 +58,9 @@ namespace detail public: // Constructors GLM_FUNC_DECL tmat4x3(); - GLM_FUNC_DECL tmat4x3(tmat4x3 const & m); + GLM_FUNC_DECL tmat4x3(tmat4x3 const & m); + template + GLM_FUNC_DECL tmat4x3(tmat4x3 const & m); GLM_FUNC_DECL explicit tmat4x3( ctor Null); diff --git a/glm/core/type_mat4x3.inl b/glm/core/type_mat4x3.inl index 807060c2..5f8b6757 100644 --- a/glm/core/type_mat4x3.inl +++ b/glm/core/type_mat4x3.inl @@ -87,10 +87,19 @@ namespace detail } template - GLM_FUNC_QUALIFIER tmat4x3::tmat4x3 - ( - tmat4x3 const & m - ) + GLM_FUNC_QUALIFIER tmat4x3::tmat4x3( + tmat4x3 const & m) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + this->value[2] = m.value[2]; + this->value[3] = m.value[3]; + } + + template + template + GLM_FUNC_QUALIFIER tmat4x3::tmat4x3( + tmat4x3 const & m) { this->value[0] = m.value[0]; this->value[1] = m.value[1]; @@ -99,17 +108,12 @@ namespace detail } template - GLM_FUNC_QUALIFIER tmat4x3::tmat4x3 - ( - ctor - ) + GLM_FUNC_QUALIFIER tmat4x3::tmat4x3(ctor) {} template - GLM_FUNC_QUALIFIER tmat4x3::tmat4x3 - ( - value_type const & s - ) + GLM_FUNC_QUALIFIER tmat4x3::tmat4x3( + value_type const & s) { value_type const Zero(0); this->value[0] = col_type(s, Zero, Zero); @@ -149,7 +153,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat4x3::tmat4x3 diff --git a/glm/core/type_mat4x4.hpp b/glm/core/type_mat4x4.hpp index dc026939..39ce60d7 100644 --- a/glm/core/type_mat4x4.hpp +++ b/glm/core/type_mat4x4.hpp @@ -64,7 +64,9 @@ namespace detail public: // Constructors GLM_FUNC_DECL tmat4x4(); - GLM_FUNC_DECL tmat4x4(tmat4x4 const & m); + GLM_FUNC_DECL tmat4x4(tmat4x4 const & m); + template + GLM_FUNC_DECL tmat4x4(tmat4x4 const & m); GLM_FUNC_DECL explicit tmat4x4( ctor Null); diff --git a/glm/core/type_mat4x4.inl b/glm/core/type_mat4x4.inl index ba9680f6..e93583cc 100644 --- a/glm/core/type_mat4x4.inl +++ b/glm/core/type_mat4x4.inl @@ -98,6 +98,19 @@ namespace detail this->value[3] = m.value[3]; } + template + template + GLM_FUNC_QUALIFIER tmat4x4::tmat4x4 + ( + tmat4x4 const & m + ) + { + this->value[0] = m.value[0]; + this->value[1] = m.value[1]; + this->value[2] = m.value[2]; + this->value[3] = m.value[3]; + } + template GLM_FUNC_QUALIFIER tmat4x4::tmat4x4 ( @@ -162,7 +175,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors template template GLM_FUNC_DECL tmat4x4::tmat4x4 diff --git a/glm/core/type_vec1.hpp b/glm/core/type_vec1.hpp index 7a24d3ba..3bba2fa7 100644 --- a/glm/core/type_vec1.hpp +++ b/glm/core/type_vec1.hpp @@ -68,6 +68,8 @@ namespace detail GLM_FUNC_DECL tvec1(); GLM_FUNC_DECL tvec1(tvec1 const & v); + template + GLM_FUNC_DECL tvec1(tvec1 const & v); ////////////////////////////////////// // Explicit basic constructors @@ -83,14 +85,14 @@ namespace detail GLM_FUNC_DECL tvec1(tref1 const & r); ////////////////////////////////////// - // Convertion scalar constructors + // Conversion scalar constructors //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL explicit tvec1(U const & s); ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template diff --git a/glm/core/type_vec1.inl b/glm/core/type_vec1.inl index 18255d2c..9acb879d 100644 --- a/glm/core/type_vec1.inl +++ b/glm/core/type_vec1.inl @@ -69,14 +69,16 @@ namespace detail template GLM_FUNC_QUALIFIER tvec1::tvec1 ( - ctor - ) + tvec1 const & v + ) : + x(v.x) {} template + template GLM_FUNC_QUALIFIER tvec1::tvec1 ( - tvec1 const & v + tvec1 const & v ) : x(v.x) {} @@ -84,6 +86,13 @@ namespace detail ////////////////////////////////////// // Explicit basic constructors + template + GLM_FUNC_QUALIFIER tvec1::tvec1 + ( + ctor + ) + {} + template GLM_FUNC_QUALIFIER tvec1::tvec1 ( @@ -104,7 +113,7 @@ namespace detail {} ////////////////////////////////////// - // Convertion scalar constructors + // Conversion scalar constructors template template @@ -116,7 +125,7 @@ namespace detail {} ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors template template diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index 0c6e604f..8da617b4 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -22,7 +22,7 @@ /// /// @ref core /// @file glm/core/type_vec2.hpp -/// @date 2008-08-18 / 2011-06-15 +/// @date 2008-08-18 / 2013-08-27 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// @@ -51,43 +51,32 @@ namespace detail ////////////////////////////////////// // Data -# if(GLM_COMPONENT == GLM_COMPONENT_CXXMS) - union - { - struct{value_type x, y;}; - struct{value_type r, g;}; - struct{value_type s, t;}; +# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE)) + union + { + struct{ value_type x, y; }; + struct{ value_type r, g; }; + struct{ value_type s, t; }; -# if(defined(GLM_SWIZZLE)) - _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, x, y) - _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, r, g) - _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, s, t) - _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, x, y) - _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, r, g) - _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, s, t) - _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, x, y) - _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, r, g) - _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, s, t) -# endif//(defined(GLM_SWIZZLE)) - }; -# elif(GLM_COMPONENT == GLM_COMPONENT_CXX98) - union {value_type x, r, s;}; - union {value_type y, g, t;}; + _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, x, y) + _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, r, g) + _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, s, t) + _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, x, y) + _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, r, g) + _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, s, t) + _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, x, y) + _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, r, g) + _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, s, t) + }; +# else + union {value_type x, r, s;}; + union {value_type y, g, t;}; -# if(defined(GLM_SWIZZLE)) - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, P, detail::tvec2, detail::tref2) - GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, P, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4) -# endif//(defined(GLM_SWIZZLE)) -# else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) - value_type x, y; - -# if(defined(GLM_SWIZZLE)) - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(value_type, P, detail::tvec2, detail::tref2, x, y) - GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(value_type, P, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4, x, y) -# endif//(defined(GLM_SWIZZLE)) -# endif//GLM_COMPONENT +# if(defined(GLM_SWIZZLE)) + //GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, P, detail::tvec2, detail::tref2) + GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, P, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4) +# endif//(defined(GLM_SWIZZLE)) +# endif//GLM_LANG ////////////////////////////////////// // Accesses @@ -100,6 +89,8 @@ namespace detail GLM_FUNC_DECL tvec2(); GLM_FUNC_DECL tvec2(tvec2 const & v); + template + GLM_FUNC_DECL tvec2(tvec2 const & v); ////////////////////////////////////// // Explicit basic constructors @@ -124,7 +115,7 @@ namespace detail } ////////////////////////////////////// - // Convertion constructors + // Conversion constructors //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template @@ -137,7 +128,7 @@ namespace detail V const & y); ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template diff --git a/glm/core/type_vec2.inl b/glm/core/type_vec2.inl index 980309dc..a19fed63 100644 --- a/glm/core/type_vec2.inl +++ b/glm/core/type_vec2.inl @@ -64,14 +64,17 @@ namespace detail template GLM_FUNC_QUALIFIER tvec2::tvec2 ( - ctor - ) + tvec2 const & v + ) : + x(v.x), + y(v.y) {} template + template GLM_FUNC_QUALIFIER tvec2::tvec2 ( - tvec2 const & v + tvec2 const & v ) : x(v.x), y(v.y) @@ -80,6 +83,13 @@ namespace detail ////////////////////////////////////// // Explicit basic constructors + template + GLM_FUNC_QUALIFIER tvec2::tvec2 + ( + ctor + ) + {} + template GLM_FUNC_QUALIFIER tvec2::tvec2 ( @@ -112,7 +122,7 @@ namespace detail {} ////////////////////////////////////// - // Convertion scalar constructors + // Conversion scalar constructors template template @@ -136,7 +146,7 @@ namespace detail {} ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors template template diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index fad362d1..ba35ea33 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -51,14 +51,13 @@ namespace detail ////////////////////////////////////// // Data -# if(GLM_COMPONENT == GLM_COMPONENT_CXXMS) - union - { - struct{value_type x, y, z;}; - struct{value_type r, g, b;}; - struct{value_type s, t, p;}; +# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE)) + union + { + struct{ value_type x, y, z; }; + struct{ value_type r, g, b; }; + struct{ value_type s, t, p; }; -# if(defined(GLM_SWIZZLE)) _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, x, y, z) _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, r, g, b) _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, s, t, p) @@ -68,27 +67,17 @@ namespace detail _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, x, y, z) _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, r, g, b) _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, s, t, p) + }; +# else + union { value_type x, r, s; }; + union { value_type y, g, t; }; + union { value_type z, b, p; }; + +# if(defined(GLM_SWIZZLE)) + //GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, P, detail::tvec3, detail::tref2, detail::tref3) + GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4) # endif//(defined(GLM_SWIZZLE)) - }; -# elif(GLM_COMPONENT == GLM_COMPONENT_CXX98) - union {value_type x, r, s;}; - union {value_type y, g, t;}; - union {value_type z, b, p;}; - -# if(defined(GLM_SWIZZLE)) - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, P, detail::tvec3, detail::tref2, detail::tref3) - GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4) -# endif//(defined(GLM_SWIZZLE)) -# else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) - value_type x, y, z; - -# if(defined(GLM_SWIZZLE)) - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(T, P, detail::tvec3, detail::tref2, detail::tref3, x, y, z) - GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(T, P, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z) -# endif//(defined(GLM_SWIZZLE)) -# endif//GLM_COMPONENT +# endif//GLM_LANG ////////////////////////////////////// // Accesses @@ -101,6 +90,8 @@ namespace detail GLM_FUNC_DECL tvec3(); GLM_FUNC_DECL tvec3(tvec3 const & v); + template + GLM_FUNC_DECL tvec3(tvec3 const & v); ////////////////////////////////////// // Explicit basic constructors @@ -115,7 +106,7 @@ namespace detail value_type const & s3); ////////////////////////////////////// - // Convertion scalar constructors + // Conversion scalar constructors //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template @@ -129,7 +120,7 @@ namespace detail W const & z); ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template diff --git a/glm/core/type_vec3.inl b/glm/core/type_vec3.inl index e2985c23..439a6131 100644 --- a/glm/core/type_vec3.inl +++ b/glm/core/type_vec3.inl @@ -65,14 +65,18 @@ namespace detail template GLM_FUNC_QUALIFIER tvec3::tvec3 ( - ctor - ) + tvec3 const & v + ) : + x(v.x), + y(v.y), + z(v.z) {} template + template GLM_FUNC_QUALIFIER tvec3::tvec3 ( - tvec3 const & v + tvec3 const & v ) : x(v.x), y(v.y), @@ -82,6 +86,13 @@ namespace detail ////////////////////////////////////// // Explicit basic constructors + template + GLM_FUNC_QUALIFIER tvec3::tvec3 + ( + ctor + ) + {} + template GLM_FUNC_QUALIFIER tvec3::tvec3 ( @@ -142,7 +153,7 @@ namespace detail {} ////////////////////////////////////// - // Convertion scalar constructors + // Conversion scalar constructors template template @@ -169,7 +180,7 @@ namespace detail {} ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors template template diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index c3197fee..c725e383 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -51,14 +51,13 @@ namespace detail ////////////////////////////////////// // Data -# if(GLM_COMPONENT == GLM_COMPONENT_CXXMS) - union - { - struct {value_type r, g, b, a;}; - struct {value_type s, t, p, q;}; - struct {value_type x, y, z, w;}; - -# if(defined(GLM_SWIZZLE)) +# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE)) + union + { + struct { value_type r, g, b, a; }; + struct { value_type s, t, p, q; }; + struct { value_type x, y, z, w;}; + _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w) _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, r, g, b, a) _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, s, t, p, q) @@ -68,28 +67,18 @@ namespace detail _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, x, y, z, w) _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, r, g, b, a) _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, s, t, p, q) + }; +# else + union { value_type x, r, s; }; + union { value_type y, g, t; }; + union { value_type z, b, p; }; + union { value_type w, a, q; }; + +# if(defined(GLM_SWIZZLE)) + //GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, P, detail::tvec4, detail::tref2, detail::tref3, detail::tref4) + GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4) # endif//(defined(GLM_SWIZZLE)) - }; -# elif(GLM_COMPONENT == GLM_COMPONENT_CXX98) - union {value_type x, r, s;}; - union {value_type y, g, t;}; - union {value_type z, b, p;}; - union {value_type w, a, q;}; - -# if(defined(GLM_SWIZZLE)) - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, P, detail::tvec4, detail::tref2, detail::tref3, detail::tref4) - GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4) -# endif//(defined(GLM_SWIZZLE)) -# else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) - value_type x, y, z, w; - -# if(defined(GLM_SWIZZLE)) - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(T, P, detail::tvec4, detail::tref2, detail::tref3, detail::tref4, x, y, z, w) - GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(T, P, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z, w) -# endif//(defined(GLM_SWIZZLE)) -# endif//GLM_COMPONENT +# endif//GLM_LANG ////////////////////////////////////// // Accesses @@ -102,6 +91,8 @@ namespace detail GLM_FUNC_DECL tvec4(); GLM_FUNC_DECL tvec4(type const & v); + template + GLM_FUNC_DECL tvec4(tvec4 const & v); ////////////////////////////////////// // Explicit basic constructors @@ -117,22 +108,22 @@ namespace detail value_type const & s3); ////////////////////////////////////// - // Convertion scalar constructors + // Conversion scalar constructors - //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + /// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL explicit tvec4( U const & x); - //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + /// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL explicit tvec4( A const & x, B const & y, C const & z, - D const & w); + D const & w); ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template @@ -232,8 +223,8 @@ namespace detail // Unary arithmetic operators GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); - template - GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); + template + GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator+=(U const & s); diff --git a/glm/core/type_vec4.inl b/glm/core/type_vec4.inl index 231f16dd..9c2734e9 100644 --- a/glm/core/type_vec4.inl +++ b/glm/core/type_vec4.inl @@ -72,14 +72,19 @@ namespace detail template GLM_FUNC_QUALIFIER tvec4::tvec4 ( - ctor - ) + type const & v + ) : + x(v.x), + y(v.y), + z(v.z), + w(v.w) {} template + template GLM_FUNC_QUALIFIER tvec4::tvec4 ( - type const & v + tvec4 const & v ) : x(v.x), y(v.y), @@ -90,6 +95,13 @@ namespace detail ////////////////////////////////////// // Explicit basic constructors + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + ctor + ) + {} + template GLM_FUNC_QUALIFIER tvec4::tvec4 ( @@ -237,8 +249,8 @@ namespace detail {} ////////////////////////////////////// - // Convertion scalar constructors - + // Conversion scalar constructors + template template GLM_FUNC_QUALIFIER tvec4::tvec4 @@ -266,8 +278,20 @@ namespace detail w(value_type(w)) {} + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4 + ( + tvec4 const & v + ) : + x(value_type(v.x)), + y(value_type(v.y)), + z(value_type(v.z)), + w(value_type(v.w)) + {} + ////////////////////////////////////// - // Convertion vector constructors + // Conversion vector constructors template template @@ -350,18 +374,6 @@ namespace detail w(value_type(v2.y)) {} - template - template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - tvec4 const & v - ) : - x(value_type(v.x)), - y(value_type(v.y)), - z(value_type(v.z)), - w(value_type(v.w)) - {} - ////////////////////////////////////// // Unary arithmetic operators @@ -379,10 +391,10 @@ namespace detail } template - template + template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= ( - tvec4 const & v + tvec4 const & v ) { this->x = T(v.x); diff --git a/glm/gtc/packing.inl b/glm/gtc/packing.inl index d67cad09..07a62855 100644 --- a/glm/gtc/packing.inl +++ b/glm/gtc/packing.inl @@ -304,7 +304,7 @@ namespace detail GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float const & v) { - int8 Scaled(round(clamp(v ,-1.0f, 1.0f) * 255.0f)); + int8 Scaled(int8(round(clamp(v, -1.0f, 1.0f) * 255.0f))); detail::unorm1x8 Packing; Packing.data = Scaled; return Packing.pack; @@ -337,7 +337,7 @@ namespace detail GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float const & v) { - glm::int8 Scaled(round(clamp(v ,-1.0f, 1.0f) * 127.0f)); + glm::int8 Scaled(int8(round(clamp(v ,-1.0f, 1.0f) * 127.0f))); detail::snorm1x8 Packing; Packing.data = Scaled; return Packing.pack; diff --git a/glm/gtx/simd_vec4.hpp b/glm/gtx/simd_vec4.hpp index 0e8da15e..04c67c4c 100644 --- a/glm/gtx/simd_vec4.hpp +++ b/glm/gtx/simd_vec4.hpp @@ -111,7 +111,7 @@ namespace detail vec4 const & v); //////////////////////////////////////// - //// Convertion vector constructors + //// Conversion vector constructors fvec4SIMD(vec2 const & v, float const & s1, float const & s2); fvec4SIMD(float const & s1, vec2 const & v, float const & s2); diff --git a/glm/gtx/simd_vec4.inl b/glm/gtx/simd_vec4.inl index a71c550d..3d04d24d 100644 --- a/glm/gtx/simd_vec4.inl +++ b/glm/gtx/simd_vec4.inl @@ -59,7 +59,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const v[4]) : //fvec4SIMD(ref4 const & r); ////////////////////////////////////// -// Convertion vector constructors +// Conversion vector constructors GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) : Data(_mm_set_ps(s2, s1, v.y, v.x)) diff --git a/readme.txt b/readme.txt index c4581aec..e07576ac 100644 --- a/readme.txt +++ b/readme.txt @@ -51,6 +51,7 @@ GLM 0.9.5.0: 2013-XX-XX - Removed GTX_ocl_type extension - Fixed post increment and decrement operators - Fixed perspective with zNear == 0 (#71) +- Removed l-value swizzle operators - Clean up compiler detection code for unsupported compilers ================================================================================ diff --git a/test/core/core_func_swizzle.cpp b/test/core/core_func_swizzle.cpp index 20351dd7..f88fe273 100644 --- a/test/core/core_func_swizzle.cpp +++ b/test/core/core_func_swizzle.cpp @@ -7,24 +7,11 @@ // File : test/core/core_func_swizzle.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_FORCE_ONLY_XYZW -# define GLM_FORCE_ONLY_XYZW -#endif -//#ifndef GLM_FORCE_PURE -//# define GLM_FORCE_PURE -//#endif -#ifndef GLM_MESSAGES -# define GLM_MESSAGES -#endif -#ifndef GLM_SWIZZLE -# define GLM_SWIZZLE -#endif -#ifndef GLM_FORCE_CXX98 -# define GLM_FORCE_CXX98 -#endif +#define GLM_MESSAGES +#define GLM_SWIZZLE #include -int test_vec2_swizzle() +int test_ivec2_swizzle() { int Error = 0; @@ -39,7 +26,7 @@ int test_vec2_swizzle() return Error; } -int test_vec3_swizzle() +int test_ivec3_swizzle() { int Error = 0; @@ -54,7 +41,7 @@ int test_vec3_swizzle() return Error; } -int test_vec4_swizzle() +int test_ivec4_swizzle() { int Error = 0; @@ -69,12 +56,33 @@ int test_vec4_swizzle() return Error; } +int test_vec4_swizzle() +{ + int Error = 0; + + glm::vec4 A(1, 2, 3, 4); + glm::vec4 B = A.xyzw(); + glm::vec4 C(0); + C.xyzw = B.xyzw; + + float f = glm::dot(C.wzyx(), C.xyzw()); + + Error += A == B ? 0 : 1; + Error += A == C ? 0 : 1; + + + static_assert(sizeof(int) <= 4, "Test"); + return Error; +} + int main() { int Error = 0; - Error += test_vec2_swizzle(); - Error += test_vec3_swizzle(); + Error += test_ivec2_swizzle(); + Error += test_ivec3_swizzle(); + Error += test_ivec4_swizzle(); + Error += test_vec4_swizzle(); return Error; diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 88e6f4c5..f3a3259d 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2008-08-31 -// Updated : 2011-09-19 +// Updated : 2013-08-27 // Licence : This source is under MIT License // File : test/core/type_vec3.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -187,130 +187,131 @@ int test_vec3_size() int test_vec3_swizzle3_2() { - int Error = 0; + int Error = 0; - glm::vec3 v(1, 2, 3); - glm::vec2 u; + glm::vec3 v(1, 2, 3); + glm::vec2 u; - // Can not assign a vec3 swizzle to a vec2 - //u = v.xyz; //Illegal - //u = v.rgb; //Illegal - //u = v.stp; //Illegal +# if(GLM_LANG & GLM_LANG_CXXMS_FLAG) + // Can not assign a vec3 swizzle to a vec2 + //u = v.xyz; //Illegal + //u = v.rgb; //Illegal + //u = v.stp; //Illegal -#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) - u = v.xx; Error += (u.x == 1.0f && u.y == 1.0f) ? 0 : 1; - u = v.xy; Error += (u.x == 1.0f && u.y == 2.0f) ? 0 : 1; - u = v.xz; Error += (u.x == 1.0f && u.y == 3.0f) ? 0 : 1; - u = v.yx; Error += (u.x == 2.0f && u.y == 1.0f) ? 0 : 1; - u = v.yy; Error += (u.x == 2.0f && u.y == 2.0f) ? 0 : 1; - u = v.yz; Error += (u.x == 2.0f && u.y == 3.0f) ? 0 : 1; - u = v.zx; Error += (u.x == 3.0f && u.y == 1.0f) ? 0 : 1; - u = v.zy; Error += (u.x == 3.0f && u.y == 2.0f) ? 0 : 1; - u = v.zz; Error += (u.x == 3.0f && u.y == 3.0f) ? 0 : 1; + u = v.xx; Error += (u.x == 1.0f && u.y == 1.0f) ? 0 : 1; + u = v.xy; Error += (u.x == 1.0f && u.y == 2.0f) ? 0 : 1; + u = v.xz; Error += (u.x == 1.0f && u.y == 3.0f) ? 0 : 1; + u = v.yx; Error += (u.x == 2.0f && u.y == 1.0f) ? 0 : 1; + u = v.yy; Error += (u.x == 2.0f && u.y == 2.0f) ? 0 : 1; + u = v.yz; Error += (u.x == 2.0f && u.y == 3.0f) ? 0 : 1; + u = v.zx; Error += (u.x == 3.0f && u.y == 1.0f) ? 0 : 1; + u = v.zy; Error += (u.x == 3.0f && u.y == 2.0f) ? 0 : 1; + u = v.zz; Error += (u.x == 3.0f && u.y == 3.0f) ? 0 : 1; - u = v.rr; Error += (u.r == 1.0f && u.g == 1.0f) ? 0 : 1; - u = v.rg; Error += (u.r == 1.0f && u.g == 2.0f) ? 0 : 1; - u = v.rb; Error += (u.r == 1.0f && u.g == 3.0f) ? 0 : 1; - u = v.gr; Error += (u.r == 2.0f && u.g == 1.0f) ? 0 : 1; - u = v.gg; Error += (u.r == 2.0f && u.g == 2.0f) ? 0 : 1; - u = v.gb; Error += (u.r == 2.0f && u.g == 3.0f) ? 0 : 1; - u = v.br; Error += (u.r == 3.0f && u.g == 1.0f) ? 0 : 1; - u = v.bg; Error += (u.r == 3.0f && u.g == 2.0f) ? 0 : 1; - u = v.bb; Error += (u.r == 3.0f && u.g == 3.0f) ? 0 : 1; + u = v.rr; Error += (u.r == 1.0f && u.g == 1.0f) ? 0 : 1; + u = v.rg; Error += (u.r == 1.0f && u.g == 2.0f) ? 0 : 1; + u = v.rb; Error += (u.r == 1.0f && u.g == 3.0f) ? 0 : 1; + u = v.gr; Error += (u.r == 2.0f && u.g == 1.0f) ? 0 : 1; + u = v.gg; Error += (u.r == 2.0f && u.g == 2.0f) ? 0 : 1; + u = v.gb; Error += (u.r == 2.0f && u.g == 3.0f) ? 0 : 1; + u = v.br; Error += (u.r == 3.0f && u.g == 1.0f) ? 0 : 1; + u = v.bg; Error += (u.r == 3.0f && u.g == 2.0f) ? 0 : 1; + u = v.bb; Error += (u.r == 3.0f && u.g == 3.0f) ? 0 : 1; - u = v.ss; Error += (u.s == 1.0f && u.t == 1.0f) ? 0 : 1; - u = v.st; Error += (u.s == 1.0f && u.t == 2.0f) ? 0 : 1; - u = v.sp; Error += (u.s == 1.0f && u.t == 3.0f) ? 0 : 1; - u = v.ts; Error += (u.s == 2.0f && u.t == 1.0f) ? 0 : 1; - u = v.tt; Error += (u.s == 2.0f && u.t == 2.0f) ? 0 : 1; - u = v.tp; Error += (u.s == 2.0f && u.t == 3.0f) ? 0 : 1; - u = v.ps; Error += (u.s == 3.0f && u.t == 1.0f) ? 0 : 1; - u = v.pt; Error += (u.s == 3.0f && u.t == 2.0f) ? 0 : 1; - u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1; - // Mixed member aliases are not valid - //u = v.rx; //Illegal - //u = v.sy; //Illegal + u = v.ss; Error += (u.s == 1.0f && u.t == 1.0f) ? 0 : 1; + u = v.st; Error += (u.s == 1.0f && u.t == 2.0f) ? 0 : 1; + u = v.sp; Error += (u.s == 1.0f && u.t == 3.0f) ? 0 : 1; + u = v.ts; Error += (u.s == 2.0f && u.t == 1.0f) ? 0 : 1; + u = v.tt; Error += (u.s == 2.0f && u.t == 2.0f) ? 0 : 1; + u = v.tp; Error += (u.s == 2.0f && u.t == 3.0f) ? 0 : 1; + u = v.ps; Error += (u.s == 3.0f && u.t == 1.0f) ? 0 : 1; + u = v.pt; Error += (u.s == 3.0f && u.t == 2.0f) ? 0 : 1; + u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1; + // Mixed member aliases are not valid + //u = v.rx; //Illegal + //u = v.sy; //Illegal + u = glm::vec2(1, 2); + v = glm::vec3(1, 2, 3); + //v.xx = u; //Illegal + v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1; + v.xz = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 2.0f) ? 0 : 1; + v.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; + //v.yy = u; //Illegal + v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; + v.zx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 1.0f) ? 0 : 1; + v.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1; + //v.zz = u; //Illegal - u = glm::vec2(1, 2); - v = glm::vec3(1, 2, 3); - //v.xx = u; //Illegal - v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1; - v.xz = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 2.0f) ? 0 : 1; - v.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; - //v.yy = u; //Illegal - v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; - v.zx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 1.0f) ? 0 : 1; - v.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1; - //v.zz = u; //Illegal -#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) +# endif//GLM_LANG - return Error; + return Error; } int test_vec3_swizzle3_3() { - int Error = 0; + int Error = 0; - glm::vec3 v(1, 2, 3); - glm::vec3 u; - - u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - -#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) - u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + glm::vec3 v(1, 2, 3); + glm::vec3 u; - u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; +# if(GLM_LANG & GLM_LANG_CXXMS_FLAG) + u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; -#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) - return Error; + u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; + u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + + u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; + u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + + u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; + u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; +# endif//GLM_LANG + + return Error; } int test_vec3_swizzle_operators() { - int Error = 0; + int Error = 0; - glm::vec3 q, u, v; + glm::vec3 q, u, v; - u = glm::vec3(1, 2, 3); - v = glm::vec3(10, 20, 30); + u = glm::vec3(1, 2, 3); + v = glm::vec3(10, 20, 30); -#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) - // Swizzle, swizzle binary operators - q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1; - q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1; - q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1; - q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1; - q = (u.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1; - q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1; +# if(GLM_LANG & GLM_LANG_CXXMS_FLAG) + // Swizzle, swizzle binary operators + q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1; + q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1; + q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1; + q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1; + q = (u.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1; + q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1; - // vec, swizzle binary operators - q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1; - q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1; - q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1; - q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1; - q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1; + // vec, swizzle binary operators + q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1; + q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1; + q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1; + q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1; + q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1; - // swizzle,vec binary operators - q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1; - q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1; - q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1; - q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1; - q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1; -#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) + // swizzle,vec binary operators + q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1; + q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1; + q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1; + q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1; + q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1; +# endif//GLM_LANG - // Compile errors - //q = (u.yz * v.xyz); - //q = (u * v.xy); + // Compile errors + //q = (u.yz * v.xyz); + //q = (u * v.xy); - return Error; + return Error; } int test_vec3_swizzle_functions() @@ -324,7 +325,6 @@ int test_vec3_swizzle_functions() // glm::dot(u.xy, v.xy); <--- Compile error // glm::dot(u.xy(), v.xy()); <--- Compiles correctly -#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) float r; // vec2 @@ -351,7 +351,6 @@ int test_vec3_swizzle_functions() r = glm::dot(s, t); Error += (int(r) == 300) ? 0 : 1; r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1; r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1; -#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) return Error; } @@ -360,9 +359,9 @@ int test_vec3_swizzle_partial() { int Error = 0; -#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) glm::vec3 A(1, 2, 3); +# if(GLM_LANG & GLM_LANG_CXXMS_FLAG) { glm::vec3 B(A.xy, 3.0f); Error += A == B ? 0 : 1; @@ -377,7 +376,7 @@ int test_vec3_swizzle_partial() glm::vec3 B(A.xyz); Error += A == B ? 0 : 1; } -#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) +# endif//GLM_LANG return Error; } diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 733ca067..3f5fd5cc 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -216,7 +216,7 @@ int test_vec4_swizzle_partial() glm::vec4 A(1, 2, 3, 4); -#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) +# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE)) { glm::vec4 B(A.xy, A.zw); Error += A == B ? 0 : 1; @@ -242,7 +242,7 @@ int test_vec4_swizzle_partial() glm::vec4 B(1.0f, A.yzw); Error += A == B ? 0 : 1; } -#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) +# endif//GLM_LANG return Error; } diff --git a/test/gtc/gtc_packing.cpp b/test/gtc/gtc_packing.cpp index b3d83739..8c79b422 100644 --- a/test/gtc/gtc_packing.cpp +++ b/test/gtc/gtc_packing.cpp @@ -31,287 +31,237 @@ #include #include -void print_bits(glm::half const & s) -{ - union - { - glm::detail::hdata h; - unsigned short i; - } uif; - - uif.h = s._data(); - - printf("f16: "); - for(std::size_t j = sizeof(s) * 8; j > 0; --j) - { - if(j == 10 || j == 15) - printf(" "); - printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0); - } -} - void print_bits(float const & s) { - union - { - float f; - unsigned int i; - } uif; - - uif.f = s; - - printf("f32: "); - for(std::size_t j = sizeof(s) * 8; j > 0; --j) - { - if(j == 23 || j == 31) - printf(" "); - printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0); - } + union + { + float f; + unsigned int i; + } uif; + + uif.f = s; + + printf("f32: "); + for(std::size_t j = sizeof(s) * 8; j > 0; --j) + { + if(j == 23 || j == 31) + printf(" "); + printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0); + } } void print_10bits(glm::uint const & s) { - printf("10b: "); - for(std::size_t j = 10; j > 0; --j) - { - if(j == 5) - printf(" "); - printf("%d", (s & (1 << (j - 1))) ? 1 : 0); - } + printf("10b: "); + for(std::size_t j = 10; j > 0; --j) + { + if(j == 5) + printf(" "); + printf("%d", (s & (1 << (j - 1))) ? 1 : 0); + } } void print_11bits(glm::uint const & s) { - printf("11b: "); - for(std::size_t j = 11; j > 0; --j) - { - if(j == 6) - printf(" "); - printf("%d", (s & (1 << (j - 1))) ? 1 : 0); - } + printf("11b: "); + for(std::size_t j = 11; j > 0; --j) + { + if(j == 6) + printf(" "); + printf("%d", (s & (1 << (j - 1))) ? 1 : 0); + } } void print_value(float const & s) { - printf("%2.5f, ", s); - print_bits(s); - printf(", "); - print_bits(glm::half(s)); -// printf(", "); -// print_11bits(detail::floatTo11bit(s)); -// printf(", "); -// print_10bits(detail::floatTo10bit(s)); - printf("\n"); -} - -int test_half() -{ - int Error = 0; - - print_value(0.0f); - print_value(0.1f); - print_value(0.2f); - print_value(0.3f); - print_value(0.4f); - print_value(0.5f); - print_value(0.6f); - print_value(1.0f); - print_value(1.1f); - print_value(1.2f); - print_value(1.3f); - print_value(1.4f); - print_value(1.5f); - print_value(1.6f); - print_value(2.0f); - print_value(2.1f); - print_value(2.2f); - print_value(2.3f); - print_value(2.4f); - print_value(2.5f); - print_value(2.6f); - - return Error; + printf("%2.5f, ", s); + print_bits(s); + printf(", "); +// print_11bits(detail::floatTo11bit(s)); +// printf(", "); +// print_10bits(detail::floatTo10bit(s)); + printf("\n"); } int test_Half1x16() { - int Error = 0; + int Error = 0; - std::vector Tests; - Tests.push_back(0.0f); - Tests.push_back(1.0f); - Tests.push_back(-1.0f); - Tests.push_back(2.0f); - Tests.push_back(-2.0f); - Tests.push_back(1.9f); + std::vector Tests; + Tests.push_back(0.0f); + Tests.push_back(1.0f); + Tests.push_back(-1.0f); + Tests.push_back(2.0f); + Tests.push_back(-2.0f); + Tests.push_back(1.9f); - for(std::size_t i = 0; i < Tests.size(); ++i) - { - glm::uint32 p0 = glm::packHalf1x16(Tests[i]); - float v0 = glm::unpackHalf1x16(p0); - glm::uint32 p1 = glm::packHalf1x16(v0); - float v1 = glm::unpackHalf1x16(p0); - Error += (v0 == v1) ? 0 : 1; - } + for(std::size_t i = 0; i < Tests.size(); ++i) + { + glm::uint32 p0 = glm::packHalf1x16(Tests[i]); + float v0 = glm::unpackHalf1x16(p0); + glm::uint32 p1 = glm::packHalf1x16(v0); + float v1 = glm::unpackHalf1x16(p0); + Error += (v0 == v1) ? 0 : 1; + } - return Error; + return Error; } int test_Half4x16() { - int Error = 0; + int Error = 0; - std::vector Tests; - Tests.push_back(glm::vec4(1.0)); - Tests.push_back(glm::vec4(0.0)); - Tests.push_back(glm::vec4(2.0)); - Tests.push_back(glm::vec4(0.1)); - Tests.push_back(glm::vec4(0.5)); - Tests.push_back(glm::vec4(-0.9)); + std::vector Tests; + Tests.push_back(glm::vec4(1.0)); + Tests.push_back(glm::vec4(0.0)); + Tests.push_back(glm::vec4(2.0)); + Tests.push_back(glm::vec4(0.1)); + Tests.push_back(glm::vec4(0.5)); + Tests.push_back(glm::vec4(-0.9)); - for(std::size_t i = 0; i < Tests.size(); ++i) - { - 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); - Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; - } + for(std::size_t i = 0; i < Tests.size(); ++i) + { + 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); + Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; + } - return Error; + return Error; } int test_I3x10_1x2() { - int Error = 0; + int Error = 0; - std::vector Tests; - Tests.push_back(glm::ivec4(0)); - Tests.push_back(glm::ivec4(1)); - Tests.push_back(glm::ivec4(-1)); - Tests.push_back(glm::ivec4(2)); - Tests.push_back(glm::ivec4(-2)); - Tests.push_back(glm::ivec4(3)); + std::vector Tests; + Tests.push_back(glm::ivec4(0)); + Tests.push_back(glm::ivec4(1)); + Tests.push_back(glm::ivec4(-1)); + Tests.push_back(glm::ivec4(2)); + Tests.push_back(glm::ivec4(-2)); + Tests.push_back(glm::ivec4(3)); - for(std::size_t i = 0; i < Tests.size(); ++i) - { - 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); - Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; - } + for(std::size_t i = 0; i < Tests.size(); ++i) + { + 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); + Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; + } - return Error; + return Error; } int test_U3x10_1x2() { - int Error = 0; + int Error = 0; - std::vector Tests; - Tests.push_back(glm::uvec4(0)); - Tests.push_back(glm::uvec4(1)); - Tests.push_back(glm::uvec4(2)); - Tests.push_back(glm::uvec4(3)); - Tests.push_back(glm::uvec4(4)); - Tests.push_back(glm::uvec4(5)); + std::vector Tests; + Tests.push_back(glm::uvec4(0)); + Tests.push_back(glm::uvec4(1)); + Tests.push_back(glm::uvec4(2)); + Tests.push_back(glm::uvec4(3)); + Tests.push_back(glm::uvec4(4)); + Tests.push_back(glm::uvec4(5)); - for(std::size_t i = 0; i < Tests.size(); ++i) - { - 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); - Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; - } + for(std::size_t i = 0; i < Tests.size(); ++i) + { + 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); + Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; + } - return Error; + return Error; } int test_Snorm3x10_1x2() { - int Error = 0; + int Error = 0; - std::vector Tests; - Tests.push_back(glm::vec4(1.0)); - Tests.push_back(glm::vec4(0.0)); - Tests.push_back(glm::vec4(2.0)); - Tests.push_back(glm::vec4(0.1)); - Tests.push_back(glm::vec4(0.5)); - Tests.push_back(glm::vec4(0.9)); + std::vector Tests; + Tests.push_back(glm::vec4(1.0)); + Tests.push_back(glm::vec4(0.0)); + Tests.push_back(glm::vec4(2.0)); + Tests.push_back(glm::vec4(0.1)); + Tests.push_back(glm::vec4(0.5)); + Tests.push_back(glm::vec4(0.9)); - for(std::size_t i = 0; i < Tests.size(); ++i) - { - 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); - Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; - } + for(std::size_t i = 0; i < Tests.size(); ++i) + { + 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); + Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; + } - return Error; + return Error; } int test_Unorm3x10_1x2() { - int Error = 0; + int Error = 0; - std::vector Tests; - Tests.push_back(glm::vec4(1.0)); - Tests.push_back(glm::vec4(0.0)); - Tests.push_back(glm::vec4(2.0)); - Tests.push_back(glm::vec4(0.1)); - Tests.push_back(glm::vec4(0.5)); - Tests.push_back(glm::vec4(0.9)); + std::vector Tests; + Tests.push_back(glm::vec4(1.0)); + Tests.push_back(glm::vec4(0.0)); + Tests.push_back(glm::vec4(2.0)); + Tests.push_back(glm::vec4(0.1)); + Tests.push_back(glm::vec4(0.5)); + Tests.push_back(glm::vec4(0.9)); - for(std::size_t i = 0; i < Tests.size(); ++i) - { - 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); - Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; - } + for(std::size_t i = 0; i < Tests.size(); ++i) + { + 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); + Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; + } - return Error; + return Error; } int test_F2x11_1x10() { - int Error = 0; + int Error = 0; - std::vector Tests; - Tests.push_back(glm::vec3(1.0)); - Tests.push_back(glm::vec3(0.0)); - Tests.push_back(glm::vec3(2.0)); - Tests.push_back(glm::vec3(0.1)); - Tests.push_back(glm::vec3(0.5)); - Tests.push_back(glm::vec3(0.9)); + std::vector Tests; + Tests.push_back(glm::vec3(1.0)); + Tests.push_back(glm::vec3(0.0)); + Tests.push_back(glm::vec3(2.0)); + Tests.push_back(glm::vec3(0.1)); + Tests.push_back(glm::vec3(0.5)); + Tests.push_back(glm::vec3(0.9)); - for(std::size_t i = 0; i < Tests.size(); ++i) - { - 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); - Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; - } + for(std::size_t i = 0; i < Tests.size(); ++i) + { + 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); + Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; + } - return Error; + return Error; } int main() { int Error(0); - Error += test_F2x11_1x10(); - Error += test_Snorm3x10_1x2(); - Error += test_Unorm3x10_1x2(); - Error += test_I3x10_1x2(); - Error += test_U3x10_1x2(); - Error += test_Half1x16(); - Error += test_U3x10_1x2(); + Error += test_F2x11_1x10(); + Error += test_Snorm3x10_1x2(); + Error += test_Unorm3x10_1x2(); + Error += test_I3x10_1x2(); + Error += test_U3x10_1x2(); + Error += test_Half1x16(); + Error += test_U3x10_1x2(); return Error; } diff --git a/test/gtc/gtc_type_precision.cpp b/test/gtc/gtc_type_precision.cpp index 8d1f8411..4e110ad0 100644 --- a/test/gtc/gtc_type_precision.cpp +++ b/test/gtc/gtc_type_precision.cpp @@ -836,12 +836,31 @@ static int test_quat_precision() return Error; } +static int test_fvec_conversion() +{ + int Error(0); + + { + glm::highp_vec4 a = glm::vec4(1, 2, 3, 4); + glm::mediump_vec4 b = glm::vec4(1, 2, 3, 4); + glm::lowp_vec4 c = b; + glm::mediump_vec4 d = c; + glm::lowp_ivec4 e = glm::ivec4(d); + glm::lowp_ivec3 f = glm::ivec3(e); + + Error += glm::all(glm::equal(b, d)) ? 0 : 1; + } + + return Error; +} + int main() { int Error(0); Error += test_scalar_size(); Error += test_fvec_size(); Error += test_fvec_precision(); + Error += test_fvec_conversion(); Error += test_dvec_precision(); Error += test_ivec_size(); Error += test_ivec_precision();