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