diff --git a/glm/core/type_mat2x2.hpp b/glm/core/type_mat2x2.hpp index 4ef7dc45..54a3b152 100644 --- a/glm/core/type_mat2x2.hpp +++ b/glm/core/type_mat2x2.hpp @@ -82,6 +82,13 @@ namespace detail col_type const & v1, col_type const & v2); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat2x2(std::initializer_list m); + + GLM_FUNC_DECL tmat2x2(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index 64655c95..d6e0aaa0 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -141,6 +141,27 @@ namespace detail this->value[1] = v1; } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat2x2::tmat2x2(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec2(*(p + 0), *(p + 1)); + this->value[1] = tvec2(*(p + 2), *(p + 3)); + } + + template + GLM_FUNC_QUALIFIER tmat2x2::tmat2x2(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversion constructors template diff --git a/glm/core/type_mat2x3.hpp b/glm/core/type_mat2x3.hpp index 0acd7a41..169abbd7 100644 --- a/glm/core/type_mat2x3.hpp +++ b/glm/core/type_mat2x3.hpp @@ -76,6 +76,13 @@ namespace detail col_type const & v0, col_type const & v1); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat2x3(std::initializer_list m); + + GLM_FUNC_DECL tmat2x3(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat2x3.inl b/glm/core/type_mat2x3.inl index 56b441df..a44ff503 100644 --- a/glm/core/type_mat2x3.inl +++ b/glm/core/type_mat2x3.inl @@ -140,6 +140,27 @@ namespace detail this->value[1] = v1; } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat2x3::tmat2x3(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec3(*(p + 0), *(p + 1), *(p + 2)); + this->value[1] = tvec3(*(p + 3), *(p + 4), *(p + 5)); + } + + template + GLM_FUNC_QUALIFIER tmat2x3::tmat2x3(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversion constructors template diff --git a/glm/core/type_mat2x4.hpp b/glm/core/type_mat2x4.hpp index db68e435..cf2a7deb 100644 --- a/glm/core/type_mat2x4.hpp +++ b/glm/core/type_mat2x4.hpp @@ -76,6 +76,13 @@ namespace detail col_type const & v0, col_type const & v1); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat2x4(std::initializer_list m); + + GLM_FUNC_DECL tmat2x4(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat2x4.inl b/glm/core/type_mat2x4.inl index 133fceee..2c2eef18 100644 --- a/glm/core/type_mat2x4.inl +++ b/glm/core/type_mat2x4.inl @@ -143,6 +143,27 @@ namespace detail this->value[1] = v1; } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat2x4::tmat2x4(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec4(*(p + 0), *(p + 1), *(p + 2), *(p + 3)); + this->value[1] = tvec4(*(p + 4), *(p + 5), *(p + 6), *(p + 7)); + } + + template + GLM_FUNC_QUALIFIER tmat2x4::tmat2x4(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversion constructors template diff --git a/glm/core/type_mat3x2.hpp b/glm/core/type_mat3x2.hpp index 876f4bc6..697e353d 100644 --- a/glm/core/type_mat3x2.hpp +++ b/glm/core/type_mat3x2.hpp @@ -78,6 +78,13 @@ namespace detail col_type const & v1, col_type const & v2); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat3x2(std::initializer_list m); + + GLM_FUNC_DECL tmat3x2(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat3x2.inl b/glm/core/type_mat3x2.inl index 05541b48..4dd063de 100644 --- a/glm/core/type_mat3x2.inl +++ b/glm/core/type_mat3x2.inl @@ -148,6 +148,29 @@ namespace detail this->value[2] = v2; } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat3x2::tmat3x2(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec2(*(p + 0), *(p + 1)); + this->value[1] = tvec2(*(p + 2), *(p + 3)); + this->value[2] = tvec2(*(p + 4), *(p + 5)); + } + + template + GLM_FUNC_QUALIFIER tmat3x2::tmat3x2(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + this->value[2] = m.begin()[2]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversion constructors template diff --git a/glm/core/type_mat3x3.hpp b/glm/core/type_mat3x3.hpp index 4d52815b..97c52969 100644 --- a/glm/core/type_mat3x3.hpp +++ b/glm/core/type_mat3x3.hpp @@ -83,6 +83,13 @@ namespace detail col_type const & v1, col_type const & v2); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat3x3(std::initializer_list m); + + GLM_FUNC_DECL tmat3x3(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat3x3.inl b/glm/core/type_mat3x3.inl index d131ba83..e1b71954 100644 --- a/glm/core/type_mat3x3.inl +++ b/glm/core/type_mat3x3.inl @@ -151,6 +151,29 @@ namespace detail this->value[2] = v2; } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat3x3::tmat3x3(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec3(*(p + 0), *(p + 1), *(p + 2)); + this->value[1] = tvec3(*(p + 3), *(p + 4), *(p + 5)); + this->value[2] = tvec3(*(p + 6), *(p + 7), *(p + 8)); + } + + template + GLM_FUNC_QUALIFIER tmat3x3::tmat3x3(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + this->value[2] = m.begin()[2]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversion constructors template diff --git a/glm/core/type_mat3x4.hpp b/glm/core/type_mat3x4.hpp index 6f73da24..11d1e08f 100644 --- a/glm/core/type_mat3x4.hpp +++ b/glm/core/type_mat3x4.hpp @@ -78,6 +78,13 @@ namespace detail col_type const & v1, col_type const & v2); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat3x4(std::initializer_list m); + + GLM_FUNC_DECL tmat3x4(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat3x4.inl b/glm/core/type_mat3x4.inl index b5165e86..a88738f1 100644 --- a/glm/core/type_mat3x4.inl +++ b/glm/core/type_mat3x4.inl @@ -195,6 +195,29 @@ namespace detail this->value[2] = col_type(v3); } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat3x4::tmat3x4(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec4(*(p + 0), *(p + 1), *(p + 2), *(p + 3)); + this->value[1] = tvec4(*(p + 4), *(p + 5), *(p + 6), *(p + 7)); + this->value[2] = tvec4(*(p + 8), *(p + 9), *(p + 10), *(p + 11)); + } + + template + GLM_FUNC_QUALIFIER tmat3x4::tmat3x4(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + this->value[2] = m.begin()[2]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + // Conversion template template diff --git a/glm/core/type_mat4x2.hpp b/glm/core/type_mat4x2.hpp index 6cf74f2d..a90fa35f 100644 --- a/glm/core/type_mat4x2.hpp +++ b/glm/core/type_mat4x2.hpp @@ -80,6 +80,13 @@ namespace detail col_type const & v2, col_type const & v3); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat4x2(std::initializer_list m); + + GLM_FUNC_DECL tmat4x2(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat4x2.inl b/glm/core/type_mat4x2.inl index aa897dc7..3ce44c99 100644 --- a/glm/core/type_mat4x2.inl +++ b/glm/core/type_mat4x2.inl @@ -206,6 +206,32 @@ namespace detail this->value[3] = col_type(v4); } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat4x2::tmat4x2(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec2(*(p + 0), *(p + 1)); + this->value[1] = tvec2(*(p + 2), *(p + 3)); + this->value[2] = tvec2(*(p + 4), *(p + 5)); + this->value[3] = tvec2(*(p + 6), *(p + 7)); + } + + template + GLM_FUNC_QUALIFIER tmat4x2::tmat4x2(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + this->value[2] = m.begin()[2]; + this->value[3] = m.begin()[3]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + + ////////////////////////////////////// // Conversion template template diff --git a/glm/core/type_mat4x3.hpp b/glm/core/type_mat4x3.hpp index 97657245..18cc7a11 100644 --- a/glm/core/type_mat4x3.hpp +++ b/glm/core/type_mat4x3.hpp @@ -80,6 +80,13 @@ namespace detail col_type const & v2, col_type const & v3); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tmat4x3(std::initializer_list m); + + GLM_FUNC_DECL tmat4x3(std::initializer_list > m); +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversions template diff --git a/glm/core/type_mat4x3.inl b/glm/core/type_mat4x3.inl index 3de9aebe..94636ba4 100644 --- a/glm/core/type_mat4x3.inl +++ b/glm/core/type_mat4x3.inl @@ -152,6 +152,31 @@ namespace detail this->value[3] = v3; } +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tmat4x3::tmat4x3(std::initializer_list m) + { + assert(m.size() >= this->length()); + + typename std::initializer_list::iterator p = m.begin(); + + this->value[0] = tvec3(*(p + 0), *(p + 1), *(p + 2)); + this->value[1] = tvec3(*(p + 3), *(p + 4), *(p + 5)); + this->value[2] = tvec3(*(p + 6), *(p + 7), *(p + 8)); + this->value[3] = tvec3(*(p + 9), *(p + 10), *(p + 11)); + } + + template + GLM_FUNC_QUALIFIER tmat4x3::tmat4x3(std::initializer_list > m) + { + this->value[0] = m.begin()[0]; + this->value[1] = m.begin()[1]; + this->value[2] = m.begin()[2]; + this->value[3] = m.begin()[3]; + } +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////// // Conversion constructors template diff --git a/test/core/core_type_mat4x3.cpp b/test/core/core_type_mat4x3.cpp index 5a8bd09e..a806f709 100644 --- a/test/core/core_type_mat4x3.cpp +++ b/test/core/core_type_mat4x3.cpp @@ -7,7 +7,9 @@ // File : test/core/type_mat4x3.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// +#include #include +#include static int test_operators() { @@ -28,10 +30,61 @@ static int test_operators() return (S && !R) ? 0 : 1; } +int test_ctr() +{ + int Error(0); + +#if(GLM_HAS_INITIALIZER_LISTS) + glm::mat4x3 m0( + glm::vec3(0, 1, 2), + glm::vec3(3, 4, 5), + glm::vec3(6, 7, 8), + glm::vec3(9, 10, 11)); + + glm::mat4x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + + glm::mat4x3 m2{ + {0, 1, 2}, + {3, 4, 5}, + {6, 7, 8}, + {9, 10, 11}}; + + for(int i = 0; i < m0.length(); ++i) + Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1; + + for(int i = 0; i < m1.length(); ++i) + Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1; + + std::vector v1{ + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} + }; + + std::vector v2{ + { + { 0, 1, 2 }, + { 4, 5, 6 }, + { 8, 9, 10 }, + { 12, 13, 14 } + }, + { + { 0, 1, 2 }, + { 4, 5, 6 }, + { 8, 9, 10 }, + { 12, 13, 14 } + } + }; + +#endif//GLM_HAS_INITIALIZER_LISTS + + return Error; +} + int main() { int Error = 0; + Error += test_ctr(); Error += test_operators(); return Error; diff --git a/test/core/core_type_mat4x4.cpp b/test/core/core_type_mat4x4.cpp index 0e8538ab..5d3278fa 100644 --- a/test/core/core_type_mat4x4.cpp +++ b/test/core/core_type_mat4x4.cpp @@ -128,6 +128,12 @@ int test_ctr() int Error(0); #if(GLM_HAS_INITIALIZER_LISTS) + glm::mat4 m0( + glm::vec4(0, 1, 2, 3), + glm::vec4(4, 5, 6, 7), + glm::vec4(8, 9, 10, 11), + glm::vec4(12, 13, 14, 15)); + glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; glm::mat4 m2{ @@ -136,6 +142,12 @@ int test_ctr() {8, 9, 10, 11}, {12, 13, 14, 15}}; + for(int i = 0; i < m0.length(); ++i) + Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1; + + for(int i = 0; i < m1.length(); ++i) + Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1; + std::vector m3{ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},