Merge nohalf

master
Christophe Riccio ago%!(EXTRA string=12 years)
commit f511121559
  1. BIN
      doc/glm.docx
  2. 51
      glm/core/setup.hpp
  3. 5
      glm/core/type_mat2x2.hpp
  4. 11
      glm/core/type_mat2x2.inl
  5. 4
      glm/core/type_mat2x3.hpp
  6. 11
      glm/core/type_mat2x3.inl
  7. 4
      glm/core/type_mat2x4.hpp
  8. 11
      glm/core/type_mat2x4.inl
  9. 2
      glm/core/type_mat3x2.hpp
  10. 12
      glm/core/type_mat3x2.inl
  11. 2
      glm/core/type_mat3x3.hpp
  12. 12
      glm/core/type_mat3x3.inl
  13. 4
      glm/core/type_mat3x4.hpp
  14. 12
      glm/core/type_mat3x4.inl
  15. 4
      glm/core/type_mat4x2.hpp
  16. 24
      glm/core/type_mat4x2.inl
  17. 4
      glm/core/type_mat4x3.hpp
  18. 30
      glm/core/type_mat4x3.inl
  19. 4
      glm/core/type_mat4x4.hpp
  20. 15
      glm/core/type_mat4x4.inl
  21. 6
      glm/core/type_vec1.hpp
  22. 19
      glm/core/type_vec1.inl
  23. 71
      glm/core/type_vec2.hpp
  24. 20
      glm/core/type_vec2.inl
  25. 49
      glm/core/type_vec3.hpp
  26. 21
      glm/core/type_vec3.inl
  27. 63
      glm/core/type_vec4.hpp
  28. 52
      glm/core/type_vec4.inl
  29. 4
      glm/gtc/packing.inl
  30. 2
      glm/gtx/simd_vec4.hpp
  31. 2
      glm/gtx/simd_vec4.inl
  32. 1
      readme.txt
  33. 48
      test/core/core_func_swizzle.cpp
  34. 241
      test/core/core_type_vec3.cpp
  35. 4
      test/core/core_type_vec4.cpp
  36. 416
      test/gtc/gtc_packing.cpp
  37. 19
      test/gtc/gtc_type_precision.cpp

Binary file not shown.

@ -133,8 +133,6 @@
// GCC defines // GCC defines
#define GLM_COMPILER_GCC 0x02000000 #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_GCC34 0x02000050
#define GLM_COMPILER_GCC35 0x02000060 #define GLM_COMPILER_GCC35 0x02000060
#define GLM_COMPILER_GCC40 0x02000070 #define GLM_COMPILER_GCC40 0x02000070
@ -588,49 +586,6 @@
# 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_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 // Radians
@ -693,10 +648,8 @@
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED))
# define GLM_MESSAGE_SWIZZLE_DISPLAYED # define GLM_MESSAGE_SWIZZLE_DISPLAYED
# if(GLM_SUPPORT_SWIZZLE_OPERATOR()) # if defined(GLM_SWIZZLE)
# pragma message("GLM: Swizzling operators enabled") # pragma message("GLM: Swizzling operators enabled")
# elif(GLM_SUPPORT_SWIZZLE_FUNCTION())
# pragma message("GLM: Swizzling operators supported through swizzling functions")
# else # else
# pragma message("GLM: Swizzling operators disabled") # pragma message("GLM: Swizzling operators disabled")
# endif # endif
@ -719,7 +672,7 @@
# define GLM_RESTRICT # define GLM_RESTRICT
# define GLM_RESTRICT_VAR __restrict # define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR # 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_DEPRECATED __attribute__((__deprecated__))
# define GLM_ALIGN(x) __attribute__((aligned(x))) # define GLM_ALIGN(x) __attribute__((aligned(x)))
# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x))) # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))

@ -65,8 +65,9 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Constructors // Constructors
GLM_FUNC_DECL tmat2x2(); GLM_FUNC_DECL tmat2x2();
GLM_FUNC_DECL tmat2x2( GLM_FUNC_DECL tmat2x2(tmat2x2<T, P> const & m);
tmat2x2 const & m); template <precision Q>
GLM_FUNC_DECL tmat2x2(tmat2x2<T, Q> const & m);
GLM_FUNC_DECL explicit tmat2x2( GLM_FUNC_DECL explicit tmat2x2(
ctor Null); ctor Null);

@ -92,6 +92,15 @@ namespace detail
this->value[1] = m.value[1]; this->value[1] = m.value[1];
} }
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2(
tmat2x2<T, Q> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2
( (
@ -133,7 +142,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat2x2<T, P>::tmat2x2 GLM_FUNC_DECL tmat2x2<T, P>::tmat2x2

@ -58,7 +58,9 @@ namespace detail
public: public:
// Constructors // Constructors
GLM_FUNC_DECL tmat2x3(); GLM_FUNC_DECL tmat2x3();
GLM_FUNC_DECL tmat2x3(tmat2x3 const & m); GLM_FUNC_DECL tmat2x3(tmat2x3<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat2x3(tmat2x3<T, Q> const & m);
GLM_FUNC_DECL explicit tmat2x3( GLM_FUNC_DECL explicit tmat2x3(
ctor); ctor);

@ -92,6 +92,15 @@ namespace detail
this->value[1] = m.value[1]; this->value[1] = m.value[1];
} }
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(
tmat2x3<T, Q> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3
( (
@ -132,7 +141,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat2x3<T, P>::tmat2x3 GLM_FUNC_DECL tmat2x3<T, P>::tmat2x3

@ -58,7 +58,9 @@ namespace detail
public: public:
// Constructors // Constructors
GLM_FUNC_DECL tmat2x4(); GLM_FUNC_DECL tmat2x4();
GLM_FUNC_DECL tmat2x4(tmat2x4 const & m); GLM_FUNC_DECL tmat2x4(tmat2x4<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat2x4(tmat2x4<T, Q> const & m);
GLM_FUNC_DECL explicit tmat2x4( GLM_FUNC_DECL explicit tmat2x4(
ctor); ctor);

@ -94,6 +94,15 @@ namespace detail
this->value[1] = m.value[1]; this->value[1] = m.value[1];
} }
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4(
tmat2x4<T, Q> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4 GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4
( (
@ -135,7 +144,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>::tmat2x4 GLM_FUNC_DECL tmat2x4<T, P>::tmat2x4

@ -59,6 +59,8 @@ namespace detail
// Constructors // Constructors
GLM_FUNC_DECL tmat3x2(); GLM_FUNC_DECL tmat3x2();
GLM_FUNC_DECL tmat3x2(tmat3x2<T, P> const & m); GLM_FUNC_DECL tmat3x2(tmat3x2<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat3x2(tmat3x2<T, Q> const & m);
GLM_FUNC_DECL explicit tmat3x2( GLM_FUNC_DECL explicit tmat3x2(
ctor); ctor);

@ -94,6 +94,16 @@ namespace detail
this->value[2] = m.value[2]; this->value[2] = m.value[2];
} }
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2(
tmat3x2<T, Q> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2 GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2
( (
@ -139,7 +149,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat3x2<T, P>::tmat3x2 GLM_FUNC_DECL tmat3x2<T, P>::tmat3x2

@ -65,6 +65,8 @@ namespace detail
// Constructors // Constructors
GLM_FUNC_DECL tmat3x3(); GLM_FUNC_DECL tmat3x3();
GLM_FUNC_DECL tmat3x3(tmat3x3<T, P> const & m); GLM_FUNC_DECL tmat3x3(tmat3x3<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat3x3(tmat3x3<T, Q> const & m);
GLM_FUNC_DECL explicit tmat3x3( GLM_FUNC_DECL explicit tmat3x3(
ctor Null); ctor Null);

@ -103,6 +103,16 @@ namespace detail
) )
{} {}
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3(
tmat3x3<T, Q> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3 GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3
( (
@ -142,7 +152,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat3x3<T, P>::tmat3x3 GLM_FUNC_DECL tmat3x3<T, P>::tmat3x3

@ -58,7 +58,9 @@ namespace detail
public: public:
// Constructors // Constructors
GLM_FUNC_DECL tmat3x4(); GLM_FUNC_DECL tmat3x4();
GLM_FUNC_DECL tmat3x4(tmat3x4 const & m); GLM_FUNC_DECL tmat3x4(tmat3x4<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat3x4(tmat3x4<T, Q> const & m);
GLM_FUNC_DECL explicit tmat3x4( GLM_FUNC_DECL explicit tmat3x4(
ctor Null); ctor Null);

@ -94,6 +94,16 @@ namespace detail
this->value[2] = m.value[2]; this->value[2] = m.value[2];
} }
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(
tmat3x4<T, Q> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
this->value[2] = m.value[2];
}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4 GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4
( (
@ -140,7 +150,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat3x4<T, P>::tmat3x4 GLM_FUNC_DECL tmat3x4<T, P>::tmat3x4

@ -58,7 +58,9 @@ namespace detail
public: public:
// Constructors // Constructors
GLM_FUNC_DECL tmat4x2(); GLM_FUNC_DECL tmat4x2();
GLM_FUNC_DECL tmat4x2(tmat4x2 const & m); GLM_FUNC_DECL tmat4x2(tmat4x2<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat4x2(tmat4x2<T, Q> const & m);
GLM_FUNC_DECL explicit tmat4x2( GLM_FUNC_DECL explicit tmat4x2(
ctor Null); ctor Null);

@ -87,10 +87,8 @@ namespace detail
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2 GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(
( tmat4x2<T, P> const & m)
tmat4x2<T, P> const & m
)
{ {
this->value[0] = m.value[0]; this->value[0] = m.value[0];
this->value[1] = m.value[1]; this->value[1] = m.value[1];
@ -99,10 +97,18 @@ namespace detail
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2 template <precision Q>
( GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(
ctor tmat4x2<T, Q> 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 <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(ctor)
{} {}
template <typename T, precision P> template <typename T, precision P>
@ -149,7 +155,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat4x2<T, P>::tmat4x2 GLM_FUNC_DECL tmat4x2<T, P>::tmat4x2

@ -58,7 +58,9 @@ namespace detail
public: public:
// Constructors // Constructors
GLM_FUNC_DECL tmat4x3(); GLM_FUNC_DECL tmat4x3();
GLM_FUNC_DECL tmat4x3(tmat4x3 const & m); GLM_FUNC_DECL tmat4x3(tmat4x3<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat4x3(tmat4x3<T, Q> const & m);
GLM_FUNC_DECL explicit tmat4x3( GLM_FUNC_DECL explicit tmat4x3(
ctor Null); ctor Null);

@ -87,10 +87,19 @@ namespace detail
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3 GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(
( tmat4x3<T, P> const & m)
tmat4x3<T, P> 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 <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(
tmat4x3<T, Q> const & m)
{ {
this->value[0] = m.value[0]; this->value[0] = m.value[0];
this->value[1] = m.value[1]; this->value[1] = m.value[1];
@ -99,17 +108,12 @@ namespace detail
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3 GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(ctor)
(
ctor
)
{} {}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3 GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3(
( value_type const & s)
value_type const & s
)
{ {
value_type const Zero(0); value_type const Zero(0);
this->value[0] = col_type(s, Zero, Zero); this->value[0] = col_type(s, Zero, Zero);
@ -149,7 +153,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat4x3<T, P>::tmat4x3 GLM_FUNC_DECL tmat4x3<T, P>::tmat4x3

@ -64,7 +64,9 @@ namespace detail
public: public:
// Constructors // Constructors
GLM_FUNC_DECL tmat4x4(); GLM_FUNC_DECL tmat4x4();
GLM_FUNC_DECL tmat4x4(tmat4x4 const & m); GLM_FUNC_DECL tmat4x4(tmat4x4<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat4x4(tmat4x4<T, Q> const & m);
GLM_FUNC_DECL explicit tmat4x4( GLM_FUNC_DECL explicit tmat4x4(
ctor Null); ctor Null);

@ -98,6 +98,19 @@ namespace detail
this->value[3] = m.value[3]; this->value[3] = m.value[3];
} }
template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4
(
tmat4x4<T, Q> 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 <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4 GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4
( (
@ -162,7 +175,7 @@ namespace detail
} }
////////////////////////////////////// //////////////////////////////////////
// Convertion constructors // Conversion constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_DECL tmat4x4<T, P>::tmat4x4 GLM_FUNC_DECL tmat4x4<T, P>::tmat4x4

@ -68,6 +68,8 @@ namespace detail
GLM_FUNC_DECL tvec1(); GLM_FUNC_DECL tvec1();
GLM_FUNC_DECL tvec1(tvec1<T, P> const & v); GLM_FUNC_DECL tvec1(tvec1<T, P> const & v);
template <precision Q>
GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors
@ -83,14 +85,14 @@ namespace detail
GLM_FUNC_DECL tvec1(tref1<T, P> const & r); GLM_FUNC_DECL tvec1(tref1<T, P> 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) //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U> template <typename U>
GLM_FUNC_DECL explicit tvec1(U const & s); 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) //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q> template <typename U, precision Q>

@ -69,14 +69,16 @@ namespace detail
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1 GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1
( (
ctor tvec1<T, P> const & v
) ) :
x(v.x)
{} {}
template <typename T, precision P> template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1 GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1
( (
tvec1<T, P> const & v tvec1<T, Q> const & v
) : ) :
x(v.x) x(v.x)
{} {}
@ -84,6 +86,13 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1
(
ctor
)
{}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1 GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1
( (
@ -104,7 +113,7 @@ namespace detail
{} {}
////////////////////////////////////// //////////////////////////////////////
// Convertion scalar constructors // Conversion scalar constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
@ -116,7 +125,7 @@ namespace detail
{} {}
////////////////////////////////////// //////////////////////////////////////
// Convertion vector constructors // Conversion vector constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U, precision Q> template <typename U, precision Q>

@ -22,7 +22,7 @@
/// ///
/// @ref core /// @ref core
/// @file glm/core/type_vec2.hpp /// @file glm/core/type_vec2.hpp
/// @date 2008-08-18 / 2011-06-15 /// @date 2008-08-18 / 2013-08-27
/// @author Christophe Riccio /// @author Christophe Riccio
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
@ -51,43 +51,32 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if(GLM_COMPONENT == GLM_COMPONENT_CXXMS) # if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE))
union union
{ {
struct{value_type x, y;}; struct{ value_type x, y; };
struct{value_type r, g;}; struct{ value_type r, g; };
struct{value_type s, t;}; 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, x, y) _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, r, g)
_GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, r, g) _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, s, t)
_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, x, y) _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, r, g)
_GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, r, g) _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, s, t)
_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, x, y) _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, r, g)
_GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, r, g) _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, s, t)
_GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, s, t) };
# endif//(defined(GLM_SWIZZLE)) # else
}; union {value_type x, r, s;};
# elif(GLM_COMPONENT == GLM_COMPONENT_CXX98) union {value_type y, g, t;};
union {value_type x, r, s;};
union {value_type y, g, t;}; # if(defined(GLM_SWIZZLE))
//GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, P, detail::tvec2, detail::tref2)
# if(defined(GLM_SWIZZLE)) GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, P, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
// Defines all he swizzle operator as functions # endif//(defined(GLM_SWIZZLE))
GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, P, detail::tvec2, detail::tref2) # endif//GLM_LANG
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
////////////////////////////////////// //////////////////////////////////////
// Accesses // Accesses
@ -100,6 +89,8 @@ namespace detail
GLM_FUNC_DECL tvec2(); GLM_FUNC_DECL tvec2();
GLM_FUNC_DECL tvec2(tvec2<T, P> const & v); GLM_FUNC_DECL tvec2(tvec2<T, P> const & v);
template <precision Q>
GLM_FUNC_DECL tvec2(tvec2<T, Q> const & v);
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // 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) //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U> template <typename U>
@ -137,7 +128,7 @@ namespace detail
V const & y); 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) //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, precision Q> template <typename U, precision Q>

@ -64,14 +64,17 @@ namespace detail
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2 GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2
( (
ctor tvec2<T, P> const & v
) ) :
x(v.x),
y(v.y)
{} {}
template <typename T, precision P> template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2 GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2
( (
tvec2<T, P> const & v tvec2<T, Q> const & v
) : ) :
x(v.x), x(v.x),
y(v.y) y(v.y)
@ -80,6 +83,13 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2
(
ctor
)
{}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2 GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2
( (
@ -112,7 +122,7 @@ namespace detail
{} {}
////////////////////////////////////// //////////////////////////////////////
// Convertion scalar constructors // Conversion scalar constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
@ -136,7 +146,7 @@ namespace detail
{} {}
////////////////////////////////////// //////////////////////////////////////
// Convertion vector constructors // Conversion vector constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U, precision Q> template <typename U, precision Q>

@ -51,14 +51,13 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if(GLM_COMPONENT == GLM_COMPONENT_CXXMS) # if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE))
union union
{ {
struct{value_type x, y, z;}; struct{ value_type x, y, z; };
struct{value_type r, g, b;}; struct{ value_type r, g, b; };
struct{value_type s, t, p;}; 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, x, y, z)
_GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, r, g, b) _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, r, g, b)
_GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, s, t, p) _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, x, y, z)
_GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, r, g, b) _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, r, g, b)
_GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, s, t, p) _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)) # endif//(defined(GLM_SWIZZLE))
}; # endif//GLM_LANG
# 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
////////////////////////////////////// //////////////////////////////////////
// Accesses // Accesses
@ -101,6 +90,8 @@ namespace detail
GLM_FUNC_DECL tvec3(); GLM_FUNC_DECL tvec3();
GLM_FUNC_DECL tvec3(tvec3<T, P> const & v); GLM_FUNC_DECL tvec3(tvec3<T, P> const & v);
template <precision Q>
GLM_FUNC_DECL tvec3(tvec3<T, Q> const & v);
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors
@ -115,7 +106,7 @@ namespace detail
value_type const & s3); 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 <typename U> template <typename U>
@ -129,7 +120,7 @@ namespace detail
W const & z); 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) //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, precision Q> template <typename A, typename B, precision Q>

@ -65,14 +65,18 @@ namespace detail
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3 GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3
( (
ctor tvec3<T, P> const & v
) ) :
x(v.x),
y(v.y),
z(v.z)
{} {}
template <typename T, precision P> template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3 GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3
( (
tvec3<T, P> const & v tvec3<T, Q> const & v
) : ) :
x(v.x), x(v.x),
y(v.y), y(v.y),
@ -82,6 +86,13 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3
(
ctor
)
{}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3 GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3
( (
@ -142,7 +153,7 @@ namespace detail
{} {}
////////////////////////////////////// //////////////////////////////////////
// Convertion scalar constructors // Conversion scalar constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
@ -169,7 +180,7 @@ namespace detail
{} {}
////////////////////////////////////// //////////////////////////////////////
// Convertion vector constructors // Conversion vector constructors
template <typename T, precision P> template <typename T, precision P>
template <typename A, typename B, precision Q> template <typename A, typename B, precision Q>

@ -51,14 +51,13 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Data // Data
# if(GLM_COMPONENT == GLM_COMPONENT_CXXMS) # if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE))
union union
{ {
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;};
# if(defined(GLM_SWIZZLE))
_GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, 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, r, g, b, a)
_GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, s, t, p, q) _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, x, y, z, w)
_GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, r, g, b, a) _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, r, g, b, a)
_GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, s, t, p, q) _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)) # endif//(defined(GLM_SWIZZLE))
}; # endif//GLM_LANG
# 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
////////////////////////////////////// //////////////////////////////////////
// Accesses // Accesses
@ -102,6 +91,8 @@ namespace detail
GLM_FUNC_DECL tvec4(); GLM_FUNC_DECL tvec4();
GLM_FUNC_DECL tvec4(type const & v); GLM_FUNC_DECL tvec4(type const & v);
template <precision Q>
GLM_FUNC_DECL tvec4(tvec4<T, Q> const & v);
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors
@ -117,22 +108,22 @@ namespace detail
value_type const & s3); 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 <typename U> template <typename U>
GLM_FUNC_DECL explicit tvec4( GLM_FUNC_DECL explicit tvec4(
U const & x); 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 <typename A, typename B, typename C, typename D> template <typename A, typename B, typename C, typename D>
GLM_FUNC_DECL explicit tvec4( GLM_FUNC_DECL explicit tvec4(
A const & x, A const & x,
B const & y, B const & y,
C const & z, 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) //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, precision Q> template <typename A, typename B, typename C, precision Q>
@ -232,8 +223,8 @@ namespace detail
// Unary arithmetic operators // Unary arithmetic operators
GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<T, P> const & v); GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<T, P> const & v);
template <typename U> template <typename U, precision Q>
GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<U, P> const & v); GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<U, Q> const & v);
template <typename U> template <typename U>
GLM_FUNC_DECL tvec4<T, P> & operator+=(U const & s); GLM_FUNC_DECL tvec4<T, P> & operator+=(U const & s);

@ -72,14 +72,19 @@ namespace detail
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4 GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
( (
ctor type const & v
) ) :
x(v.x),
y(v.y),
z(v.z),
w(v.w)
{} {}
template <typename T, precision P> template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4 GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
( (
type const & v tvec4<T, Q> const & v
) : ) :
x(v.x), x(v.x),
y(v.y), y(v.y),
@ -90,6 +95,13 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Explicit basic constructors // Explicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
(
ctor
)
{}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4 GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
( (
@ -237,8 +249,8 @@ namespace detail
{} {}
////////////////////////////////////// //////////////////////////////////////
// Convertion scalar constructors // Conversion scalar constructors
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4 GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
@ -266,8 +278,20 @@ namespace detail
w(value_type(w)) w(value_type(w))
{} {}
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
(
tvec4<U, Q> 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 <typename T, precision P> template <typename T, precision P>
template <typename A, typename B, typename C, precision Q> template <typename A, typename B, typename C, precision Q>
@ -350,18 +374,6 @@ namespace detail
w(value_type(v2.y)) w(value_type(v2.y))
{} {}
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
(
tvec4<U, Q> 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 // Unary arithmetic operators
@ -379,10 +391,10 @@ namespace detail
} }
template <typename T, precision P> template <typename T, precision P>
template <typename U> template <typename U, precision Q>
GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator= GLM_FUNC_QUALIFIER tvec4<T, P> & tvec4<T, P>::operator=
( (
tvec4<U, P> const & v tvec4<U, Q> const & v
) )
{ {
this->x = T(v.x); this->x = T(v.x);

@ -304,7 +304,7 @@ namespace detail
GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float const & v) 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; detail::unorm1x8 Packing;
Packing.data = Scaled; Packing.data = Scaled;
return Packing.pack; return Packing.pack;
@ -337,7 +337,7 @@ namespace detail
GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float const & v) 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; detail::snorm1x8 Packing;
Packing.data = Scaled; Packing.data = Scaled;
return Packing.pack; return Packing.pack;

@ -111,7 +111,7 @@ namespace detail
vec4 const & v); vec4 const & v);
//////////////////////////////////////// ////////////////////////////////////////
//// Convertion vector constructors //// Conversion vector constructors
fvec4SIMD(vec2 const & v, float const & s1, float const & s2); fvec4SIMD(vec2 const & v, float const & s1, float const & s2);
fvec4SIMD(float const & s1, vec2 const & v, float const & s2); fvec4SIMD(float const & s1, vec2 const & v, float const & s2);

@ -59,7 +59,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const v[4]) :
//fvec4SIMD(ref4<float> const & r); //fvec4SIMD(ref4<float> const & r);
////////////////////////////////////// //////////////////////////////////////
// Convertion vector constructors // Conversion vector constructors
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) : GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) :
Data(_mm_set_ps(s2, s1, v.y, v.x)) Data(_mm_set_ps(s2, s1, v.y, v.x))

@ -51,6 +51,7 @@ GLM 0.9.5.0: 2013-XX-XX
- Removed GTX_ocl_type extension - Removed GTX_ocl_type extension
- Fixed post increment and decrement operators - Fixed post increment and decrement operators
- Fixed perspective with zNear == 0 (#71) - Fixed perspective with zNear == 0 (#71)
- Removed l-value swizzle operators
- Clean up compiler detection code for unsupported compilers - Clean up compiler detection code for unsupported compilers
================================================================================ ================================================================================

@ -7,24 +7,11 @@
// File : test/core/core_func_swizzle.cpp // File : test/core/core_func_swizzle.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_FORCE_ONLY_XYZW #define GLM_MESSAGES
# define GLM_FORCE_ONLY_XYZW #define GLM_SWIZZLE
#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
#include <glm/glm.hpp> #include <glm/glm.hpp>
int test_vec2_swizzle() int test_ivec2_swizzle()
{ {
int Error = 0; int Error = 0;
@ -39,7 +26,7 @@ int test_vec2_swizzle()
return Error; return Error;
} }
int test_vec3_swizzle() int test_ivec3_swizzle()
{ {
int Error = 0; int Error = 0;
@ -54,7 +41,7 @@ int test_vec3_swizzle()
return Error; return Error;
} }
int test_vec4_swizzle() int test_ivec4_swizzle()
{ {
int Error = 0; int Error = 0;
@ -69,12 +56,33 @@ int test_vec4_swizzle()
return Error; 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 main()
{ {
int Error = 0; int Error = 0;
Error += test_vec2_swizzle(); Error += test_ivec2_swizzle();
Error += test_vec3_swizzle(); Error += test_ivec3_swizzle();
Error += test_ivec4_swizzle();
Error += test_vec4_swizzle(); Error += test_vec4_swizzle();
return Error; return Error;

@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-08-31 // Created : 2008-08-31
// Updated : 2011-09-19 // Updated : 2013-08-27
// Licence : This source is under MIT License // Licence : This source is under MIT License
// File : test/core/type_vec3.cpp // File : test/core/type_vec3.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -187,130 +187,131 @@ int test_vec3_size()
int test_vec3_swizzle3_2() int test_vec3_swizzle3_2()
{ {
int Error = 0; int Error = 0;
glm::vec3 v(1, 2, 3); glm::vec3 v(1, 2, 3);
glm::vec2 u; glm::vec2 u;
// Can not assign a vec3 swizzle to a vec2 # if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
//u = v.xyz; //Illegal // Can not assign a vec3 swizzle to a vec2
//u = v.rgb; //Illegal //u = v.xyz; //Illegal
//u = v.stp; //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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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; u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1;
// Mixed member aliases are not valid // Mixed member aliases are not valid
//u = v.rx; //Illegal //u = v.rx; //Illegal
//u = v.sy; //Illegal //u = v.sy; //Illegal
u = glm::vec2(1, 2);
u = glm::vec2(1, 2); v = glm::vec3(1, 2, 3);
v = glm::vec3(1, 2, 3); //v.xx = u; //Illegal
//v.xx = u; //Illegal v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1;
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.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.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; //v.yy = u; //Illegal
//v.yy = u; //Illegal v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1;
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.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.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1; //v.zz = u; //Illegal
//v.zz = u; //Illegal
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) # endif//GLM_LANG
return Error; return Error;
} }
int test_vec3_swizzle3_3() int test_vec3_swizzle3_3()
{ {
int Error = 0; int Error = 0;
glm::vec3 v(1, 2, 3); glm::vec3 v(1, 2, 3);
glm::vec3 u; glm::vec3 u;
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.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;
#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.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 = 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.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.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 = 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.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.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 = 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; u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) # endif//GLM_LANG
return Error;
return Error;
} }
int test_vec3_swizzle_operators() 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); u = glm::vec3(1, 2, 3);
v = glm::vec3(10, 20, 30); v = glm::vec3(10, 20, 30);
#if(GLM_SUPPORT_SWIZZLE_OPERATOR()) # if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
// Swizzle, swizzle binary operators // Swizzle, swizzle binary operators
q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1; 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.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.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.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1;
q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1; q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1;
// vec, swizzle binary operators // 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.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.xxx); Error += (q == v.x * u) ? 0 : 1;
q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1; q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1;
// swizzle,vec binary operators // 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.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.xxx * v); Error += (q == u.x * v) ? 0 : 1;
q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1; q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1;
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) # endif//GLM_LANG
// Compile errors // Compile errors
//q = (u.yz * v.xyz); //q = (u.yz * v.xyz);
//q = (u * v.xy); //q = (u * v.xy);
return Error; return Error;
} }
int test_vec3_swizzle_functions() 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); <--- Compile error
// 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;
// vec2 // 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, t); Error += (int(r) == 300) ? 0 : 1;
r = glm::dot(s.xyzw(), t.xyzw()); 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; r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
return Error; return Error;
} }
@ -360,9 +359,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_LANG & GLM_LANG_CXXMS_FLAG)
{ {
glm::vec3 B(A.xy, 3.0f); glm::vec3 B(A.xy, 3.0f);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
@ -377,7 +376,7 @@ int test_vec3_swizzle_partial()
glm::vec3 B(A.xyz); glm::vec3 B(A.xyz);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
} }
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR()) # endif//GLM_LANG
return Error; return Error;
} }

@ -216,7 +216,7 @@ int test_vec4_swizzle_partial()
glm::vec4 A(1, 2, 3, 4); 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); glm::vec4 B(A.xy, A.zw);
Error += A == B ? 0 : 1; Error += A == B ? 0 : 1;
@ -242,7 +242,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_SUPPORT_SWIZZLE_OPERATOR()) # endif//GLM_LANG
return Error; return Error;
} }

@ -31,287 +31,237 @@
#include <cstdio> #include <cstdio>
#include <vector> #include <vector>
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) void print_bits(float const & s)
{ {
union union
{ {
float f; float f;
unsigned int i; unsigned int i;
} uif; } uif;
uif.f = s; uif.f = s;
printf("f32: "); printf("f32: ");
for(std::size_t j = sizeof(s) * 8; j > 0; --j) for(std::size_t j = sizeof(s) * 8; j > 0; --j)
{ {
if(j == 23 || j == 31) if(j == 23 || j == 31)
printf(" "); printf(" ");
printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0); printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0);
} }
} }
void print_10bits(glm::uint const & s) void print_10bits(glm::uint const & s)
{ {
printf("10b: "); printf("10b: ");
for(std::size_t j = 10; j > 0; --j) for(std::size_t j = 10; j > 0; --j)
{ {
if(j == 5) if(j == 5)
printf(" "); printf(" ");
printf("%d", (s & (1 << (j - 1))) ? 1 : 0); printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
} }
} }
void print_11bits(glm::uint const & s) void print_11bits(glm::uint const & s)
{ {
printf("11b: "); printf("11b: ");
for(std::size_t j = 11; j > 0; --j) for(std::size_t j = 11; j > 0; --j)
{ {
if(j == 6) if(j == 6)
printf(" "); printf(" ");
printf("%d", (s & (1 << (j - 1))) ? 1 : 0); printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
} }
} }
void print_value(float const & s) void print_value(float const & s)
{ {
printf("%2.5f, ", s); printf("%2.5f, ", s);
print_bits(s); print_bits(s);
printf(", "); printf(", ");
print_bits(glm::half(s)); // print_11bits(detail::floatTo11bit(s));
// printf(", "); // printf(", ");
// print_11bits(detail::floatTo11bit(s)); // print_10bits(detail::floatTo10bit(s));
// printf(", "); printf("\n");
// 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;
} }
int test_Half1x16() int test_Half1x16()
{ {
int Error = 0; int Error = 0;
std::vector<float> Tests; std::vector<float> Tests;
Tests.push_back(0.0f); Tests.push_back(0.0f);
Tests.push_back(1.0f); Tests.push_back(1.0f);
Tests.push_back(-1.0f); Tests.push_back(-1.0f);
Tests.push_back(2.0f); Tests.push_back(2.0f);
Tests.push_back(-2.0f); Tests.push_back(-2.0f);
Tests.push_back(1.9f); Tests.push_back(1.9f);
for(std::size_t i = 0; i < Tests.size(); ++i) for(std::size_t i = 0; i < Tests.size(); ++i)
{ {
glm::uint32 p0 = glm::packHalf1x16(Tests[i]); glm::uint32 p0 = glm::packHalf1x16(Tests[i]);
float v0 = glm::unpackHalf1x16(p0); float v0 = glm::unpackHalf1x16(p0);
glm::uint32 p1 = glm::packHalf1x16(v0); glm::uint32 p1 = glm::packHalf1x16(v0);
float v1 = glm::unpackHalf1x16(p0); float v1 = glm::unpackHalf1x16(p0);
Error += (v0 == v1) ? 0 : 1; Error += (v0 == v1) ? 0 : 1;
} }
return Error; return Error;
} }
int test_Half4x16() int test_Half4x16()
{ {
int Error = 0; int Error = 0;
std::vector<glm::vec4> Tests; std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0)); Tests.push_back(glm::vec4(1.0));
Tests.push_back(glm::vec4(0.0)); Tests.push_back(glm::vec4(0.0));
Tests.push_back(glm::vec4(2.0)); Tests.push_back(glm::vec4(2.0));
Tests.push_back(glm::vec4(0.1)); Tests.push_back(glm::vec4(0.1));
Tests.push_back(glm::vec4(0.5)); Tests.push_back(glm::vec4(0.5));
Tests.push_back(glm::vec4(-0.9)); Tests.push_back(glm::vec4(-0.9));
for(std::size_t i = 0; i < Tests.size(); ++i) for(std::size_t i = 0; i < Tests.size(); ++i)
{ {
glm::uint64 p0 = glm::packHalf4x16(Tests[i]); glm::uint64 p0 = glm::packHalf4x16(Tests[i]);
glm::vec4 v0 = glm::unpackHalf4x16(p0); glm::vec4 v0 = glm::unpackHalf4x16(p0);
glm::uint64 p1 = glm::packHalf4x16(v0); glm::uint64 p1 = glm::packHalf4x16(v0);
glm::vec4 v1 = glm::unpackHalf4x16(p0); glm::vec4 v1 = glm::unpackHalf4x16(p0);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
} }
return Error; return Error;
} }
int test_I3x10_1x2() int test_I3x10_1x2()
{ {
int Error = 0; int Error = 0;
std::vector<glm::ivec4> Tests; std::vector<glm::ivec4> Tests;
Tests.push_back(glm::ivec4(0)); Tests.push_back(glm::ivec4(0));
Tests.push_back(glm::ivec4(1)); Tests.push_back(glm::ivec4(1));
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(-2)); Tests.push_back(glm::ivec4(-2));
Tests.push_back(glm::ivec4(3)); Tests.push_back(glm::ivec4(3));
for(std::size_t i = 0; i < Tests.size(); ++i) for(std::size_t i = 0; i < Tests.size(); ++i)
{ {
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]); glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]);
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0); glm::ivec4 v0 = glm::unpackI3x10_1x2(p0);
glm::uint32 p1 = glm::packI3x10_1x2(v0); glm::uint32 p1 = glm::packI3x10_1x2(v0);
glm::ivec4 v1 = glm::unpackI3x10_1x2(p0); glm::ivec4 v1 = glm::unpackI3x10_1x2(p0);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
} }
return Error; return Error;
} }
int test_U3x10_1x2() int test_U3x10_1x2()
{ {
int Error = 0; int Error = 0;
std::vector<glm::uvec4> Tests; std::vector<glm::uvec4> Tests;
Tests.push_back(glm::uvec4(0)); Tests.push_back(glm::uvec4(0));
Tests.push_back(glm::uvec4(1)); Tests.push_back(glm::uvec4(1));
Tests.push_back(glm::uvec4(2)); Tests.push_back(glm::uvec4(2));
Tests.push_back(glm::uvec4(3)); Tests.push_back(glm::uvec4(3));
Tests.push_back(glm::uvec4(4)); Tests.push_back(glm::uvec4(4));
Tests.push_back(glm::uvec4(5)); Tests.push_back(glm::uvec4(5));
for(std::size_t i = 0; i < Tests.size(); ++i) for(std::size_t i = 0; i < Tests.size(); ++i)
{ {
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]); glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]);
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0); glm::uvec4 v0 = glm::unpackU3x10_1x2(p0);
glm::uint32 p1 = glm::packU3x10_1x2(v0); glm::uint32 p1 = glm::packU3x10_1x2(v0);
glm::uvec4 v1 = glm::unpackU3x10_1x2(p0); glm::uvec4 v1 = glm::unpackU3x10_1x2(p0);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
} }
return Error; return Error;
} }
int test_Snorm3x10_1x2() int test_Snorm3x10_1x2()
{ {
int Error = 0; int Error = 0;
std::vector<glm::vec4> Tests; std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0)); Tests.push_back(glm::vec4(1.0));
Tests.push_back(glm::vec4(0.0)); Tests.push_back(glm::vec4(0.0));
Tests.push_back(glm::vec4(2.0)); Tests.push_back(glm::vec4(2.0));
Tests.push_back(glm::vec4(0.1)); Tests.push_back(glm::vec4(0.1));
Tests.push_back(glm::vec4(0.5)); Tests.push_back(glm::vec4(0.5));
Tests.push_back(glm::vec4(0.9)); Tests.push_back(glm::vec4(0.9));
for(std::size_t i = 0; i < Tests.size(); ++i) for(std::size_t i = 0; i < Tests.size(); ++i)
{ {
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]); glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0); glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0); glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0); glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
} }
return Error; return Error;
} }
int test_Unorm3x10_1x2() int test_Unorm3x10_1x2()
{ {
int Error = 0; int Error = 0;
std::vector<glm::vec4> Tests; std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0)); Tests.push_back(glm::vec4(1.0));
Tests.push_back(glm::vec4(0.0)); Tests.push_back(glm::vec4(0.0));
Tests.push_back(glm::vec4(2.0)); Tests.push_back(glm::vec4(2.0));
Tests.push_back(glm::vec4(0.1)); Tests.push_back(glm::vec4(0.1));
Tests.push_back(glm::vec4(0.5)); Tests.push_back(glm::vec4(0.5));
Tests.push_back(glm::vec4(0.9)); Tests.push_back(glm::vec4(0.9));
for(std::size_t i = 0; i < Tests.size(); ++i) for(std::size_t i = 0; i < Tests.size(); ++i)
{ {
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]); glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0); glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0); glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0); glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
} }
return Error; return Error;
} }
int test_F2x11_1x10() int test_F2x11_1x10()
{ {
int Error = 0; int Error = 0;
std::vector<glm::vec3> Tests; std::vector<glm::vec3> Tests;
Tests.push_back(glm::vec3(1.0)); Tests.push_back(glm::vec3(1.0));
Tests.push_back(glm::vec3(0.0)); Tests.push_back(glm::vec3(0.0));
Tests.push_back(glm::vec3(2.0)); Tests.push_back(glm::vec3(2.0));
Tests.push_back(glm::vec3(0.1)); Tests.push_back(glm::vec3(0.1));
Tests.push_back(glm::vec3(0.5)); Tests.push_back(glm::vec3(0.5));
Tests.push_back(glm::vec3(0.9)); Tests.push_back(glm::vec3(0.9));
for(std::size_t i = 0; i < Tests.size(); ++i) for(std::size_t i = 0; i < Tests.size(); ++i)
{ {
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]); glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]);
glm::vec3 v0 = glm::unpackF2x11_1x10(p0); glm::vec3 v0 = glm::unpackF2x11_1x10(p0);
glm::uint32 p1 = glm::packF2x11_1x10(v0); glm::uint32 p1 = glm::packF2x11_1x10(v0);
glm::vec3 v1 = glm::unpackF2x11_1x10(p0); glm::vec3 v1 = glm::unpackF2x11_1x10(p0);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
} }
return Error; return Error;
} }
int main() int main()
{ {
int Error(0); int Error(0);
Error += test_F2x11_1x10(); Error += test_F2x11_1x10();
Error += test_Snorm3x10_1x2(); Error += test_Snorm3x10_1x2();
Error += test_Unorm3x10_1x2(); Error += test_Unorm3x10_1x2();
Error += test_I3x10_1x2(); Error += test_I3x10_1x2();
Error += test_U3x10_1x2(); Error += test_U3x10_1x2();
Error += test_Half1x16(); Error += test_Half1x16();
Error += test_U3x10_1x2(); Error += test_U3x10_1x2();
return Error; return Error;
} }

@ -836,12 +836,31 @@ static int test_quat_precision()
return Error; 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 main()
{ {
int Error(0); int Error(0);
Error += test_scalar_size(); Error += test_scalar_size();
Error += test_fvec_size(); Error += test_fvec_size();
Error += test_fvec_precision(); Error += test_fvec_precision();
Error += test_fvec_conversion();
Error += test_dvec_precision(); Error += test_dvec_precision();
Error += test_ivec_size(); Error += test_ivec_size();
Error += test_ivec_precision(); Error += test_ivec_precision();

Loading…
Cancel
Save