diff --git a/glm/core/type_mat2x2.hpp b/glm/core/type_mat2x2.hpp index 8d6a3918..7f0df2c7 100644 --- a/glm/core/type_mat2x2.hpp +++ b/glm/core/type_mat2x2.hpp @@ -56,10 +56,12 @@ namespace glm GLM_FUNC_DECL tmat2x2 _inverse() const; private: + ////////////////////////////////////// // Data col_type value[2]; public: + ////////////////////////////////////// // Constructors GLM_FUNC_DECL tmat2x2(); GLM_FUNC_DECL tmat2x2( @@ -76,6 +78,23 @@ namespace glm col_type const & v1, col_type const & v2); + ////////////////////////////////////// + // Convertion constructors + template + GLM_FUNC_DECL explicit tmat2x2( + U const & x); + + template + GLM_FUNC_DECL explicit tmat2x2( + U const & x1, V const & y1, + M const & x2, N const & y2); + + //template + //GLM_FUNC_DECL explicit tmat2x2( + // tvec2 const & v1, + // tvec2 const & v2); + + ////////////////////////////////////// // Conversions template GLM_FUNC_DECL explicit tmat2x2(tmat2x2 const & m); diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index 7a53a969..11a3f11c 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -107,8 +107,46 @@ namespace detail this->value[1] = v1; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat2x2::tmat2x2 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec2(value_type(s), Zero); + this->value[1] = tvec2(Zero, value_type(s)); + } + + template + template + GLM_FUNC_DECL tmat2x2::tmat2x2 + ( + U const & x1, V const & y1, + M const & x2, N const & y2 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1)); + this->value[1] = col_type(value_type(x2), value_type(y2)); + } + + //template + //template + //GLM_FUNC_DECL tmat2x2::tmat2x2 + //( + // tvec2 const & v1, + // tvec2 const & v2 + //) + //{ + // this->value[0] = col_type(v1); + // this->value[1] = col_type(v2); + //} + ////////////////////////////////////////////////////////////// - // mat2 conversions + // mat2x2 conversions template template @@ -215,7 +253,7 @@ namespace detail } ////////////////////////////////////////////////////////////// - // mat3 operators + // mat2x2 operators // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared template diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index 29d641ce..afaf8f8d 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -93,7 +93,7 @@ namespace glm tvec2(tref2 const & r); ////////////////////////////////////// - // Convertion scalar constructors + // Convertion constructors //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template diff --git a/test/gtc/gtc_half_float.cpp b/test/gtc/gtc_half_float.cpp index adfe1efa..92b968b0 100644 --- a/test/gtc/gtc_half_float.cpp +++ b/test/gtc/gtc_half_float.cpp @@ -51,10 +51,38 @@ int test_half_precision_mat() return Error; } +int test_half_ctor_mat2x2() +{ + int Error = 0; + + { + glm::hvec2 A(1, 2); + glm::hvec2 B(3, 4); + glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f); + glm::hmat2 D(1, 2, 3, 4); + + Error += C[0] == D[0] ? 0 : 1; + Error += C[1] == D[1] ? 0 : 1; + } + + { + glm::hvec2 A(1, 2.0); + glm::hvec2 B(3, 4.0); + glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f); + glm::hmat2 D(1, 2.0, 3u, 4.0f); + + Error += C[0] == D[0] ? 0 : 1; + Error += C[1] == D[1] ? 0 : 1; + } + + return Error; +} + int main() { int Error = 0; + Error += test_half_ctor_mat2x2(); Error += test_half_precision_scalar(); Error += test_half_precision_vec(); Error += test_half_precision_mat();