Fixed setup options

This commit is contained in:
Christophe Riccio 2011-10-20 14:03:08 +01:00
parent ee15fe5289
commit 5050bfacf7
13 changed files with 132 additions and 128 deletions

View File

@ -100,7 +100,7 @@ namespace detail
template <> template <>
GLM_FUNC_QUALIFIER detail::thalf floor<detail::thalf>(detail::thalf const & x) GLM_FUNC_QUALIFIER detail::thalf floor<detail::thalf>(detail::thalf const & x)
{ {
return detail::thalf(::std::floor(x.toFloat())); return detail::thalf(::std::floor(float(x)));
} }
template <typename genType> template <typename genType>

View File

@ -300,13 +300,13 @@
// User defines: GLM_FORCE_CXX98 // User defines: GLM_FORCE_CXX98
#define GLM_LANG_CXX 0 #define GLM_LANG_CXX (0 << 0)
#define GLM_LANG_CXX98 1 #define GLM_LANG_CXX98 ((1 << 1) | GLM_LANG_CXX)
#define GLM_LANG_CXX03 2 #define GLM_LANG_CXX03 ((1 << 2) | GLM_LANG_CXX98)
#define GLM_LANG_CXX0X 3 #define GLM_LANG_CXX0X ((1 << 3) | GLM_LANG_CXX03)
#define GLM_LANG_CXX11 4 #define GLM_LANG_CXX11 ((1 << 4) | GLM_LANG_CXX11)
#define GLM_LANG_CXXMS 5 #define GLM_LANG_CXXMS (1 << 5)
#define GLM_LANG_CXXGNU 6 #define GLM_LANG_CXXGNU (1 << 6)
#if(defined(GLM_FORCE_CXX11)) #if(defined(GLM_FORCE_CXX11))
# define GLM_LANG GLM_LANG_CXX11 # define GLM_LANG GLM_LANG_CXX11
@ -314,20 +314,22 @@
# define GLM_LANG GLM_LANG_CXX03 # define GLM_LANG GLM_LANG_CXX03
#elif(defined(GLM_FORCE_CXX98)) #elif(defined(GLM_FORCE_CXX98))
# define GLM_LANG GLM_LANG_CXX98 # define GLM_LANG GLM_LANG_CXX98
#elif(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && defined(__STRICT_ANSI__))
# 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_VC) == GLM_COMPILER_VC) && defined(_MSC_EXTENSIONS))
# define GLM_LANG GLM_LANG_CXXMS
#elif(((GLM_COMPILER & GLM_COMPILER_VC) == GLM_COMPILER_VC) && !defined(_MSC_EXTENSIONS))
# if(GLM_COMPILER >= GLM_COMPILER_VC2010)
# define GLM_LANG GLM_LANG_CXX0X
# else
# define GLM_LANG GLM_LANG_CXX98
# endif//(GLM_COMPILER == GLM_COMPILER_VC2010)
#else #else
# define GLM_LANG GLM_LANG_CXX # if(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && defined(__STRICT_ANSI__))
# 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_VC) == GLM_COMPILER_VC) && defined(_MSC_EXTENSIONS))
# define GLM_LANG GLM_LANG_CXXMS
# elif(((GLM_COMPILER & GLM_COMPILER_VC) == GLM_COMPILER_VC) && !defined(_MSC_EXTENSIONS))
# if(GLM_COMPILER >= GLM_COMPILER_VC2010)
# define GLM_LANG GLM_LANG_CXX0X
# else
# define GLM_LANG GLM_LANG_CXX98
# endif//(GLM_COMPILER == GLM_COMPILER_VC2010)
# else
# define GLM_LANG GLM_LANG_CXX
# endif
#endif #endif
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED)) #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED))
@ -430,38 +432,46 @@
# endif//GLM_ARCH # endif//GLM_ARCH
#endif//GLM_MESSAGE #endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Support check macros
#define GLM_SUPPORT_ANONYMOUS_UNION() \
((GLM_LANG & GLM_LANG_CXX98) == GLM_LANG_CXX98)
#define GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() \
(((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || ((GLM_LANG & GLM_LANG_CXXMS) == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X)))
#define GLM_SUPPORT_SWIZZLE_OPERATOR() \
(defined(GLM_SWIZZLE) && GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE())
#define GLM_SUPPORT_SWIZZLE_FUNCTION() defined(GLM_SWIZZLE)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Components // Components
//#define GLM_FORCE_ONLY_XYZW //#define GLM_FORCE_ONLY_XYZW
#define GLM_COMPONENT_GLSL_NAMES 0 #define GLM_COMPONENT_ONLY_XYZW 0 // To disable multiple vector component names access.
#define GLM_COMPONENT_ONLY_XYZW 1 // To disable multiple vector component names access. #define GLM_COMPONENT_CXX98 1 //
#define GLM_COMPONENT_MS_EXT 2 // To use anonymous union to provide multiple component names access for class valType. Visual C++ only. #define GLM_COMPONENT_CXX11 2 // To use anonymous union to provide multiple component names access for class valType. Visual C++ only.
#ifndef GLM_FORCE_ONLY_XYZW #if(GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() && !defined(GLM_FORCE_ONLY_XYZW))
# if((GLM_COMPILER & GLM_COMPILER_VC) && defined(_MSC_EXTENSIONS)) # define GLM_COMPONENT GLM_COMPONENT_CXX11
# define GLM_COMPONENT GLM_COMPONENT_MS_EXT #elif(GLM_SUPPORT_ANONYMOUS_UNION() && !defined(GLM_FORCE_ONLY_XYZW))
# else # define GLM_COMPONENT GLM_COMPONENT_CXX98
# define GLM_COMPONENT GLM_COMPONENT_GLSL_NAMES
# endif
#else #else
# define GLM_COMPONENT GLM_COMPONENT_ONLY_XYZW # define GLM_COMPONENT GLM_COMPONENT_ONLY_XYZW
#endif #endif
#if((GLM_COMPONENT == GLM_COMPONENT_MS_EXT) && !(GLM_COMPILER & GLM_COMPILER_VC))
# error "GLM_COMPONENT value is GLM_COMPONENT_MS_EXT but this is not allowed with the current compiler."
#endif
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPONENT_DISPLAYED)) #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPONENT_DISPLAYED))
# define GLM_MESSAGE_COMPONENT_DISPLAYED # define GLM_MESSAGE_COMPONENT_DISPLAYED
# if(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES) # if(GLM_COMPONENT == GLM_COMPONENT_CXX98)
# pragma message("GLM: GLSL multiple vector component names") # 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) # elif(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
# pragma message("GLM: x,y,z,w vector component names only") # pragma message("GLM: x,y,z,w component names for all vector types")
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT) # elif(GLM_COMPONENT == GLM_COMPONENT_CXX11)
# pragma message("GLM: Multiple vector component names through Visual C++ language extensions") # pragma message("GLM: x,y,z,w; r,g,b,a; s,t,p,q component names for all vector types")
# else # else
# error "GLM_COMPONENT value unknown" # error "GLM: GLM_COMPONENT value unknown"
# endif//GLM_MESSAGE_COMPONENT_DISPLAYED # endif//GLM_MESSAGE_COMPONENT_DISPLAYED
#endif//GLM_MESSAGE #endif//GLM_MESSAGE
@ -513,13 +523,6 @@
#define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL #define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL
#define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE #define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Support check macros
#define GLM_SUPPORT_SWIZZLE_OPERATOR() (defined(GLM_SWIZZLE) && \
((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_LANG == GLM_LANG_CXX0X))))
#define GLM_SUPPORT_SWIZZLE_FUNCTION() defined(GLM_SWIZZLE)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Swizzle operators // Swizzle operators

View File

@ -272,7 +272,7 @@ namespace detail
template <typename U> template <typename U>
GLM_FUNC_QUALIFIER thalf::operator U() const GLM_FUNC_QUALIFIER thalf::operator U() const
{ {
return static_cast<U>(this->toFloat()); return static_cast<U>(toFloat32(this->data));
} }
// Unary updatable operators // Unary updatable operators
@ -325,38 +325,38 @@ namespace detail
GLM_FUNC_QUALIFIER detail::thalf operator+ (detail::thalf const & s1, detail::thalf const & s2) GLM_FUNC_QUALIFIER detail::thalf operator+ (detail::thalf const & s1, detail::thalf const & s2)
{ {
return detail::thalf(s1.toFloat() + s2.toFloat()); return detail::thalf(float(s1) + float(s2));
} }
GLM_FUNC_QUALIFIER detail::thalf operator- (detail::thalf const & s1, detail::thalf const & s2) GLM_FUNC_QUALIFIER detail::thalf operator- (detail::thalf const & s1, detail::thalf const & s2)
{ {
return detail::thalf(s1.toFloat() - s2.toFloat()); return detail::thalf(float(s1) - float(s2));
} }
GLM_FUNC_QUALIFIER detail::thalf operator* (detail::thalf const & s1, detail::thalf const & s2) GLM_FUNC_QUALIFIER detail::thalf operator* (detail::thalf const & s1, detail::thalf const & s2)
{ {
return detail::thalf(s1.toFloat() * s2.toFloat()); return detail::thalf(float(s1) * float(s2));
} }
GLM_FUNC_QUALIFIER detail::thalf operator/ (detail::thalf const & s1, detail::thalf const & s2) GLM_FUNC_QUALIFIER detail::thalf operator/ (detail::thalf const & s1, detail::thalf const & s2)
{ {
return detail::thalf(s1.toFloat() / s2.toFloat()); return detail::thalf(float(s1) / float(s2));
} }
// Unary constant operators // Unary constant operators
GLM_FUNC_QUALIFIER detail::thalf operator- (detail::thalf const & s) GLM_FUNC_QUALIFIER detail::thalf operator- (detail::thalf const & s)
{ {
return detail::thalf(-s.toFloat()); return detail::thalf(-float(s));
} }
GLM_FUNC_QUALIFIER detail::thalf operator-- (detail::thalf const & s, int) GLM_FUNC_QUALIFIER detail::thalf operator-- (detail::thalf const & s, int)
{ {
return detail::thalf(s.toFloat() - 1.0f); return detail::thalf(float(s) - 1.0f);
} }
GLM_FUNC_QUALIFIER detail::thalf operator++ (detail::thalf const & s, int) GLM_FUNC_QUALIFIER detail::thalf operator++ (detail::thalf const & s, int)
{ {
return detail::thalf(s.toFloat() + 1.0f); return detail::thalf(float(s) + 1.0f);
} }
GLM_FUNC_QUALIFIER bool operator== GLM_FUNC_QUALIFIER bool operator==
@ -383,7 +383,7 @@ namespace detail
detail::thalf const & y detail::thalf const & y
) )
{ {
return x.toFloat() < y.toFloat(); return float(x) < float(y);
} }
GLM_FUNC_QUALIFIER bool operator<= GLM_FUNC_QUALIFIER bool operator<=
@ -392,7 +392,7 @@ namespace detail
detail::thalf const & y detail::thalf const & y
) )
{ {
return x.toFloat() <= y.toFloat(); return float(x) <= float(y);
} }
GLM_FUNC_QUALIFIER bool operator> GLM_FUNC_QUALIFIER bool operator>
@ -401,7 +401,7 @@ namespace detail
detail::thalf const & y detail::thalf const & y
) )
{ {
return x.toFloat() > y.toFloat(); return float(x) > float(y);
} }
GLM_FUNC_QUALIFIER bool operator>= GLM_FUNC_QUALIFIER bool operator>=
@ -410,7 +410,7 @@ namespace detail
detail::thalf const & y detail::thalf const & y
) )
{ {
return x.toFloat() >= y.toFloat(); return float(x) >= float(y);
} }
}//namespace detail }//namespace detail

View File

@ -62,18 +62,10 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) # if(GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() && !defined(GLM_FORCE_ONLY_XYZW))
value_type x, y;
# if(GLM_SUPPORT_SWIZZLE_FUNCTION())
// Defines all he swizzle operator as functions
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_SUPPORT_SWIZZLE_FUNCTION()
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
union union
{ {
# if(GLM_SUPPORT_SWIZZLE_OPERATOR()) # if(defined(GLM_SWIZZLE))
_GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y) _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y)
_GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g) _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g)
_GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t) _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t)
@ -83,21 +75,29 @@ namespace detail
_GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y) _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y)
_GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g) _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g)
_GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t) _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t)
# endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) # endif//(defined(GLM_SWIZZLE))
struct{value_type r, g;}; struct{value_type r, g;};
struct{value_type s, t;}; struct{value_type s, t;};
struct{value_type x, y;}; struct{value_type x, y;};
}; };
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES) # elif(GLM_SUPPORT_ANONYMOUS_UNION() && !defined(GLM_FORCE_ONLY_XYZW))
union {value_type x, r, s;}; union {value_type x, r, s;};
union {value_type y, g, t;}; union {value_type y, g, t;};
# if(GLM_SUPPORT_SWIZZLE_FUNCTION()) # if(defined(GLM_SWIZZLE))
// Defines all he swizzle operator as functions // Defines all he swizzle operator as functions
GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2) 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) GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
# endif//GLM_SUPPORT_SWIZZLE_FUNCTION() # endif//(defined(GLM_SWIZZLE))
# else
value_type x, y;
# if(defined(GLM_SWIZZLE))
// Defines all he swizzle operator as functions
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//(defined(GLM_SWIZZLE))
# endif//GLM_COMPONENT # endif//GLM_COMPONENT
////////////////////////////////////// //////////////////////////////////////

View File

@ -62,18 +62,10 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) # if(GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() && !defined(GLM_FORCE_ONLY_XYZW))
value_type x, y, z;
# if(GLM_SUPPORT_SWIZZLE_FUNCTION())
// Defines all he swizzle operator as functions
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_SUPPORT_SWIZZLE_FUNCTION()
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
union union
{ {
# if(GLM_SUPPORT_SWIZZLE_OPERATOR()) # if(defined(GLM_SWIZZLE))
_GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y, z) _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y, z)
_GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b) _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b)
_GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p) _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p)
@ -83,22 +75,30 @@ namespace detail
_GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z) _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z)
_GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b) _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b)
_GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p) _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p)
# endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) # endif//(defined(GLM_SWIZZLE))
struct{value_type r, g, b;}; struct{value_type r, g, b;};
struct{value_type s, t, p;}; struct{value_type s, t, p;};
struct{value_type x, y, z;}; struct{value_type x, y, z;};
}; };
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES) # elif(GLM_SUPPORT_ANONYMOUS_UNION() && !defined(GLM_FORCE_ONLY_XYZW))
union {value_type x, r, s;}; union {value_type x, r, s;};
union {value_type y, g, t;}; union {value_type y, g, t;};
union {value_type z, b, p;}; union {value_type z, b, p;};
# if(GLM_SUPPORT_SWIZZLE_FUNCTION()) # if(defined(GLM_SWIZZLE))
// Defines all he swizzle operator as functions // Defines all he swizzle operator as functions
GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, detail::tvec3, detail::tref2, detail::tref3) 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) GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4)
# endif//GLM_SUPPORT_SWIZZLE_FUNCTION() # endif//(defined(GLM_SWIZZLE))
# else
value_type x, y, z;
# if(defined(GLM_SWIZZLE))
// Defines all he swizzle operator as functions
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//(defined(GLM_SWIZZLE))
# endif//GLM_COMPONENT # endif//GLM_COMPONENT
////////////////////////////////////// //////////////////////////////////////

View File

@ -62,18 +62,10 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW) # if(GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() && !defined(GLM_FORCE_ONLY_XYZW))
value_type x, y, z, w;
# if(GLM_SUPPORT_SWIZZLE_FUNCTION())
// Defines all he swizzle operator as functions
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_SUPPORT_SWIZZLE_FUNCTION()
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
union union
{ {
# if(GLM_SUPPORT_SWIZZLE_OPERATOR()) # if(defined(GLM_SWIZZLE))
_GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y, z, w) _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y, z, w)
_GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b, a) _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b, a)
_GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p, q) _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p, q)
@ -83,23 +75,31 @@ namespace detail
_GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z, w) _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z, w)
_GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b, a) _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b, a)
_GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p, q) _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p, q)
# endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) # endif//(defined(GLM_SWIZZLE))
struct{value_type r, g, b, a;}; struct{value_type r, g, b, a;};
struct{value_type s, t, p, q;}; struct{value_type s, t, p, q;};
struct{value_type x, y, z, w;}; struct{value_type x, y, z, w;};
}; };
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES) # elif(GLM_SUPPORT_ANONYMOUS_UNION() && !defined(GLM_FORCE_ONLY_XYZW))
union {value_type x, r, s;}; union {value_type x, r, s;};
union {value_type y, g, t;}; union {value_type y, g, t;};
union {value_type z, b, p;}; union {value_type z, b, p;};
union {value_type w, a, q;}; union {value_type w, a, q;};
# if(GLM_SUPPORT_SWIZZLE_FUNCTION()) # if(defined(GLM_SWIZZLE))
// Defines all he swizzle operator as functions // 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_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) GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4)
# endif//GLM_SUPPORT_SWIZZLE_FUNCTION() # endif//(defined(GLM_SWIZZLE))
# else
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, 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//(defined(GLM_SWIZZLE))
# endif//GLM_COMPONENT # endif//GLM_COMPONENT
////////////////////////////////////// //////////////////////////////////////

View File

@ -43,7 +43,7 @@ namespace detail
GLM_FUNC_QUALIFIER std::string to_string(detail::thalf const & x) GLM_FUNC_QUALIFIER std::string to_string(detail::thalf const & x)
{ {
return detail::format("half(%2.4f)", x.toFloat()); return detail::format("half(%2.4f)", float(x));
} }
GLM_FUNC_QUALIFIER std::string to_string(float x) GLM_FUNC_QUALIFIER std::string to_string(float x)

View File

@ -8,9 +8,10 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
//#define GLM_FORCE_ONLY_XYZW //#define GLM_FORCE_ONLY_XYZW
//#define GLM_FORCE_PURE
#define GLM_MESSAGES #define GLM_MESSAGES
#define GLM_SWIZZLE_OPERATOR #define GLM_SWIZZLE
#define GLM_FORCE_CXX98 //#define GLM_FORCE_CXX98
#include <glm/glm.hpp> #include <glm/glm.hpp>
int test_vec2_swizzle() int test_vec2_swizzle()

View File

@ -15,13 +15,13 @@ int test_half_ctor()
int Error = 0; int Error = 0;
glm::half A(1.0f); glm::half A(1.0f);
Error += A.toFloat() == 1.0f ? 0 : 1; Error += float(A) == 1.0f ? 0 : 1;
glm::half B = glm::half(1.0f); glm::half B = glm::half(1.0f);
Error += B.toFloat() == 1.0f ? 0 : 1; Error += float(B) == 1.0f ? 0 : 1;
glm::half C = B; glm::half C = B;
Error += C.toFloat() == 1.0f ? 0 : 1; Error += float(C) == 1.0f ? 0 : 1;
return Error; return Error;
} }
@ -31,13 +31,13 @@ int test_half_cast()
int Error = 0; int Error = 0;
glm::half A(2.0f); glm::half A(2.0f);
Error += A.toFloat() == 2.0f ? 0 : 1; Error += float(A) == 2.0f ? 0 : 1;
glm::half B(2.0); glm::half B(2.0);
Error += B.toFloat() == 2.0f ? 0 : 1; Error += float(B) == 2.0f ? 0 : 1;
glm::half C(2); glm::half C(2);
Error += C.toFloat() == 2.0f ? 0 : 1; Error += float(C) == 2.0f ? 0 : 1;
float D(A); float D(A);
Error += D == 2.0f ? 0 : 1; Error += D == 2.0f ? 0 : 1;

View File

@ -7,7 +7,7 @@
// File : test/core/type_vec1.cpp // File : test/core/type_vec1.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_SWIZZLE_OPERATOR #define GLM_SWIZZLE
#include <glm/glm.hpp> #include <glm/glm.hpp>
static int test_operators() static int test_operators()

View File

@ -7,7 +7,7 @@
// File : test/core/type_vec2.cpp // File : test/core/type_vec2.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_SWIZZLE_OPERATOR #define GLM_SWIZZLE
#include <glm/glm.hpp> #include <glm/glm.hpp>
int test_vec2_operators() int test_vec2_operators()

View File

@ -7,7 +7,7 @@
// File : test/core/type_vec3.cpp // File : test/core/type_vec3.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_SWIZZLE_OPERATOR #define GLM_SWIZZLE
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp> #include <glm/gtc/half_float.hpp>
#include <cstdio> #include <cstdio>
@ -280,29 +280,29 @@ int test_vec3_swizzle_half()
u = v; u = v;
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; Error += (u.x == glm::half(1.0f) && u.y == glm::half(2.0f) && u.z == glm::half(3.0f)) ? 0 : 1;
#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) #if(GLM_SUPPORT_SWIZZLE_OPERATOR())
u = v.xyz; u = v.xyz;
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; Error += (u.x == glm::half(1.0f) && u.y == glm::half(2.0f) && u.z == glm::half(3.0f)) ? 0 : 1;
u = v.zyx; u = v.zyx;
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; Error += (u.x == glm::half(3.0f) && u.y == glm::half(2.0f) && u.z == glm::half(1.0f)) ? 0 : 1;
u.zyx = v; u.zyx = v;
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; Error += (u.x == glm::half(3.0f) && u.y == glm::half(2.0f) && u.z == glm::half(1.0f)) ? 0 : 1;
u = v.rgb; u = v.rgb;
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; Error += (u.x == glm::half(1.0f) && u.y == glm::half(2.0f) && u.z == glm::half(3.0f)) ? 0 : 1;
u = v.bgr; u = v.bgr;
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; Error += (u.x == glm::half(3.0f) && u.y == glm::half(2.0f) && u.z == glm::half(1.0f)) ? 0 : 1;
u.bgr = v; u.bgr = v;
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; Error += (u.x == glm::half(3.0f) && u.y == glm::half(2.0f) && u.z == glm::half(1.0f)) ? 0 : 1;
u = v.stp; u = v.stp;
Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; Error += (u.x == glm::half(1.0f) && u.y == glm::half(2.0f) && u.z == glm::half(3.0f)) ? 0 : 1;
u = v.pts; u = v.pts;
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; Error += (u.x == glm::half(3.0f) && u.y == glm::half(2.0f) && u.z == glm::half(1.0f)) ? 0 : 1;
u.pts = v; u.pts = v;
Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; Error += (u.x == glm::half(3.0f) && u.y == glm::half(2.0f) && u.z == glm::half(1.0f)) ? 0 : 1;
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) #endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error; return Error;
@ -361,9 +361,9 @@ int test_vec3_swizzle_functions()
// glm::dot(u.xy(), v.xy()); <--- Compiles correctly // glm::dot(u.xy(), v.xy()); <--- Compiles correctly
// //
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
float r; float r;
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
// vec2 // vec2
glm::vec2 a(1, 2); glm::vec2 a(1, 2);
glm::vec2 b(10, 20); glm::vec2 b(10, 20);
@ -397,9 +397,9 @@ int test_vec3_swizzle_partial()
{ {
int Error = 0; int Error = 0;
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
glm::vec3 A(1, 2, 3); glm::vec3 A(1, 2, 3);
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
{ {
glm::vec3 B(A.xy, 3.0f); glm::vec3 B(A.xy, 3.0f);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;

View File

@ -7,7 +7,7 @@
// File : test/core/type_vec4.cpp // File : test/core/type_vec4.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_SWIZZLE_OPERATOR #define GLM_SWIZZLE
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp> #include <glm/gtc/half_float.hpp>
#include <vector> #include <vector>
@ -220,7 +220,7 @@ int test_vec4_swizzle_partial()
glm::vec4 A(1, 2, 3, 4); glm::vec4 A(1, 2, 3, 4);
#if((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS)) #if(GLM_SUPPORT_SWIZZLE_OPERATOR())
{ {
glm::vec4 B(A.xy, A.zw); glm::vec4 B(A.xy, A.zw);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
@ -246,7 +246,7 @@ int test_vec4_swizzle_partial()
glm::vec4 B(1.0f, A.yzw); glm::vec4 B(1.0f, A.yzw);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
} }
#endif//((GLM_LANG == GLM_LANG_CXX11) || (GLM_LANG == GLM_LANG_CXXMS)) #endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error; return Error;
} }