~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/gtx/wrap.inl

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////////////////////////////
2
 
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3
 
///////////////////////////////////////////////////////////////////////////////////////////////////
4
 
// Created : 2009-11-25
5
 
// Updated : 2010-02-13
6
 
// Licence : This source is under MIT License
7
 
// File    : glm/gtx/wrap.inl
8
 
///////////////////////////////////////////////////////////////////////////////////////////////////
9
 
// Dependency:
10
 
// - GLM core
11
 
///////////////////////////////////////////////////////////////////////////////////////////////////
12
 
 
13
 
namespace glm
14
 
{
15
 
        template <typename genType> 
16
 
        GLM_FUNC_QUALIFIER genType clamp
17
 
        (
18
 
                genType const & Texcoord
19
 
        )
20
 
        {
21
 
                return glm::clamp(Texcoord, genType(0), genType(1));
22
 
        }
23
 
 
24
 
        template <typename T> 
25
 
        GLM_FUNC_QUALIFIER detail::tvec2<T> clamp
26
 
        (
27
 
                detail::tvec2<T> const & Texcoord
28
 
        )
29
 
        {
30
 
                detail::tvec2<T> Result;
31
 
                for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
32
 
                        Result[i] = clamp(Texcoord[i]);
33
 
                return Result;
34
 
        }
35
 
 
36
 
        template <typename T> 
37
 
        GLM_FUNC_QUALIFIER detail::tvec3<T> clamp
38
 
        (
39
 
                detail::tvec3<T> const & Texcoord
40
 
        )
41
 
        {
42
 
                detail::tvec3<T> Result;
43
 
                for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
44
 
                        Result[i] = clamp(Texcoord[i]);
45
 
                return Result;
46
 
        }
47
 
 
48
 
        template <typename T> 
49
 
        GLM_FUNC_QUALIFIER detail::tvec4<T> clamp
50
 
        (
51
 
                detail::tvec4<T> const & Texcoord
52
 
        )
53
 
        {
54
 
                detail::tvec4<T> Result;
55
 
                for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
56
 
                        Result[i] = clamp(Texcoord[i]);
57
 
                return Result;
58
 
        }
59
 
 
60
 
        ////////////////////////
61
 
        // repeat
62
 
 
63
 
        template <typename genType> 
64
 
        GLM_FUNC_QUALIFIER genType repeat
65
 
        (
66
 
                genType const & Texcoord
67
 
        )
68
 
        {
69
 
                return glm::fract(Texcoord);
70
 
        }
71
 
 
72
 
        template <typename T> 
73
 
        GLM_FUNC_QUALIFIER detail::tvec2<T> repeat
74
 
        (
75
 
                detail::tvec2<T> const & Texcoord
76
 
        )
77
 
        {
78
 
                detail::tvec2<T> Result;
79
 
                for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
80
 
                        Result[i] = repeat(Texcoord[i]);
81
 
                return Result;
82
 
        }
83
 
 
84
 
        template <typename T> 
85
 
        GLM_FUNC_QUALIFIER detail::tvec3<T> repeat
86
 
        (
87
 
                detail::tvec3<T> const & Texcoord
88
 
        )
89
 
        {
90
 
                detail::tvec3<T> Result;
91
 
                for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
92
 
                        Result[i] = repeat(Texcoord[i]);
93
 
                return Result;
94
 
        }
95
 
 
96
 
        template <typename T> 
97
 
        GLM_FUNC_QUALIFIER detail::tvec4<T> repeat
98
 
        (
99
 
                detail::tvec4<T> const & Texcoord
100
 
        )
101
 
        {
102
 
                detail::tvec4<T> Result;
103
 
                for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
104
 
                        Result[i] = repeat(Texcoord[i]);
105
 
                return Result;
106
 
        }
107
 
 
108
 
        ////////////////////////
109
 
        // mirrorRepeat
110
 
 
111
 
        template <typename genType> 
112
 
        GLM_FUNC_QUALIFIER genType mirrorRepeat
113
 
        (
114
 
                genType const & Texcoord
115
 
        )
116
 
        {
117
 
                genType const Clamp = genType(int(glm::floor(Texcoord)) % 2);
118
 
                genType const Floor = glm::floor(Texcoord);
119
 
                genType const Rest = Texcoord - Floor;
120
 
                genType const Mirror = Clamp + Rest;
121
 
 
122
 
                genType Out;
123
 
                if(Mirror >= genType(1))
124
 
                        Out = genType(1) - Rest;
125
 
                else
126
 
                        Out = Rest;
127
 
                return Out;
128
 
        }
129
 
 
130
 
        template <typename T> 
131
 
        GLM_FUNC_QUALIFIER detail::tvec2<T> mirrorRepeat
132
 
        (
133
 
                detail::tvec2<T> const & Texcoord
134
 
        )
135
 
        {
136
 
                detail::tvec2<T> Result;
137
 
                for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i)
138
 
                        Result[i] = mirrorRepeat(Texcoord[i]);
139
 
                return Result;
140
 
        }
141
 
 
142
 
        template <typename T> 
143
 
        GLM_FUNC_QUALIFIER detail::tvec3<T> mirrorRepeat
144
 
        (
145
 
                detail::tvec3<T> const & Texcoord
146
 
        )
147
 
        {
148
 
                detail::tvec3<T> Result;
149
 
                for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i)
150
 
                        Result[i] = mirrorRepeat(Texcoord[i]);
151
 
                return Result;
152
 
        }
153
 
 
154
 
        template <typename T> 
155
 
        GLM_FUNC_QUALIFIER detail::tvec4<T> mirrorRepeat
156
 
        (
157
 
                detail::tvec4<T> const & Texcoord
158
 
        )
159
 
        {
160
 
                detail::tvec4<T> Result;
161
 
                for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i)
162
 
                        Result[i] = mirrorRepeat(Texcoord[i]);
163
 
                return Result;
164
 
        }
165
 
}//namespace glm