Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6KB

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