3rdparty/glm/doc/api/a00131_source.html
| | 0.9.8 |
type_vec4.hpp
Go to the documentation of this file.
1
4 #pragma once
5
6 #include "type_vec.hpp"
7 #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
8 # if GLM_HAS_UNRESTRICTED_UNIONS
9 # include "_swizzle.hpp"
10 # else
11 # include "_swizzle_func.hpp"
12 # endif
13 #endif //GLM_SWIZZLE
14 #include <cstddef>
15
16 namespace glm
17 {
18template <typename T, precision P = defaultp>
19struct tvec4
20 {
21// -- Implementation detail --
22
23typedef T value_type;
24typedef tvec4<T, P> type;
25typedef tvec4<bool, P> bool_type;
26
27// -- Data --
28
29 # if GLM_HAS_ALIGNED_TYPE
30 # if GLM_COMPILER & GLM_COMPILER_GCC
31 # pragma GCC diagnostic push
32 # pragma GCC diagnostic ignored "-pedantic"
33 # endif
34 # if GLM_COMPILER & GLM_COMPILER_CLANG
35 # pragma clang diagnostic push
36 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
37 # pragma clang diagnostic ignored "-Wnested-anon-types"
38 # endif
39
40union
41 {
42struct { T x, y, z, w;};
43struct { T r, g, b, a; };
44struct { T s, t, p, q; };
45
46typename detail::storage<T, sizeof(T) * 4, detail::is_aligned<P>::value>::type data;
47
48 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
49 _GLM_SWIZZLE4_2_MEMBERS(T, P, glm::tvec2, x, y, z, w)
50 _GLM_SWIZZLE4_2_MEMBERS(T, P, glm::tvec2, r, g, b, a)
51 _GLM_SWIZZLE4_2_MEMBERS(T, P, glm::tvec2, s, t, p, q)
52 _GLM_SWIZZLE4_3_MEMBERS(T, P, glm::tvec3, x, y, z, w)
53 _GLM_SWIZZLE4_3_MEMBERS(T, P, glm::tvec3, r, g, b, a)
54 _GLM_SWIZZLE4_3_MEMBERS(T, P, glm::tvec3, s, t, p, q)
55 _GLM_SWIZZLE4_4_MEMBERS(T, P, glm::tvec4, x, y, z, w)
56 _GLM_SWIZZLE4_4_MEMBERS(T, P, glm::tvec4, r, g, b, a)
57 _GLM_SWIZZLE4_4_MEMBERS(T, P, glm::tvec4, s, t, p, q)
58 # endif//GLM_SWIZZLE
59 };
60
61 # if GLM_COMPILER & GLM_COMPILER_CLANG
62 # pragma clang diagnostic pop
63 # endif
64 # if GLM_COMPILER & GLM_COMPILER_GCC
65 # pragma GCC diagnostic pop
66 # endif
67 # else
68union { T x, r, s; };
69union { T y, g, t; };
70union { T z, b, p; };
71union { T w, a, q; };
72
73 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
74 GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P, tvec4, tvec2, tvec3, tvec4)
75 # endif//GLM_SWIZZLE
76 # endif
77
78// -- Component accesses --
79
81typedef length_t length_type;
82 GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
83
84 GLM_FUNC_DECL T & operator[](length_type i);
85 GLM_FUNC_DECL T const & operator[](length_type i) const;
86
87// -- Implicit basic constructors --
88
89 GLM_FUNC_DECL GLM_CONSTEXPR tvec4() GLM_DEFAULT_CTOR;
90 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, P> const& v) GLM_DEFAULT;
91 template <precision Q>
92 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec4<T, Q> const& v);
93
94// -- Explicit basic constructors --
95
96 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit tvec4(ctor);
97 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD explicit tvec4(T scalar);
98 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD tvec4(T a, T b, T c, T d);
99
100// -- Conversion scalar constructors --
101
103 template <typename A, typename B, typename C, typename D>
104 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(A a, B b, C c, D d);
105 template <typename A, typename B, typename C, typename D>
106 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec1<A, P> const& a, tvec1<B, P> const& b, tvec1<C, P> const& c, tvec1<D, P> const& d);
107
108// -- Conversion vector constructors --
109
111 template <typename A, typename B, typename C, precision Q>
112 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec2<A, Q> const & a, B b, C c);
114 template <typename A, typename B, typename C, precision Q>
115 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec2<A, Q> const & a, tvec1<B, Q> const & b, tvec1<C, Q> const & c);
117 template <typename A, typename B, typename C, precision Q>
118 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(A a, tvec2<B, Q> const & b, C c);
120 template <typename A, typename B, typename C, precision Q>
121 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec1<A, Q> const & a, tvec2<B, Q> const & b, tvec1<C, Q> const & c);
123 template <typename A, typename B, typename C, precision Q>
124 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(A a, B b, tvec2<C, Q> const & c);
126 template <typename A, typename B, typename C, precision Q>
127 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec1<A, Q> const & a, tvec1<B, Q> const & b, tvec2<C, Q> const & c);
129 template <typename A, typename B, precision Q>
130 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec3<A, Q> const & a, B b);
132 template <typename A, typename B, precision Q>
133 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec3<A, Q> const & a, tvec1<B, Q> const & b);
135 template <typename A, typename B, precision Q>
136 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(A a, tvec3<B, Q> const & b);
138 template <typename A, typename B, precision Q>
139 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec1<A, Q> const & a, tvec3<B, Q> const & b);
141 template <typename A, typename B, precision Q>
142 GLM_FUNC_DECL GLM_CONSTEXPR tvec4(tvec2<A, Q> const & a, tvec2<B, Q> const & b);
143
145 template <typename U, precision Q>
146 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tvec4(tvec4<U, Q> const& v);
147
148// -- Swizzle constructors --
149 # if GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
150template <int E0, int E1, int E2, int E3>
151 GLM_FUNC_DECL tvec4(detail::_swizzle<4, T, P, glm::tvec4, E0, E1, E2, E3> const & that)
152 {
153 *this = that();
154 }
155
156template <int E0, int E1, int F0, int F1>
157 GLM_FUNC_DECL tvec4(detail::_swizzle<2, T, P, glm::tvec2, E0, E1, -1, -2> const & v, detail::_swizzle<2, T, P, glm::tvec2, F0, F1, -1, -2> const & u)
158 {
159 *this = tvec4<T, P>(v(), u());
160 }
161
162template <int E0, int E1>
163 GLM_FUNC_DECL tvec4(T const & x, T const & y, detail::_swizzle<2, T, P, glm::tvec2, E0, E1, -1, -2> const & v)
164 {
165 *this = tvec4<T, P>(x, y, v());
166 }
167
168template <int E0, int E1>
169 GLM_FUNC_DECL tvec4(T const & x, detail::_swizzle<2, T, P, glm::tvec2, E0, E1, -1, -2> const & v, T const & w)
170 {
171 *this = tvec4<T, P>(x, v(), w);
172 }
173
174template <int E0, int E1>
175 GLM_FUNC_DECL tvec4(detail::_swizzle<2, T, P, glm::tvec2, E0, E1, -1, -2> const & v, T const & z, T const & w)
176 {
177 *this = tvec4<T, P>(v(), z, w);
178 }
179
180template <int E0, int E1, int E2>
181 GLM_FUNC_DECL tvec4(detail::_swizzle<3, T, P, glm::tvec3, E0, E1, E2, -1> const & v, T const & w)
182 {
183 *this = tvec4<T, P>(v(), w);
184 }
185
186template <int E0, int E1, int E2>
187 GLM_FUNC_DECL tvec4(T const & x, detail::_swizzle<3, T, P, glm::tvec3, E0, E1, E2, -1> const & v)
188 {
189 *this = tvec4<T, P>(x, v());
190 }
191 # endif// GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
192
193// -- Unary arithmetic operators --
194
195 GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<T, P> const & v) GLM_DEFAULT;
196
197template <typename U>
198 GLM_FUNC_DECL tvec4<T, P> & operator=(tvec4<U, P> const & v);
199template <typename U>
200 GLM_FUNC_DECL tvec4<T, P> & operator+=(U scalar);
201template <typename U>
202 GLM_FUNC_DECL tvec4<T, P> & operator+=(tvec1<U, P> const & v);
203template <typename U>
204 GLM_FUNC_DECL tvec4<T, P> & operator+=(tvec4<U, P> const & v);
205template <typename U>
206 GLM_FUNC_DECL tvec4<T, P> & operator-=(U scalar);
207template <typename U>
208 GLM_FUNC_DECL tvec4<T, P> & operator-=(tvec1<U, P> const & v);
209template <typename U>
210 GLM_FUNC_DECL tvec4<T, P> & operator-=(tvec4<U, P> const & v);
211template <typename U>
212 GLM_FUNC_DECL tvec4<T, P> & operator*=(U scalar);
213template <typename U>
214 GLM_FUNC_DECL tvec4<T, P> & operator*=(tvec1<U, P> const& v);
215template <typename U>
216 GLM_FUNC_DECL tvec4<T, P> & operator*=(tvec4<U, P> const& v);
217template <typename U>
218 GLM_FUNC_DECL tvec4<T, P> & operator/=(U scalar);
219template <typename U>
220 GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec1<U, P> const & v);
221template <typename U>
222 GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec4<U, P> const & v);
223
224// -- Increment and decrement operators --
225
226 GLM_FUNC_DECL tvec4<T, P> & operator++();
227 GLM_FUNC_DECL tvec4<T, P> & operator--();
228 GLM_FUNC_DECL tvec4<T, P> operator++(int);
229 GLM_FUNC_DECL tvec4<T, P> operator--(int);
230
231// -- Unary bit operators --
232
233template <typename U>
234 GLM_FUNC_DECL tvec4<T, P> & operator%=(U scalar);
235template <typename U>
236 GLM_FUNC_DECL tvec4<T, P> & operator%=(tvec1<U, P> const & v);
237template <typename U>
238 GLM_FUNC_DECL tvec4<T, P> & operator%=(tvec4<U, P> const & v);
239template <typename U>
240 GLM_FUNC_DECL tvec4<T, P> & operator&=(U scalar);
241template <typename U>
242 GLM_FUNC_DECL tvec4<T, P> & operator&=(tvec1<U, P> const & v);
243template <typename U>
244 GLM_FUNC_DECL tvec4<T, P> & operator&=(tvec4<U, P> const & v);
245template <typename U>
246 GLM_FUNC_DECL tvec4<T, P> & operator|=(U scalar);
247template <typename U>
248 GLM_FUNC_DECL tvec4<T, P> & operator|=(tvec1<U, P> const & v);
249template <typename U>
250 GLM_FUNC_DECL tvec4<T, P> & operator|=(tvec4<U, P> const & v);
251template <typename U>
252 GLM_FUNC_DECL tvec4<T, P> & operator^=(U scalar);
253template <typename U>
254 GLM_FUNC_DECL tvec4<T, P> & operator^=(tvec1<U, P> const & v);
255template <typename U>
256 GLM_FUNC_DECL tvec4<T, P> & operator^=(tvec4<U, P> const & v);
257template <typename U>
258 GLM_FUNC_DECL tvec4<T, P> & operator<<=(U scalar);
259template <typename U>
260 GLM_FUNC_DECL tvec4<T, P> & operator<<=(tvec1<U, P> const & v);
261template <typename U>
262 GLM_FUNC_DECL tvec4<T, P> & operator<<=(tvec4<U, P> const & v);
263template <typename U>
264 GLM_FUNC_DECL tvec4<T, P> & operator>>=(U scalar);
265template <typename U>
266 GLM_FUNC_DECL tvec4<T, P> & operator>>=(tvec1<U, P> const & v);
267template <typename U>
268 GLM_FUNC_DECL tvec4<T, P> & operator>>=(tvec4<U, P> const & v);
269 };
270
271// -- Unary operators --
272
273template <typename T, precision P>
274 GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v);
275
276template <typename T, precision P>
277 GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v);
278
279// -- Binary operators --
280
281template <typename T, precision P>
282 GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, T scalar);
283
284template <typename T, precision P>
285 GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
286
287template <typename T, precision P>
288 GLM_FUNC_DECL tvec4<T, P> operator+(T scalar, tvec4<T, P> const & v);
289
290template <typename T, precision P>
291 GLM_FUNC_DECL tvec4<T, P> operator+(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
292
293template <typename T, precision P>
294 GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
295
296template <typename T, precision P>
297 GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v, T scalar);
298
299template <typename T, precision P>
300 GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
301
302template <typename T, precision P>
303 GLM_FUNC_DECL tvec4<T, P> operator-(T scalar, tvec4<T, P> const & v);
304
305template <typename T, precision P>
306 GLM_FUNC_DECL tvec4<T, P> operator-(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
307
308template <typename T, precision P>
309 GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
310
311template <typename T, precision P>
312 GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, T scalar);
313
314template <typename T, precision P>
315 GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
316
317template <typename T, precision P>
318 GLM_FUNC_DECL tvec4<T, P> operator*(T scalar, tvec4<T, P> const & v);
319
320template <typename T, precision P>
321 GLM_FUNC_DECL tvec4<T, P> operator*(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
322
323template <typename T, precision P>
324 GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
325
326template <typename T, precision P>
327 GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v, T scalar);
328
329template <typename T, precision P>
330 GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec1<T, P> const & v2);
331
332template <typename T, precision P>
333 GLM_FUNC_DECL tvec4<T, P> operator/(T scalar, tvec4<T, P> const & v);
334
335template <typename T, precision P>
336 GLM_FUNC_DECL tvec4<T, P> operator/(tvec1<T, P> const & v1, tvec4<T, P> const & v2);
337
338template <typename T, precision P>
339 GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
340
341template <typename T, precision P>
342 GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v, T scalar);
343
344template <typename T, precision P>
345 GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
346
347template <typename T, precision P>
348 GLM_FUNC_DECL tvec4<T, P> operator%(T scalar, tvec4<T, P> const & v);
349
350template <typename T, precision P>
351 GLM_FUNC_DECL tvec4<T, P> operator%(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
352
353template <typename T, precision P>
354 GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
355
356template <typename T, precision P>
357 GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v, T scalar);
358
359template <typename T, precision P>
360 GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
361
362template <typename T, precision P>
363 GLM_FUNC_DECL tvec4<T, P> operator&(T scalar, tvec4<T, P> const & v);
364
365template <typename T, precision P>
366 GLM_FUNC_DECL tvec4<T, P> operator&(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
367
368template <typename T, precision P>
369 GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
370
371template <typename T, precision P>
372 GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v, T scalar);
373
374template <typename T, precision P>
375 GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
376
377template <typename T, precision P>
378 GLM_FUNC_DECL tvec4<T, P> operator|(T scalar, tvec4<T, P> const & v);
379
380template <typename T, precision P>
381 GLM_FUNC_DECL tvec4<T, P> operator|(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
382
383template <typename T, precision P>
384 GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
385
386template <typename T, precision P>
387 GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v, T scalar);
388
389template <typename T, precision P>
390 GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
391
392template <typename T, precision P>
393 GLM_FUNC_DECL tvec4<T, P> operator^(T scalar, tvec4<T, P> const & v);
394
395template <typename T, precision P>
396 GLM_FUNC_DECL tvec4<T, P> operator^(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
397
398template <typename T, precision P>
399 GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
400
401template <typename T, precision P>
402 GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v, T scalar);
403
404template <typename T, precision P>
405 GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
406
407template <typename T, precision P>
408 GLM_FUNC_DECL tvec4<T, P> operator<<(T scalar, tvec4<T, P> const & v);
409
410template <typename T, precision P>
411 GLM_FUNC_DECL tvec4<T, P> operator<<(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
412
413template <typename T, precision P>
414 GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
415
416template <typename T, precision P>
417 GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v, T scalar);
418
419template <typename T, precision P>
420 GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v, tvec1<T, P> const & scalar);
421
422template <typename T, precision P>
423 GLM_FUNC_DECL tvec4<T, P> operator>>(T scalar, tvec4<T, P> const & v);
424
425template <typename T, precision P>
426 GLM_FUNC_DECL tvec4<T, P> operator>>(tvec1<T, P> const & scalar, tvec4<T, P> const & v);
427
428template <typename T, precision P>
429 GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
430
431template <typename T, precision P>
432 GLM_FUNC_DECL tvec4<T, P> operator~(tvec4<T, P> const & v);
433
434// -- Boolean operators --
435
436template <typename T, precision P>
437 GLM_FUNC_DECL bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
438
439template <typename T, precision P>
440 GLM_FUNC_DECL bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
441
442template <precision P>
443 GLM_FUNC_DECL tvec4<bool, P> operator&&(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2);
444
445template <precision P>
446 GLM_FUNC_DECL tvec4<bool, P> operator||(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2);
447 }//namespace glm
448
449 #ifndef GLM_EXTERNAL_TEMPLATE
450 #include "type_vec4.inl"
451 #endif//GLM_EXTERNAL_TEMPLATE
GLM Core
Definition: _noise.hpp:11
GLM Core
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
GLM Core
Generated by 1.8.10