From 4843f8ffb983fa54fd3309ed2b87f12bf27f0840 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 19 Oct 2011 16:49:28 +0100 Subject: [PATCH] Added swizzle operator from generated functions for non C++11 compiler --- glm/core/_swizzle_func.hpp | 58 +++++++++++++++++---------------- glm/core/setup.hpp | 8 ++--- glm/core/type_vec2.hpp | 36 ++++++++++++-------- glm/core/type_vec3.hpp | 27 ++++++++++++--- glm/core/type_vec4.hpp | 18 +++++++--- glm/glm.hpp | 2 -- test/core/core_func_swizzle.cpp | 36 +++++++++++++++++++- 7 files changed, 128 insertions(+), 57 deletions(-) diff --git a/glm/core/_swizzle_func.hpp b/glm/core/_swizzle_func.hpp index 0275980a..faa98478 100644 --- a/glm/core/_swizzle_func.hpp +++ b/glm/core/_swizzle_func.hpp @@ -68,9 +68,11 @@ return SWIZZLED_TYPE(this->A, this->B, this->C, this->D); \ } +#define GLM_MUTABLE + #define GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, B) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, A) + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) #define GLM_SWIZZLE_GEN_REF_FROM_VEC2(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE) \ GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, x, y) \ @@ -80,20 +82,20 @@ //GLM_SWIZZLE_GEN_REF_FROM_VEC2(valType, detail::vec2, detail::ref2) #define GLM_SWIZZLE_GEN_REF2_FROM_VEC3_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, B) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, C) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, A) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, C) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , C, A) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , C, B) + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B) #define GLM_SWIZZLE_GEN_REF3_FROM_VEC3_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, B, C) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, C, B) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, A, C) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, C, A) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , C, A, B) \ - GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , C, B, A) + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B, A) #define GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ GLM_SWIZZLE_GEN_REF2_FROM_VEC3_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C) \ @@ -107,18 +109,18 @@ //GLM_SWIZZLE_GEN_REF_FROM_VEC3(valType, detail::vec3, detail::ref2, detail::ref3) #define GLM_SWIZZLE_GEN_REF2_FROM_VEC4_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, B) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, C) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, D) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, A) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, C) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , B, D) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , C, A) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , C, B) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , C, D) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , D, A) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , D, B) \ - GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , D, C) + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, C) #define GLM_SWIZZLE_GEN_REF3_FROM_VEC4_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, , A, B, C) \ @@ -771,8 +773,8 @@ GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, D) #define GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) \ - GLM_SWIZZLE_GEN_VEC2_FROM_VEC4_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B) \ - GLM_SWIZZLE_GEN_VEC3_FROM_VEC4_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC2_FROM_VEC4_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_FROM_VEC4_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C, D) \ GLM_SWIZZLE_GEN_VEC4_FROM_VEC4_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) #define GLM_SWIZZLE_GEN_VEC_FROM_VEC4(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 535d3f00..7b40eb28 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -314,12 +314,12 @@ #define GLM_LANG_CXXMS 5 #define GLM_LANG_CXXGNU 6 -#if(defined(GLM_FORCE_CXX98)) -# define GLM_LANG GLM_LANG_CXX98 +#if(defined(GLM_FORCE_CXX11)) +# define GLM_LANG GLM_LANG_CXX11 #elif(defined(GLM_FORCE_CXX03)) # define GLM_LANG GLM_LANG_CXX03 -#elif(defined(GLM_FORCE_CXX11)) -# define GLM_LANG GLM_LANG_CXX11 +#elif(defined(GLM_FORCE_CXX98)) +# define GLM_LANG GLM_LANG_CXX98 #elif(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && defined(__GXX_EXPERIMENTAL_CXX0X__)) // -std=c++0x or -std=gnu++0x # define GLM_LANG GLM_LANG_CXX0X #elif(GLM_COMPILER == GLM_COMPILER_VC2010) //_MSC_EXTENSIONS for MS language extensions diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index 67750657..1670c1d7 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -64,18 +64,26 @@ namespace detail # if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) value_type x, y; -# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT || GLM_LANG == GLM_LANG_CXX0X) + +# ifdef GLM_SWIZZLE_OPERATOR + // Defines all he swizzle operator as functions + GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2) + GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4) +# endif//GLM_SWIZZLE_OPERATOR +# elif((GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X))) union { - _GLM_SWIZZLE2_2_MEMBERS(value_type,glm::detail::tvec2,x,y) - _GLM_SWIZZLE2_2_MEMBERS(value_type,glm::detail::tvec2,r,g) - _GLM_SWIZZLE2_2_MEMBERS(value_type,glm::detail::tvec2,s,t) - _GLM_SWIZZLE2_3_MEMBERS(value_type,glm::detail::tvec3,x,y) - _GLM_SWIZZLE2_3_MEMBERS(value_type,glm::detail::tvec3,r,g) - _GLM_SWIZZLE2_3_MEMBERS(value_type,glm::detail::tvec3,s,t) - _GLM_SWIZZLE2_4_MEMBERS(value_type,glm::detail::tvec4,x,y) - _GLM_SWIZZLE2_4_MEMBERS(value_type,glm::detail::tvec4,r,g) - _GLM_SWIZZLE2_4_MEMBERS(value_type,glm::detail::tvec4,s,t) +# ifdef GLM_SWIZZLE_OPERATOR + _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2, x, y) + _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2, r, g) + _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2, s, t) + _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3, x, y) + _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3, r, g) + _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3, s, t) + _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4, x, y) + _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4, r, g) + _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4, s, t) +# endif//GLM_SWIZZLE_OPERATOR struct{value_type r, g;}; struct{value_type s, t;}; @@ -85,9 +93,11 @@ namespace detail union {value_type x, r, s;}; union {value_type y, g, t;}; - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC2(T, detail::ref2, detail::vec2) - GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, detail::vec4, detail::vec2, detail::vec3, detail::vec4) +# ifdef GLM_SWIZZLE_OPERATOR + // Defines all he swizzle operator as functions + GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2) + GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4) +# endif//GLM_SWIZZLE_OPERATOR # endif//GLM_COMPONENT ////////////////////////////////////// diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index da954137..fcf99397 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -61,12 +61,25 @@ namespace detail ////////////////////////////////////// // Data - +/* +#define GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C) \ + SWIZZLED_TYPE A ## B ## C() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->B); \ + } +*/ # if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) value_type x, y, z; -# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT || GLM_LANG == GLM_LANG_CXX0X) + +# ifdef GLM_SWIZZLE_OPERATOR + // Defines all he swizzle operator as functions + GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, detail::tvec3, detail::tref2, detail::tref3) + GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4) +# endif//GLM_SWIZZLE_OPERATOR +# elif((GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X))) union { +# ifdef GLM_SWIZZLE_OPERATOR _GLM_SWIZZLE3_2_MEMBERS(value_type,glm::detail::tvec2,x,y,z) _GLM_SWIZZLE3_2_MEMBERS(value_type,glm::detail::tvec2,r,g,b) _GLM_SWIZZLE3_2_MEMBERS(value_type,glm::detail::tvec2,s,t,p) @@ -76,6 +89,7 @@ namespace detail _GLM_SWIZZLE3_4_MEMBERS(value_type,glm::detail::tvec4,x,y,z) _GLM_SWIZZLE3_4_MEMBERS(value_type,glm::detail::tvec4,r,g,b) _GLM_SWIZZLE3_4_MEMBERS(value_type,glm::detail::tvec4,s,t,p) +# endif//GLM_SWIZZLE_OPERATOR struct{value_type r, g, b;}; struct{value_type s, t, p;}; @@ -86,9 +100,12 @@ namespace detail union {value_type y, g, t;}; union {value_type z, b, p;}; - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, detail::ref3, detail::vec2, detail::vec3) - GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, detail::vec4, detail::vec2, detail::vec3, detail::vec4) +# ifdef GLM_SWIZZLE_OPERATOR + //GLM_SWIZZLE_GEN_VEC3_ENTRY(T, detail::tvec3, detail::tvec3, const, x, y, z) + // Defines all he swizzle operator as functions + GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, detail::tvec3, detail::tref2, detail::tref3) + GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4) +# endif//GLM_SWIZZLE_OPERATOR # endif//GLM_COMPONENT ////////////////////////////////////// diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index f2b6daff..8619cbec 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -64,9 +64,16 @@ namespace detail # if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) value_type x, y, z, w; -# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT || GLM_LANG == GLM_LANG_CXX0X) + +# ifdef GLM_SWIZZLE_OPERATOR + // Defines all he swizzle operator as functions + GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, detail::tvec4, detail::tref2, detail::tref3, detail::tref4) + GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4) +# endif//GLM_SWIZZLE_OPERATOR +# elif((GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X))) union { +# ifdef GLM_SWIZZLE_OPERATOR _GLM_SWIZZLE4_2_MEMBERS(value_type,glm::detail::tvec2,x,y,z,w) _GLM_SWIZZLE4_2_MEMBERS(value_type,glm::detail::tvec2,r,g,b,a) _GLM_SWIZZLE4_2_MEMBERS(value_type,glm::detail::tvec2,s,t,p,q) @@ -76,6 +83,7 @@ namespace detail _GLM_SWIZZLE4_4_MEMBERS(value_type,glm::detail::tvec4,x,y,z,w) _GLM_SWIZZLE4_4_MEMBERS(value_type,glm::detail::tvec4,r,g,b,a) _GLM_SWIZZLE4_4_MEMBERS(value_type,glm::detail::tvec4,s,t,p,q) +# endif//GLM_SWIZZLE_OPERATOR struct{value_type r, g, b, a;}; struct{value_type s, t, p, q;}; @@ -87,9 +95,11 @@ namespace detail union {value_type z, b, p;}; union {value_type w, a, q;}; - // Defines all he swizzle operator as functions - GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, detail::ref4, detail::vec2, detail::vec3, detail::vec4) - GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, detail::vec4, detail::vec2, detail::vec3, detail::vec4) +# ifdef GLM_SWIZZLE_OPERATOR + // Defines all he swizzle operator as functions + GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, detail::tvec4, detail::tref2, detail::tref3, detail::tref4) + GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4) +# endif//GLM_SWIZZLE_OPERATOR # endif//GLM_COMPONENT ////////////////////////////////////// diff --git a/glm/glm.hpp b/glm/glm.hpp index 382b1a42..79e1d878 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -80,8 +80,6 @@ #ifndef glm_glm #define glm_glm -#define GLM_FORCE_CXX98 - #include #include #include diff --git a/test/core/core_func_swizzle.cpp b/test/core/core_func_swizzle.cpp index 3512aaba..0df72e49 100644 --- a/test/core/core_func_swizzle.cpp +++ b/test/core/core_func_swizzle.cpp @@ -7,15 +7,47 @@ // File : test/core/core_func_swizzle.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// -#define GLM_FORCE_CXX98 +#define GLM_MESSAGES +#define GLM_SWIZZLE_OPERATOR +//#define GLM_FORCE_CXX11 #include +int test_vec2_swizzle() +{ + int Error = 0; + + glm::ivec2 A(1, 2); + glm::ivec2 B = A.xy(); + glm::ivec2 C(0); + C.xy() = B.xy(); + + Error += A == B ? 0 : 1; + + return Error; +} + +int test_vec3_swizzle() +{ + int Error = 0; + + glm::ivec3 A(1, 2, 3); + glm::ivec3 B = A.xyz(); + glm::ivec3 C(0); + C.xyz() = B.xyz(); + + Error += A == B ? 0 : 1; + + return Error; +} + int test_vec4_swizzle() { int Error = 0; glm::ivec4 A(1, 2, 3, 4); glm::ivec4 B = A.xyzw(); + glm::ivec4 C(0); + C.xyzw() = B.xyzw(); Error += A == B ? 0 : 1; @@ -26,6 +58,8 @@ int main() { int Error = 0; + Error += test_vec2_swizzle(); + Error += test_vec3_swizzle(); Error += test_vec4_swizzle(); return Error;