- Main Page
- Related Pages
- Modules
- Files

- File List

type_vec2.hpp
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef glm_core_type_gentype2
30 #define glm_core_type_gentype2
31
32 #include "type_vec.hpp"
33 #include "type_float.hpp"
34 #include "type_int.hpp"
35 #include "type_size.hpp"
36 #include "_swizzle.hpp"
37
38 namespace glm{
39 namespace detail
40 {
41 template <typename T> struct tref2;
42 template <typename T> struct tref3;
43 template <typename T> struct tref4;
44 template <typename T> struct tvec3;
45 template <typename T> struct tvec4;
46
47 template <typename T>
48 struct tvec2
49 {
50 enum ctor{null};
51
52 typedef T value_type;
53 typedef std::size_t size_type;
54 typedef tvec2<T> type;
55 typedef tvec2<bool> bool_type;
56
57 GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
58
60 // Data
61
62 # if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
63 union
64 {
65 # if(defined(GLM_SWIZZLE))
66 _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y)
67 _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g)
68 _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t)
69 _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y)
70 _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g)
71 _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t)
72 _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y)
73 _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g)
74 _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t)
75 # endif//(defined(GLM_SWIZZLE))
76
77 struct{value_type r, g;};
78 struct{value_type s, t;};
79 struct{value_type x, y;};
80 };
81 # elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
82 union {value_type x, r, s;};
83 union {value_type y, g, t;};
84
85 # if(defined(GLM_SWIZZLE))
86 // Defines all he swizzle operator as functions
87 GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2)
88 GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
89 # endif//(defined(GLM_SWIZZLE))
90 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
91 value_type x, y;
92
93 # if(defined(GLM_SWIZZLE))
94 // Defines all he swizzle operator as functions
95 GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(value_type, detail::tvec2, detail::tref2, x, y)
96 GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4, x, y)
97 # endif//(defined(GLM_SWIZZLE))
98 # endif//GLM_COMPONENT
99
101 // Accesses
102
103 GLM_FUNC_DECL value_type & operator[](size_type i);
104 GLM_FUNC_DECL value_type const & operator[](size_type i) const;
105
107 // Implicit basic constructors
108
109 GLM_FUNC_DECL tvec2();
110 GLM_FUNC_DECL tvec2(tvec2<T> const & v);
111
113 // Explicit basic constructors
114
115 GLM_FUNC_DECL explicit tvec2(
116 ctor);
117 GLM_FUNC_DECL explicit tvec2(
118 value_type const & s);
119 GLM_FUNC_DECL explicit tvec2(
120 value_type const & s1,
121 value_type const & s2);
122
124 // Swizzle constructors
125
126 tvec2(tref2<T> const & r);
127
128 template <int E0, int E1>
129 GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2<T>,E0,E1,-1,-2>& that)
130 {
131 *this = that();
132 }
133
135 // Convertion constructors
136
138 template <typename U>
139 GLM_FUNC_DECL explicit tvec2(
140 U const & x);
142 template <typename U, typename V>
143 GLM_FUNC_DECL explicit tvec2(
144 U const & x,
145 V const & y);
146
148 // Convertion vector constructors
149
151 template <typename U>
152 GLM_FUNC_DECL explicit tvec2(tvec2<U> const & v);
154 template <typename U>
155 GLM_FUNC_DECL explicit tvec2(tvec3<U> const & v);
157 template <typename U>
158 GLM_FUNC_DECL explicit tvec2(tvec4<U> const & v);
159
161 // Unary arithmetic operators
162
163 GLM_FUNC_DECL tvec2<T> & operator= (tvec2<T> const & v);
164 template <typename U>
165 GLM_FUNC_DECL tvec2<T> & operator= (tvec2<U> const & v);
166
167 template <typename U>
168 GLM_FUNC_DECL tvec2<T> & operator+=(U const & s);
169 template <typename U>
170 GLM_FUNC_DECL tvec2<T> & operator+=(tvec2<U> const & v);
171 template <typename U>
172 GLM_FUNC_DECL tvec2<T> & operator-=(U const & s);
173 template <typename U>
174 GLM_FUNC_DECL tvec2<T> & operator-=(tvec2<U> const & v);
175 template <typename U>
176 GLM_FUNC_DECL tvec2<T> & operator*=(U const & s);
177 template <typename U>
178 GLM_FUNC_DECL tvec2<T> & operator*=(tvec2<U> const & v);
179 template <typename U>
180 GLM_FUNC_DECL tvec2<T> & operator/=(U const & s);
181 template <typename U>
182 GLM_FUNC_DECL tvec2<T> & operator/=(tvec2<U> const & v);
183 GLM_FUNC_DECL tvec2<T> & operator++();
184 GLM_FUNC_DECL tvec2<T> & operator--();
185
187 // Unary bit operators
188
189 template <typename U>
190 GLM_FUNC_DECL tvec2<T> & operator%= (U const & s);
191 template <typename U>
192 GLM_FUNC_DECL tvec2<T> & operator%= (tvec2<U> const & v);
193 template <typename U>
194 GLM_FUNC_DECL tvec2<T> & operator&= (U const & s);
195 template <typename U>
196 GLM_FUNC_DECL tvec2<T> & operator&= (tvec2<U> const & v);
197 template <typename U>
198 GLM_FUNC_DECL tvec2<T> & operator|= (U const & s);
199 template <typename U>
200 GLM_FUNC_DECL tvec2<T> & operator|= (tvec2<U> const & v);
201 template <typename U>
202 GLM_FUNC_DECL tvec2<T> & operator^= (U const & s);
203 template <typename U>
204 GLM_FUNC_DECL tvec2<T> & operator^= (tvec2<U> const & v);
205 template <typename U>
206 GLM_FUNC_DECL tvec2<T> & operator<<=(U const & s);
207 template <typename U>
208 GLM_FUNC_DECL tvec2<T> & operator<<=(tvec2<U> const & v);
209 template <typename U>
210 GLM_FUNC_DECL tvec2<T> & operator>>=(U const & s);
211 template <typename U>
212 GLM_FUNC_DECL tvec2<T> & operator>>=(tvec2<U> const & v);
213
215 // Swizzle operators
216
217 GLM_FUNC_DECL value_type swizzle(comp X) const;
218 GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
219 GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
220 GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
221 GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
222 };
223
224 template <typename T>
225 struct tref2
226 {
227 GLM_FUNC_DECL tref2(T & x, T & y);
228 GLM_FUNC_DECL tref2(tref2<T> const & r);
229 GLM_FUNC_DECL explicit tref2(tvec2<T> const & v);
230
231 GLM_FUNC_DECL tref2<T> & operator= (tref2<T> const & r);
232 GLM_FUNC_DECL tref2<T> & operator= (tvec2<T> const & v);
233
234 GLM_FUNC_DECL tvec2<T> operator() ();
235
236 T & x;
237 T & y;
238 };
239
240 GLM_DETAIL_IS_VECTOR(tvec2);
241
242 } //namespace detail
243
246
252 typedef detail::tvec2<highp_float> highp_vec2;
253
259 typedef detail::tvec2<mediump_float> mediump_vec2;
260
266 typedef detail::tvec2<lowp_float> lowp_vec2;
267
273 typedef detail::tvec2<highp_int> highp_ivec2;
274
280 typedef detail::tvec2<mediump_int> mediump_ivec2;
281
287 typedef detail::tvec2<lowp_int> lowp_ivec2;
288
294 typedef detail::tvec2<highp_uint> highp_uvec2;
295
301 typedef detail::tvec2<mediump_uint> mediump_uvec2;
302
308 typedef detail::tvec2<lowp_uint> lowp_uvec2;
309
311 }//namespace glm
312
313 #ifndef GLM_EXTERNAL_TEMPLATE
314 #include "type_vec2.inl"
315 #endif//GLM_EXTERNAL_TEMPLATE
316
317 #endif//glm_core_type_gentype2