diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 521e8ccc..762229b3 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -58,6 +58,10 @@ namespace glm static GLM_RELAXED_CONSTEXPR precision prec = P; # endif//GLM_META_PROG_HELPERS + static const type ZERO; + static const type X; + static const type Y; + static const type XY; // -- Data -- # if GLM_HAS_ANONYMOUS_UNION diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 39d0549e..db95c67a 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -28,6 +28,17 @@ namespace glm { + template + const tvec2 tvec2::ZERO = tvec2(static_cast(0), static_cast(0)); + + template + const tvec2 tvec2::X = tvec2(static_cast(1), static_cast(0)); + + template + const tvec2 tvec2::Y = tvec2(static_cast(0), static_cast(1)); + + template + const tvec2 tvec2::XY = tvec2(static_cast(1), static_cast(1)); // -- Implicit basic constructors -- # if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 69b5957e..9f2e8d14 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -331,6 +331,17 @@ int test_operator_increment() return Error; } +int test_vec2_static_const() { + int Error(0); + + Error += (glm::ivec2(0, 0) == glm::ivec2::ZERO) ? 0 : 1; + Error += (glm::vec2(1, 0) == glm::vec2::X) ? 0 : 1; + Error += (glm::bvec2(false, true) == glm::bvec2::Y) ? 0 : 1; + Error += (glm::dvec2(1, 1) == glm::dvec2::XY) ? 0 : 1; + + return Error; +} + int main() { int Error = 0; @@ -343,6 +354,7 @@ int main() assert(glm::vec2::components == 2); # endif + Error += test_vec2_static_const(); Error += test_vec2_size(); Error += test_vec2_ctor(); Error += test_vec2_operators();