diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 362f4896..99a701e4 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -36,6 +36,7 @@ namespace glm struct tvec4 { enum ctor{null}; + enum {_size = 4}; typedef T value_type; typedef std::size_t size_type; static size_type value_size(); diff --git a/glm/gtc/swizzle.hpp b/glm/gtc/swizzle.hpp index 7af4b4f6..a1cf29d1 100644 --- a/glm/gtc/swizzle.hpp +++ b/glm/gtc/swizzle.hpp @@ -26,9 +26,9 @@ namespace glm //! GLM_GTC_swizzle extension namespace swizzle{ - template + template class vecType> T swizzle( - detail::tvec4 const & v, + vecType const & v, comp x); template @@ -46,6 +46,21 @@ namespace glm detail::tvec4 const & v, comp x, comp y, comp z, comp w); + template + T& swizzle( + detail::tvec4 & v, + comp x); + + template + detail::tref2 swizzle( + detail::tvec4 & v, + comp x, comp y); + + template + detail::tref3 swizzle( + detail::tvec4 & v, + comp x, comp y, comp z); + template detail::tref4 swizzle( detail::tvec4 & v, diff --git a/glm/gtc/swizzle.inl b/glm/gtc/swizzle.inl index 79519df1..a1e7a61b 100644 --- a/glm/gtc/swizzle.inl +++ b/glm/gtc/swizzle.inl @@ -2,13 +2,14 @@ namespace glm{ namespace gtc{ namespace swizzle { - template + template class vecType> inline T swizzle ( - detail::tvec4 const & v, + vecType const & v, comp x ) { + assert(int(x) < int(typename vecType::_size)); return v[x]; }