2014-11-25 23:27:12 +00:00
|
|
|
/// @ref gtx_wrap
|
|
|
|
/// @file glm/gtx/wrap.inl
|
2010-04-29 10:54:07 +00:00
|
|
|
|
2011-10-14 13:07:53 +00:00
|
|
|
namespace glm
|
2010-04-29 10:54:07 +00:00
|
|
|
{
|
2017-08-15 23:22:50 +00:00
|
|
|
template<length_t L, typename T, qualifier Q>
|
|
|
|
GLM_FUNC_QUALIFIER vec<L, T, Q> clamp(vec<L, T, Q> const& Texcoord)
|
2011-10-14 13:07:53 +00:00
|
|
|
{
|
2017-08-15 23:22:50 +00:00
|
|
|
return glm::clamp(Texcoord, vec<L, T, Q>(0), vec<L, T, Q>(1));
|
2011-10-14 13:07:53 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename genType>
|
2017-08-15 20:04:24 +00:00
|
|
|
GLM_FUNC_QUALIFIER genType clamp(genType const& Texcoord)
|
2011-10-14 13:07:53 +00:00
|
|
|
{
|
2016-12-30 00:23:29 +00:00
|
|
|
return clamp(vec<1, genType, defaultp>(Texcoord)).x;
|
2011-10-14 13:07:53 +00:00
|
|
|
}
|
|
|
|
|
2017-08-15 23:22:50 +00:00
|
|
|
template<length_t L, typename T, qualifier Q>
|
|
|
|
GLM_FUNC_QUALIFIER vec<L, T, Q> repeat(vec<L, T, Q> const& Texcoord)
|
2011-10-14 13:07:53 +00:00
|
|
|
{
|
2016-08-06 17:28:16 +00:00
|
|
|
return glm::fract(Texcoord);
|
2011-10-14 13:07:53 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename genType>
|
2017-08-15 20:04:24 +00:00
|
|
|
GLM_FUNC_QUALIFIER genType repeat(genType const& Texcoord)
|
2011-10-14 13:07:53 +00:00
|
|
|
{
|
2016-12-30 00:23:29 +00:00
|
|
|
return repeat(vec<1, genType, defaultp>(Texcoord)).x;
|
2011-10-14 13:07:53 +00:00
|
|
|
}
|
|
|
|
|
2017-08-15 23:22:50 +00:00
|
|
|
template<length_t L, typename T, qualifier Q>
|
|
|
|
GLM_FUNC_QUALIFIER vec<L, T, Q> mirrorClamp(vec<L, T, Q> const& Texcoord)
|
2011-10-14 13:07:53 +00:00
|
|
|
{
|
2016-08-06 17:28:16 +00:00
|
|
|
return glm::fract(glm::abs(Texcoord));
|
2011-10-14 13:07:53 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename genType>
|
2017-08-15 20:04:24 +00:00
|
|
|
GLM_FUNC_QUALIFIER genType mirrorClamp(genType const& Texcoord)
|
2015-06-27 18:12:27 +00:00
|
|
|
{
|
2016-12-30 00:23:29 +00:00
|
|
|
return mirrorClamp(vec<1, genType, defaultp>(Texcoord)).x;
|
2015-06-27 18:12:27 +00:00
|
|
|
}
|
|
|
|
|
2017-08-15 23:22:50 +00:00
|
|
|
template<length_t L, typename T, qualifier Q>
|
|
|
|
GLM_FUNC_QUALIFIER vec<L, T, Q> mirrorRepeat(vec<L, T, Q> const& Texcoord)
|
2015-06-27 18:12:27 +00:00
|
|
|
{
|
2017-08-15 23:22:50 +00:00
|
|
|
vec<L, T, Q> const Abs = glm::abs(Texcoord);
|
|
|
|
vec<L, T, Q> const Clamp = glm::mod(glm::floor(Abs), vec<L, T, Q>(2));
|
|
|
|
vec<L, T, Q> const Floor = glm::floor(Abs);
|
|
|
|
vec<L, T, Q> const Rest = Abs - Floor;
|
|
|
|
vec<L, T, Q> const Mirror = Clamp + Rest;
|
|
|
|
return mix(Rest, vec<L, T, Q>(1) - Rest, glm::greaterThanEqual(Mirror, vec<L, T, Q>(1)));
|
2015-06-27 18:12:27 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename genType>
|
2016-08-06 17:28:16 +00:00
|
|
|
GLM_FUNC_QUALIFIER genType mirrorRepeat(genType const& Texcoord)
|
2011-10-14 13:07:53 +00:00
|
|
|
{
|
2016-12-30 00:23:29 +00:00
|
|
|
return mirrorRepeat(vec<1, genType, defaultp>(Texcoord)).x;
|
2011-10-14 13:07:53 +00:00
|
|
|
}
|
2010-04-29 10:54:07 +00:00
|
|
|
}//namespace glm
|