- Main Page
- Related Pages
- Modules
- Files

- File List

type_vec3.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_gentype3
30 #define glm_core_type_gentype3
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 tvec2;
45 template <typename T> struct tvec4;
46
47 template <typename T>
48 struct tvec3
49 {
50 enum ctor{null};
51
52 typedef T value_type;
53 typedef std::size_t size_type;
54 typedef tvec3<T> type;
55 typedef tvec3<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_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y, z)
67 _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b)
68 _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p)
69 _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y, z)
70 _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g, b)
71 _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t, p)
72 _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z)
73 _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b)
74 _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p)
75 # endif//(defined(GLM_SWIZZLE))
76
77 struct{value_type r, g, b;};
78 struct{value_type s, t, p;};
79 struct{value_type x, y, z;};
80 };
81 # elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
82 union {value_type x, r, s;};
83 union {value_type y, g, t;};
84 union {value_type z, b, p;};
85
86 # if(defined(GLM_SWIZZLE))
87 // Defines all he swizzle operator as functions
88 GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, detail::tvec3, detail::tref2, detail::tref3)
89 GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4)
90 # endif//(defined(GLM_SWIZZLE))
91 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
92 value_type x, y, z;
93
94 # if(defined(GLM_SWIZZLE))
95 // Defines all he swizzle operator as functions
96 GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(T, detail::tvec3, detail::tref2, detail::tref3, x, y, z)
97 GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z)
98 # endif//(defined(GLM_SWIZZLE))
99 # endif//GLM_COMPONENT
100
102 // Accesses
103
104 GLM_FUNC_DECL value_type & operator[](size_type i);
105 GLM_FUNC_DECL value_type const & operator[](size_type i) const;
106
108 // Implicit basic constructors
109
110 GLM_FUNC_DECL tvec3();
111 GLM_FUNC_DECL tvec3(tvec3<T> const & v);
112
114 // Explicit basic constructors
115
116 GLM_FUNC_DECL explicit tvec3(
117 ctor);
118 GLM_FUNC_DECL explicit tvec3(
119 value_type const & s);
120 GLM_FUNC_DECL explicit tvec3(
121 value_type const & s1,
122 value_type const & s2,
123 value_type const & s3);
124
126 // Convertion scalar constructors
127
129 template <typename U>
130 GLM_FUNC_DECL explicit tvec3(
131 U const & x);
133 template <typename U, typename V, typename W>
134 GLM_FUNC_DECL explicit tvec3(
135 U const & x,
136 V const & y,
137 W const & z);
138
140 // Convertion vector constructors
141
143 template <typename A, typename B>
144 GLM_FUNC_DECL explicit tvec3(tvec2<A> const & v, B const & s);
146 template <typename A, typename B>
147 GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B> const & v);
149 template <typename U>
150 GLM_FUNC_DECL explicit tvec3(tvec3<U> const & v);
152 template <typename U>
153 GLM_FUNC_DECL explicit tvec3(tvec4<U> const & v);
154
156 // Swizzle constructors
157
158 GLM_FUNC_DECL tvec3(tref3<T> const & r);
159
160 template <typename A, typename B>
161 GLM_FUNC_DECL explicit tvec3(tref2<A> const & v, B const & s);
162
163 template <typename A, typename B>
164 GLM_FUNC_DECL explicit tvec3(A const & s, tref2<B> const & v);
165
166 template <int E0, int E1, int E2>
167 GLM_FUNC_DECL tvec3(glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & that)
168 {
169 *this = that();
170 }
171
172 template <int E0, int E1>
173 GLM_FUNC_DECL tvec3(glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, T const & s)
174 {
175 *this = tvec3<T>(v(), s);
176 }
177
178 template <int E0, int E1>
179 GLM_FUNC_DECL tvec3(T const & s, glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v)
180 {
181 *this = tvec3<T>(s, v());
182 }
183
185 // Unary arithmetic operators
186
187 GLM_FUNC_DECL tvec3<T> & operator= (tvec3<T> const & v);
188 template <typename U>
189 GLM_FUNC_DECL tvec3<T> & operator= (tvec3<U> const & v);
190
191 template <typename U>
192 GLM_FUNC_DECL tvec3<T> & operator+=(U const & s);
193 template <typename U>
194 GLM_FUNC_DECL tvec3<T> & operator+=(tvec3<U> const & v);
195 template <typename U>
196 GLM_FUNC_DECL tvec3<T> & operator-=(U const & s);
197 template <typename U>
198 GLM_FUNC_DECL tvec3<T> & operator-=(tvec3<U> const & v);
199 template <typename U>
200 GLM_FUNC_DECL tvec3<T> & operator*=(U const & s);
201 template <typename U>
202 GLM_FUNC_DECL tvec3<T> & operator*=(tvec3<U> const & v);
203 template <typename U>
204 GLM_FUNC_DECL tvec3<T> & operator/=(U const & s);
205 template <typename U>
206 GLM_FUNC_DECL tvec3<T> & operator/=(tvec3<U> const & v);
207 GLM_FUNC_DECL tvec3<T> & operator++();
208 GLM_FUNC_DECL tvec3<T> & operator--();
209
211 // Unary bit operators
212
213 template <typename U>
214 GLM_FUNC_DECL tvec3<T> & operator%= (U const & s);
215 template <typename U>
216 GLM_FUNC_DECL tvec3<T> & operator%= (tvec3<U> const & v);
217 template <typename U>
218 GLM_FUNC_DECL tvec3<T> & operator&= (U const & s);
219 template <typename U>
220 GLM_FUNC_DECL tvec3<T> & operator&= (tvec3<U> const & v);
221 template <typename U>
222 GLM_FUNC_DECL tvec3<T> & operator|= (U const & s);
223 template <typename U>
224 GLM_FUNC_DECL tvec3<T> & operator|= (tvec3<U> const & v);
225 template <typename U>
226 GLM_FUNC_DECL tvec3<T> & operator^= (U const & s);
227 template <typename U>
228 GLM_FUNC_DECL tvec3<T> & operator^= (tvec3<U> const & v);
229 template <typename U>
230 GLM_FUNC_DECL tvec3<T> & operator<<=(U const & s);
231 template <typename U>
232 GLM_FUNC_DECL tvec3<T> & operator<<=(tvec3<U> const & v);
233 template <typename U>
234 GLM_FUNC_DECL tvec3<T> & operator>>=(U const & s);
235 template <typename U>
236 GLM_FUNC_DECL tvec3<T> & operator>>=(tvec3<U> const & v);
237
239 // Swizzle operators
240
241 GLM_FUNC_DECL value_type swizzle(comp X) const;
242 GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
243 GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
244 GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
245 GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
246 GLM_FUNC_DECL tref3<T> swizzle(comp X, comp Y, comp Z);
247 };
248
249 template <typename T>
250 struct tref3
251 {
252 GLM_FUNC_DECL tref3(T & x, T & y, T & z);
253 GLM_FUNC_DECL tref3(tref3<T> const & r);
254 GLM_FUNC_DECL explicit tref3(tvec3<T> const & v);
255
256 GLM_FUNC_DECL tref3<T> & operator= (tref3<T> const & r);
257 GLM_FUNC_DECL tref3<T> & operator= (tvec3<T> const & v);
258
259 GLM_FUNC_DECL tvec3<T> operator() ();
260
261 T & x;
262 T & y;
263 T & z;
264 };
265
266 GLM_DETAIL_IS_VECTOR(tvec3);
267 } //namespace detail
268
271
277 typedef detail::tvec3<highp_float> highp_vec3;
278
284 typedef detail::tvec3<mediump_float> mediump_vec3;
285
291 typedef detail::tvec3<lowp_float> lowp_vec3;
292
298 typedef detail::tvec3<highp_int> highp_ivec3;
299
305 typedef detail::tvec3<mediump_int> mediump_ivec3;
306
312 typedef detail::tvec3<lowp_int> lowp_ivec3;
313
319 typedef detail::tvec3<highp_uint> highp_uvec3;
320
326 typedef detail::tvec3<mediump_uint> mediump_uvec3;
327
333 typedef detail::tvec3<lowp_uint> lowp_uvec3;
334
336 }//namespace glm
337
338 #ifndef GLM_EXTERNAL_TEMPLATE
339 #include "type_vec3.inl"
340 #endif//GLM_EXTERNAL_TEMPLATE
341
342 #endif//glm_core_type_gentype3