Added GLM_SUPPORT_SWIZZLE_OPERATOR macro

This commit is contained in:
Christophe Riccio 2011-10-20 11:28:23 +01:00
parent e5c087da89
commit 7cbda2e1e2
7 changed files with 25 additions and 19 deletions

View file

@ -535,4 +535,10 @@
# endif
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Support check macros
#define GLM_SUPPORT_SWIZZLE_OPERATOR() \
((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X)))
#endif//glm_setup

View file

@ -70,7 +70,7 @@ namespace detail
GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(value_type, detail::tvec2, detail::tref2, x, y)
GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4, x, y)
# endif//GLM_SWIZZLE_OPERATOR
# elif((GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X)))
# elif(GLM_SUPPORT_SWIZZLE_OPERATOR())
union
{
# ifdef GLM_SWIZZLE_OPERATOR

View file

@ -76,7 +76,7 @@ namespace detail
GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(T, detail::tvec3, detail::tref2, detail::tref3, x, y, z)
GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z)
# endif//GLM_SWIZZLE_OPERATOR
# elif((GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X)))
# elif(GLM_SUPPORT_SWIZZLE_OPERATOR())
union
{
# ifdef GLM_SWIZZLE_OPERATOR

View file

@ -70,7 +70,7 @@ namespace detail
GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(T, detail::tvec4, detail::tref2, detail::tref3, detail::tref4, x, y, z, w)
GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z, w)
# endif//GLM_SWIZZLE_OPERATOR
# elif((GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X)))
# elif(GLM_SUPPORT_SWIZZLE_OPERATOR())
union
{
# ifdef GLM_SWIZZLE_OPERATOR

View file

@ -47,7 +47,7 @@
namespace glm{
namespace detail
{
#if((GLM_LANG != GLM_LANG_CXX11) && (GLM_LANG != GLM_LANG_CXXMS))
#if(!GLM_SUPPORT_SWIZZLE_OPERATOR())
template <>
struct tvec2<thalf>
{
@ -345,7 +345,7 @@ namespace detail
tvec4<thalf> swizzle(comp X, comp Y, comp Z, comp W) const;
tref4<thalf> swizzle(comp X, comp Y, comp Z, comp W);
};
#endif//((GLM_LANG != GLM_LANG_CXX11) && (GLM_LANG != GLM_LANG_CXXMS))
#endif//(!GLM_SUPPORT_SWIZZLE_OPERATOR())
}
//namespace detail

View file

@ -29,7 +29,7 @@
namespace glm{
namespace detail
{
#if((GLM_LANG != GLM_LANG_CXX11) && (GLM_LANG != GLM_LANG_CXXMS))
#if(!GLM_SUPPORT_SWIZZLE_OPERATOR())
//////////////////////////////////////
// hvec2
@ -1003,7 +1003,7 @@ namespace detail
(*this)[w]);
}
#endif//_MSC_EXTENSIONS
#endif//(!GLM_SUPPORT_SWIZZLE_OPERATOR())
}//namespace detail
}//namespace glm

View file

@ -192,7 +192,7 @@ int test_vec3_swizzle3_2()
//u = v.rgb; //Illegal
//u = v.stp; //Illegal
#if((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#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;
@ -238,7 +238,7 @@ int test_vec3_swizzle3_2()
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_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error;
}
@ -252,7 +252,7 @@ int test_vec3_swizzle3_3()
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
#if((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#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;
@ -264,7 +264,7 @@ int test_vec3_swizzle3_3()
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 == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error;
}
@ -282,7 +282,7 @@ int test_vec3_swizzle_half()
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1;
#if((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
u = v.xyz;
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1;
u = v.zyx;
@ -303,7 +303,7 @@ int test_vec3_swizzle_half()
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
u.pts = v;
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1;
#endif//((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error;
}
@ -317,7 +317,7 @@ int test_vec3_swizzle_operators()
u = glm::vec3(1, 2, 3);
v = glm::vec3(10, 20, 30);
#if((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#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;
@ -339,7 +339,7 @@ int test_vec3_swizzle_operators()
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 == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
// Compile errors
//q = (u.yz * v.xyz);
@ -363,7 +363,7 @@ int test_vec3_swizzle_functions()
float r;
#if((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
// vec2
glm::vec2 a(1, 2);
glm::vec2 b(10, 20);
@ -388,7 +388,7 @@ 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_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error;
}
@ -399,7 +399,7 @@ int test_vec3_swizzle_partial()
glm::vec3 A(1, 2, 3);
#if((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
{
glm::vec3 B(A.xy, 3.0f);
Error += A == B ? 0 : 1;
@ -414,7 +414,7 @@ int test_vec3_swizzle_partial()
glm::vec3 B(A.xyz);
Error += A == B ? 0 : 1;
}
#endif//((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS))
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error;
}