| 1 | /// @ref gtx_wrap |
| 2 | |
| 3 | namespace glm |
| 4 | { |
| 5 | template<length_t L, typename T, qualifier Q> |
| 6 | GLM_FUNC_QUALIFIER vec<L, T, Q> clamp(vec<L, T, Q> const& Texcoord) |
| 7 | { |
| 8 | return glm::clamp(Texcoord, vec<L, T, Q>(0), vec<L, T, Q>(1)); |
| 9 | } |
| 10 | |
| 11 | template<typename genType> |
| 12 | GLM_FUNC_QUALIFIER genType clamp(genType const& Texcoord) |
| 13 | { |
| 14 | return clamp(vec<1, genType, defaultp>(Texcoord)).x; |
| 15 | } |
| 16 | |
| 17 | template<length_t L, typename T, qualifier Q> |
| 18 | GLM_FUNC_QUALIFIER vec<L, T, Q> repeat(vec<L, T, Q> const& Texcoord) |
| 19 | { |
| 20 | return glm::fract(Texcoord); |
| 21 | } |
| 22 | |
| 23 | template<typename genType> |
| 24 | GLM_FUNC_QUALIFIER genType repeat(genType const& Texcoord) |
| 25 | { |
| 26 | return repeat(vec<1, genType, defaultp>(Texcoord)).x; |
| 27 | } |
| 28 | |
| 29 | template<length_t L, typename T, qualifier Q> |
| 30 | GLM_FUNC_QUALIFIER vec<L, T, Q> mirrorClamp(vec<L, T, Q> const& Texcoord) |
| 31 | { |
| 32 | return glm::fract(glm::abs(Texcoord)); |
| 33 | } |
| 34 | |
| 35 | template<typename genType> |
| 36 | GLM_FUNC_QUALIFIER genType mirrorClamp(genType const& Texcoord) |
| 37 | { |
| 38 | return mirrorClamp(vec<1, genType, defaultp>(Texcoord)).x; |
| 39 | } |
| 40 | |
| 41 | template<length_t L, typename T, qualifier Q> |
| 42 | GLM_FUNC_QUALIFIER vec<L, T, Q> mirrorRepeat(vec<L, T, Q> const& Texcoord) |
| 43 | { |
| 44 | vec<L, T, Q> const Abs = glm::abs(Texcoord); |
| 45 | vec<L, T, Q> const Clamp = glm::mod(glm::floor(Abs), vec<L, T, Q>(2)); |
| 46 | vec<L, T, Q> const Floor = glm::floor(Abs); |
| 47 | vec<L, T, Q> const Rest = Abs - Floor; |
| 48 | vec<L, T, Q> const Mirror = Clamp + Rest; |
| 49 | return mix(Rest, vec<L, T, Q>(1) - Rest, glm::greaterThanEqual(Mirror, vec<L, T, Q>(1))); |
| 50 | } |
| 51 | |
| 52 | template<typename genType> |
| 53 | GLM_FUNC_QUALIFIER genType mirrorRepeat(genType const& Texcoord) |
| 54 | { |
| 55 | return mirrorRepeat(vec<1, genType, defaultp>(Texcoord)).x; |
| 56 | } |
| 57 | }//namespace glm |