mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Added swizzle operator from generated functions for non C++11 compiler
This commit is contained in:
parent
58be5cf410
commit
4843f8ffb9
@ -68,9 +68,11 @@
|
||||
return SWIZZLED_TYPE<TMPL_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) \
|
||||
|
@ -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
|
||||
|
@ -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<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>,s,t)
|
||||
_GLM_SWIZZLE2_3_MEMBERS(value_type,glm::detail::tvec3<value_type>,x,y)
|
||||
_GLM_SWIZZLE2_3_MEMBERS(value_type,glm::detail::tvec3<value_type>,r,g)
|
||||
_GLM_SWIZZLE2_3_MEMBERS(value_type,glm::detail::tvec3<value_type>,s,t)
|
||||
_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>,s,t)
|
||||
# ifdef GLM_SWIZZLE_OPERATOR
|
||||
_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>, s, t)
|
||||
_GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y)
|
||||
_GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g)
|
||||
_GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t)
|
||||
_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>, 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
|
||||
|
||||
//////////////////////////////////////
|
||||
|
@ -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<TMPL_TYPE> A ## B ## C() CONST \
|
||||
{ \
|
||||
return SWIZZLED_TYPE<TMPL_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<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>,s,t,p)
|
||||
@ -76,6 +89,7 @@ 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>,r,g,b)
|
||||
_GLM_SWIZZLE3_4_MEMBERS(value_type,glm::detail::tvec4<value_type>,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
|
||||
|
||||
//////////////////////////////////////
|
||||
|
@ -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<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>,s,t,p,q)
|
||||
@ -76,6 +83,7 @@ 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>,r,g,b,a)
|
||||
_GLM_SWIZZLE4_4_MEMBERS(value_type,glm::detail::tvec4<value_type>,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
|
||||
|
||||
//////////////////////////////////////
|
||||
|
@ -80,8 +80,6 @@
|
||||
#ifndef glm_glm
|
||||
#define glm_glm
|
||||
|
||||
#define GLM_FORCE_CXX98
|
||||
|
||||
#include <cmath>
|
||||
#include <climits>
|
||||
#include <cfloat>
|
||||
|
@ -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 <glm/glm.hpp>
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user