mirror of
https://github.com/icaven/glm.git
synced 2025-12-13 15:09:59 +08:00
- specializes for 1, 2, 3 and 4-dimensional vector types which are then aliased as tvec1, tvec2, tvec3 and tvec4 - requires C++11 aliases; breaks compatability with C++03 - tested on: - clang-3.5.2, clang-3.8.0 - gcc 4.8.5, gcc 5.4.1, gcc 6.2.0 TODO: - still uses template template parameters - most can probably be removed - some definitions might now be de-duplicated
59 lines
1.9 KiB
C++
59 lines
1.9 KiB
C++
/// @ref gtx_wrap
|
|
/// @file glm/gtx/wrap.inl
|
|
|
|
namespace glm
|
|
{
|
|
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
|
|
GLM_FUNC_QUALIFIER vecType<D, T, P> clamp(vecType<D, T, P> const& Texcoord)
|
|
{
|
|
return glm::clamp(Texcoord, vecType<D, T, P>(0), vecType<D, T, P>(1));
|
|
}
|
|
|
|
template <typename genType>
|
|
GLM_FUNC_QUALIFIER genType clamp(genType const & Texcoord)
|
|
{
|
|
return clamp(tvec1<genType, defaultp>(Texcoord)).x;
|
|
}
|
|
|
|
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
|
|
GLM_FUNC_QUALIFIER vecType<D, T, P> repeat(vecType<D, T, P> const& Texcoord)
|
|
{
|
|
return glm::fract(Texcoord);
|
|
}
|
|
|
|
template <typename genType>
|
|
GLM_FUNC_QUALIFIER genType repeat(genType const & Texcoord)
|
|
{
|
|
return repeat(tvec1<genType, defaultp>(Texcoord)).x;
|
|
}
|
|
|
|
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
|
|
GLM_FUNC_QUALIFIER vecType<D, T, P> mirrorClamp(vecType<D, T, P> const& Texcoord)
|
|
{
|
|
return glm::fract(glm::abs(Texcoord));
|
|
}
|
|
|
|
template <typename genType>
|
|
GLM_FUNC_QUALIFIER genType mirrorClamp(genType const & Texcoord)
|
|
{
|
|
return mirrorClamp(tvec1<genType, defaultp>(Texcoord)).x;
|
|
}
|
|
|
|
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
|
|
GLM_FUNC_QUALIFIER vecType<D, T, P> mirrorRepeat(vecType<D, T, P> const& Texcoord)
|
|
{
|
|
vecType<D, T, P> const Abs = glm::abs(Texcoord);
|
|
vecType<D, T, P> const Clamp = glm::mod(glm::floor(Abs), vecType<D, T, P>(2));
|
|
vecType<D, T, P> const Floor = glm::floor(Abs);
|
|
vecType<D, T, P> const Rest = Abs - Floor;
|
|
vecType<D, T, P> const Mirror = Clamp + Rest;
|
|
return mix(Rest, vecType<D, T, P>(1) - Rest, glm::greaterThanEqual(Mirror, vecType<D, T, P>(1)));
|
|
}
|
|
|
|
template <typename genType>
|
|
GLM_FUNC_QUALIFIER genType mirrorRepeat(genType const& Texcoord)
|
|
{
|
|
return mirrorRepeat(tvec1<genType, defaultp>(Texcoord)).x;
|
|
}
|
|
}//namespace glm
|