mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 10:14:35 +00:00
More use of initializer lists
This commit is contained in:
parent
3308b75836
commit
e48c5ae892
@ -35,7 +35,6 @@ namespace glm
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 2, T, Q> const& m) GLM_DEFAULT;
|
||||
template<qualifier P>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 2, T, P> const& m);
|
||||
|
||||
|
@ -10,28 +10,22 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0), col_type(0, 1)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0);
|
||||
this->value[1] = col_type(0, 1);
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat(mat<2, 2, T, Q> const& m)
|
||||
{
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 2, T, Q>::mat(mat<2, 2, T, P> const& m)
|
||||
# if GLM_HAS_INITIALIZER_LISTS
|
||||
: value{m.value[0], m.value[1]}
|
||||
: value{m[0], m[1]}
|
||||
# endif
|
||||
{
|
||||
# if !GLM_HAS_INITIALIZER_LISTS
|
||||
|
@ -36,7 +36,6 @@ namespace glm
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 3, T, Q> const& m) GLM_DEFAULT;
|
||||
template<qualifier P>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 mat(mat<2, 3, T, P> const& m);
|
||||
|
||||
|
@ -8,29 +8,28 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0, 0), col_type(0, 1, 0)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0);
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat(mat<2, 3, T, Q> const& m)
|
||||
{
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 3, T, Q>::mat(mat<2, 3, T, P> const& m)
|
||||
# if GLM_HAS_INITIALIZER_LISTS
|
||||
: value{m.value[0], m.value[1]}
|
||||
# endif
|
||||
{
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
# if !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
# endif
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
|
@ -8,23 +8,17 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0, 0);
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat(mat<2, 4, T, Q> const& m)
|
||||
{
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<2, 4, T, Q>::mat(mat<2, 4, T, P> const& m)
|
||||
|
@ -8,8 +8,11 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0), col_type(0, 1), col_type(0, 0)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0);
|
||||
this->value[1] = col_type(0, 1);
|
||||
this->value[2] = col_type(0, 0);
|
||||
@ -17,16 +20,6 @@ namespace glm
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat(mat<3, 2, T, Q> const& m)
|
||||
{
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
this->value[2] = m.value[2];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 2, T, Q>::mat(mat<3, 2, T, P> const& m)
|
||||
|
@ -10,8 +10,11 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0, 0), col_type(0, 1, 0), col_type(0, 0, 1)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0);
|
||||
this->value[2] = col_type(0, 0, 1);
|
||||
@ -19,16 +22,6 @@ namespace glm
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat(mat<3, 3, T, Q> const& m)
|
||||
{
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
this->value[2] = m.value[2];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 3, T, Q>::mat(mat<3, 3, T, P> const& m)
|
||||
|
@ -8,8 +8,11 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0, 0);
|
||||
this->value[2] = col_type(0, 0, 1, 0);
|
||||
@ -17,16 +20,6 @@ namespace glm
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat(mat<3, 4, T, Q> const& m)
|
||||
{
|
||||
this->value[0] = m.value[0];
|
||||
this->value[1] = m.value[1];
|
||||
this->value[2] = m.value[2];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<3, 4, T, Q>::mat(mat<3, 4, T, P> const& m)
|
||||
|
@ -8,8 +8,11 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0), col_type(0, 1), col_type(0, 0), col_type(0, 0)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0);
|
||||
this->value[1] = col_type(0, 1);
|
||||
this->value[2] = col_type(0, 0);
|
||||
@ -18,17 +21,6 @@ namespace glm
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat(mat<4, 2, 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];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 2, T, Q>::mat(mat<4, 2, T, P> const& m)
|
||||
|
@ -8,8 +8,11 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0, 0), col_type(0, 1, 0), col_type(0, 0, 1), col_type(0, 0, 0)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0);
|
||||
this->value[2] = col_type(0, 0, 1);
|
||||
@ -18,17 +21,6 @@ namespace glm
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat(mat<4, 3, 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];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 3, T, Q>::mat(mat<4, 3, T, P> const& m)
|
||||
|
@ -10,8 +10,11 @@ namespace glm
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || defined(GLM_FORCE_CTOR_INIT)
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat()
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
|
||||
: value{col_type(1, 0, 0, 0), col_type(0, 1, 0, 0), col_type(0, 0, 1, 0), col_type(0, 0, 0, 1)}
|
||||
# endif
|
||||
{
|
||||
# ifdef GLM_FORCE_CTOR_INIT
|
||||
# if defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
|
||||
this->value[0] = col_type(1, 0, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0, 0);
|
||||
this->value[2] = col_type(0, 0, 1, 0);
|
||||
@ -20,17 +23,6 @@ namespace glm
|
||||
}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat(mat<4, 4, T, Q> const& m)
|
||||
{
|
||||
this->value[0] = m[0];
|
||||
this->value[1] = m[1];
|
||||
this->value[2] = m[2];
|
||||
this->value[3] = m[3];
|
||||
}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
template<qualifier P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CXX14 mat<4, 4, T, Q>::mat(mat<4, 4, T, P> const& m)
|
||||
|
@ -57,11 +57,20 @@ int test_inverse()
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::mediump_mat2x2 const A(1.0f);
|
||||
glm::highp_mat2x2 const B(A);
|
||||
glm::mediump_mat2x2 const C(B);
|
||||
|
||||
for(glm::length_t i = 0; i < A.length(); ++i)
|
||||
Error += glm::all(glm::equal(A[i], C[i])) ? 0 : 1;
|
||||
}
|
||||
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
glm::mat2x2 m0(
|
||||
glm::vec2(0, 1),
|
||||
glm::vec2(0, 1),
|
||||
glm::vec2(2, 3));
|
||||
|
||||
glm::mat2x2 m1{0, 1, 2, 3};
|
||||
|
Loading…
Reference in New Issue
Block a user