7 #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
8 # if GLM_HAS_UNRESTRICTED_UNIONS
18 template<
typename T, qualifier P>
24 typedef vec<4, T, P> type;
25 typedef vec<4, bool, P> bool_type;
29 # if GLM_HAS_ONLY_XYZW
32 # elif GLM_HAS_ALIGNED_TYPE
33 # if GLM_COMPILER & GLM_COMPILER_GCC
34 # pragma GCC diagnostic push
35 # pragma GCC diagnostic ignored "-Wpedantic"
37 # if GLM_COMPILER & GLM_COMPILER_CLANG
38 # pragma clang diagnostic push
39 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
40 # pragma clang diagnostic ignored "-Wnested-anon-types"
45 struct { T x, y, z, w;};
46 struct { T r, g, b, a; };
47 struct { T s, t, p, q; };
49 typename detail::storage<T, sizeof(T) * 4, detail::is_aligned<P>::value>::type data;
51 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
52 GLM_SWIZZLE4_2_MEMBERS(T, P, x, y, z, w)
53 GLM_SWIZZLE4_2_MEMBERS(T, P, r, g, b, a)
54 GLM_SWIZZLE4_2_MEMBERS(T, P, s, t, p, q)
55 GLM_SWIZZLE4_3_MEMBERS(T, P, x, y, z, w)
56 GLM_SWIZZLE4_3_MEMBERS(T, P, r, g, b, a)
57 GLM_SWIZZLE4_3_MEMBERS(T, P, s, t, p, q)
58 GLM_SWIZZLE4_4_MEMBERS(T, P, x, y, z, w)
59 GLM_SWIZZLE4_4_MEMBERS(T, P, r, g, b, a)
60 GLM_SWIZZLE4_4_MEMBERS(T, P, s, t, p, q)
64 # if GLM_COMPILER & GLM_COMPILER_CLANG
65 # pragma clang diagnostic pop
67 # if GLM_COMPILER & GLM_COMPILER_GCC
68 # pragma GCC diagnostic pop
76 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
77 GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P)
84 typedef length_t length_type;
85 GLM_FUNC_DECL
static GLM_CONSTEXPR length_type
length(){
return 4;}
87 GLM_FUNC_DECL T & operator[](length_type i);
88 GLM_FUNC_DECL T
const & operator[](length_type i)
const;
92 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec() GLM_DEFAULT;
93 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(vec<4, T, P> const& v) GLM_DEFAULT;
95 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(vec<4, T, Q> const& v);
99 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD explicit vec(T scalar);
100 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(T x, T y, T z, T w);
105 template<typename X, typename Y, typename Z, typename W>
106 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(X _x, Y _y, Z _z, W _w);
107 template<typename X, typename Y, typename Z, typename W>
108 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, P> const& _x, vec<1, Y, P> const& _Y, vec<1, Z, P> const& _z, vec<1, W, P> const& _w);
113 template<typename A, typename B, typename C, qualifier Q>
114 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, Q> const& _xy, B _z, C _w);
116 template<typename A, typename B, typename C, qualifier Q>
117 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, Q> const& _xy, vec<1, B, Q> const& _z, vec<1, C, Q> const& _w);
119 template<typename A, typename B, typename C, qualifier Q>
120 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A _x, vec<2, B, Q> const& _yz, C _w);
122 template<typename A, typename B, typename C, qualifier Q>
123 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, Q> const& _x, vec<2, B, Q> const& _yz, vec<1, C, Q> const& _w);
125 template<typename A, typename B, typename C, qualifier Q>
126 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A _x, B _y, vec<2, C, Q> const& _zw);
128 template<typename A, typename B, typename C, qualifier Q>
129 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, Q> const& _x, vec<1, B, Q> const& _y, vec<2, C, Q> const& _zw);
131 template<typename A, typename B, qualifier Q>
132 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<3, A, Q> const& _xyz, B _w);
134 template<typename A, typename B, qualifier Q>
135 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<3, A, Q> const& _xyz, vec<1, B, Q> const& _w);
137 template<typename A, typename B, qualifier Q>
138 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A _x, vec<3, B, Q> const& _yzw);
140 template<typename A, typename B, qualifier Q>
141 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, Q> const& _x, vec<3, B, Q> const& _yzw);
143 template<typename A, typename B, qualifier Q>
144 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, Q> const& _xy, vec<2, B, Q> const& _zw);
147 template<typename U, qualifier Q>
148 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<4, U, Q> const& v);
151 # if GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
152 template<
int E0,
int E1,
int E2,
int E3>
153 GLM_FUNC_DECL vec(detail::_swizzle<4, T, P, E0, E1, E2, E3>
const & that)
158 template<
int E0,
int E1,
int F0,
int F1>
159 GLM_FUNC_DECL vec(detail::_swizzle<2, T, P, E0, E1, -1, -2>
const & v, detail::_swizzle<2, T, P, F0, F1, -1, -2>
const & u)
161 *
this = vec<4, T, P>(v(), u());
164 template<
int E0,
int E1>
165 GLM_FUNC_DECL vec(T
const & x, T
const & y, detail::_swizzle<2, T, P, E0, E1, -1, -2>
const & v)
167 *
this = vec<4, T, P>(x, y, v());
170 template<
int E0,
int E1>
171 GLM_FUNC_DECL vec(T
const & x, detail::_swizzle<2, T, P, E0, E1, -1, -2>
const & v, T
const & w)
173 *
this = vec<4, T, P>(x, v(), w);
176 template<
int E0,
int E1>
177 GLM_FUNC_DECL vec(detail::_swizzle<2, T, P, E0, E1, -1, -2>
const & v, T
const & z, T
const & w)
179 *
this = vec<4, T, P>(v(), z, w);
182 template<
int E0,
int E1,
int E2>
183 GLM_FUNC_DECL vec(detail::_swizzle<3, T, P, E0, E1, E2, -1>
const & v, T
const & w)
185 *
this = vec<4, T, P>(v(), w);
188 template<
int E0,
int E1,
int E2>
189 GLM_FUNC_DECL vec(T
const & x, detail::_swizzle<3, T, P, E0, E1, E2, -1>
const & v)
191 *
this = vec<4, T, P>(x, v());
193 # endif// GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
197 GLM_FUNC_DECL vec<4, T, P>& operator=(vec<4, T, P>
const & v) GLM_DEFAULT;
200 GLM_FUNC_DECL vec<4, T, P>& operator=(vec<4, U, P>
const & v);
202 GLM_FUNC_DECL vec<4, T, P>& operator+=(U scalar);
204 GLM_FUNC_DECL vec<4, T, P>& operator+=(vec<1, U, P>
const & v);
206 GLM_FUNC_DECL vec<4, T, P>& operator+=(vec<4, U, P>
const & v);
208 GLM_FUNC_DECL vec<4, T, P>& operator-=(U scalar);
210 GLM_FUNC_DECL vec<4, T, P>& operator-=(vec<1, U, P>
const & v);
212 GLM_FUNC_DECL vec<4, T, P>& operator-=(vec<4, U, P>
const & v);
214 GLM_FUNC_DECL vec<4, T, P>& operator*=(U scalar);
216 GLM_FUNC_DECL vec<4, T, P>& operator*=(vec<1, U, P>
const& v);
218 GLM_FUNC_DECL vec<4, T, P>& operator*=(vec<4, U, P>
const& v);
220 GLM_FUNC_DECL vec<4, T, P>& operator/=(U scalar);
222 GLM_FUNC_DECL vec<4, T, P>& operator/=(vec<1, U, P>
const & v);
224 GLM_FUNC_DECL vec<4, T, P>& operator/=(vec<4, U, P>
const & v);
228 GLM_FUNC_DECL vec<4, T, P> & operator++();
229 GLM_FUNC_DECL vec<4, T, P> & operator--();
230 GLM_FUNC_DECL vec<4, T, P> operator++(
int);
231 GLM_FUNC_DECL vec<4, T, P> operator--(
int);
236 GLM_FUNC_DECL vec<4, T, P> & operator%=(U scalar);
238 GLM_FUNC_DECL vec<4, T, P> & operator%=(vec<1, U, P>
const & v);
240 GLM_FUNC_DECL vec<4, T, P> & operator%=(vec<4, U, P>
const & v);
242 GLM_FUNC_DECL vec<4, T, P> & operator&=(U scalar);
244 GLM_FUNC_DECL vec<4, T, P> & operator&=(vec<1, U, P>
const & v);
246 GLM_FUNC_DECL vec<4, T, P> & operator&=(vec<4, U, P>
const & v);
248 GLM_FUNC_DECL vec<4, T, P> & operator|=(U scalar);
250 GLM_FUNC_DECL vec<4, T, P> & operator|=(vec<1, U, P>
const & v);
252 GLM_FUNC_DECL vec<4, T, P> & operator|=(vec<4, U, P>
const & v);
254 GLM_FUNC_DECL vec<4, T, P> & operator^=(U scalar);
256 GLM_FUNC_DECL vec<4, T, P> & operator^=(vec<1, U, P>
const & v);
258 GLM_FUNC_DECL vec<4, T, P> & operator^=(vec<4, U, P>
const & v);
260 GLM_FUNC_DECL vec<4, T, P> & operator<<=(U scalar);
262 GLM_FUNC_DECL vec<4, T, P> & operator<<=(vec<1, U, P>
const & v);
264 GLM_FUNC_DECL vec<4, T, P> & operator<<=(vec<4, U, P>
const & v);
266 GLM_FUNC_DECL vec<4, T, P> & operator>>=(U scalar);
268 GLM_FUNC_DECL vec<4, T, P> & operator>>=(vec<1, U, P>
const & v);
270 GLM_FUNC_DECL vec<4, T, P> & operator>>=(vec<4, U, P>
const & v);
275 template<
typename T, qualifier P>
276 GLM_FUNC_DECL vec<4, T, P> operator+(vec<4, T, P>
const & v);
278 template<
typename T, qualifier P>
279 GLM_FUNC_DECL vec<4, T, P> operator-(vec<4, T, P>
const & v);
283 template<
typename T, qualifier P>
284 GLM_FUNC_DECL vec<4, T, P> operator+(vec<4, T, P>
const & v, T scalar);
286 template<
typename T, qualifier P>
287 GLM_FUNC_DECL vec<4, T, P> operator+(vec<4, T, P>
const & v1, vec<1, T, P>
const & v2);
289 template<
typename T, qualifier P>
290 GLM_FUNC_DECL vec<4, T, P> operator+(T scalar, vec<4, T, P>
const & v);
292 template<
typename T, qualifier P>
293 GLM_FUNC_DECL vec<4, T, P> operator+(vec<1, T, P>
const & v1, vec<4, T, P>
const & v2);
295 template<
typename T, qualifier P>
296 GLM_FUNC_DECL vec<4, T, P> operator+(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
298 template<
typename T, qualifier P>
299 GLM_FUNC_DECL vec<4, T, P> operator-(vec<4, T, P>
const & v, T scalar);
301 template<
typename T, qualifier P>
302 GLM_FUNC_DECL vec<4, T, P> operator-(vec<4, T, P>
const & v1, vec<1, T, P>
const & v2);
304 template<
typename T, qualifier P>
305 GLM_FUNC_DECL vec<4, T, P> operator-(T scalar, vec<4, T, P>
const & v);
307 template<
typename T, qualifier P>
308 GLM_FUNC_DECL vec<4, T, P> operator-(vec<1, T, P>
const & v1, vec<4, T, P>
const & v2);
310 template<
typename T, qualifier P>
311 GLM_FUNC_DECL vec<4, T, P> operator-(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
313 template<
typename T, qualifier P>
314 GLM_FUNC_DECL vec<4, T, P> operator*(vec<4, T, P>
const & v, T scalar);
316 template<
typename T, qualifier P>
317 GLM_FUNC_DECL vec<4, T, P> operator*(vec<4, T, P>
const & v1, vec<1, T, P>
const & v2);
319 template<
typename T, qualifier P>
320 GLM_FUNC_DECL vec<4, T, P> operator*(T scalar, vec<4, T, P>
const & v);
322 template<
typename T, qualifier P>
323 GLM_FUNC_DECL vec<4, T, P> operator*(vec<1, T, P>
const & v1, vec<4, T, P>
const & v2);
325 template<
typename T, qualifier P>
326 GLM_FUNC_DECL vec<4, T, P> operator*(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
328 template<
typename T, qualifier P>
329 GLM_FUNC_DECL vec<4, T, P> operator/(vec<4, T, P>
const & v, T scalar);
331 template<
typename T, qualifier P>
332 GLM_FUNC_DECL vec<4, T, P> operator/(vec<4, T, P>
const & v1, vec<1, T, P>
const & v2);
334 template<
typename T, qualifier P>
335 GLM_FUNC_DECL vec<4, T, P> operator/(T scalar, vec<4, T, P>
const & v);
337 template<
typename T, qualifier P>
338 GLM_FUNC_DECL vec<4, T, P> operator/(vec<1, T, P>
const & v1, vec<4, T, P>
const & v2);
340 template<
typename T, qualifier P>
341 GLM_FUNC_DECL vec<4, T, P> operator/(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
343 template<
typename T, qualifier P>
344 GLM_FUNC_DECL vec<4, T, P> operator%(vec<4, T, P>
const & v, T scalar);
346 template<
typename T, qualifier P>
347 GLM_FUNC_DECL vec<4, T, P> operator%(vec<4, T, P>
const & v, vec<1, T, P>
const & scalar);
349 template<
typename T, qualifier P>
350 GLM_FUNC_DECL vec<4, T, P> operator%(T scalar, vec<4, T, P>
const & v);
352 template<
typename T, qualifier P>
353 GLM_FUNC_DECL vec<4, T, P> operator%(vec<1, T, P>
const & scalar, vec<4, T, P>
const & v);
355 template<
typename T, qualifier P>
356 GLM_FUNC_DECL vec<4, T, P> operator%(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
358 template<
typename T, qualifier P>
359 GLM_FUNC_DECL vec<4, T, P> operator&(vec<4, T, P>
const & v, T scalar);
361 template<
typename T, qualifier P>
362 GLM_FUNC_DECL vec<4, T, P> operator&(vec<4, T, P>
const & v, vec<1, T, P>
const & scalar);
364 template<
typename T, qualifier P>
365 GLM_FUNC_DECL vec<4, T, P> operator&(T scalar, vec<4, T, P>
const & v);
367 template<
typename T, qualifier P>
368 GLM_FUNC_DECL vec<4, T, P> operator&(vec<1, T, P>
const & scalar, vec<4, T, P>
const & v);
370 template<
typename T, qualifier P>
371 GLM_FUNC_DECL vec<4, T, P> operator&(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
373 template<
typename T, qualifier P>
374 GLM_FUNC_DECL vec<4, T, P> operator|(vec<4, T, P>
const & v, T scalar);
376 template<
typename T, qualifier P>
377 GLM_FUNC_DECL vec<4, T, P> operator|(vec<4, T, P>
const & v, vec<1, T, P>
const & scalar);
379 template<
typename T, qualifier P>
380 GLM_FUNC_DECL vec<4, T, P> operator|(T scalar, vec<4, T, P>
const & v);
382 template<
typename T, qualifier P>
383 GLM_FUNC_DECL vec<4, T, P> operator|(vec<1, T, P>
const & scalar, vec<4, T, P>
const & v);
385 template<
typename T, qualifier P>
386 GLM_FUNC_DECL vec<4, T, P> operator|(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
388 template<
typename T, qualifier P>
389 GLM_FUNC_DECL vec<4, T, P> operator^(vec<4, T, P>
const & v, T scalar);
391 template<
typename T, qualifier P>
392 GLM_FUNC_DECL vec<4, T, P> operator^(vec<4, T, P>
const & v, vec<1, T, P>
const & scalar);
394 template<
typename T, qualifier P>
395 GLM_FUNC_DECL vec<4, T, P> operator^(T scalar, vec<4, T, P>
const & v);
397 template<
typename T, qualifier P>
398 GLM_FUNC_DECL vec<4, T, P> operator^(vec<1, T, P>
const & scalar, vec<4, T, P>
const & v);
400 template<
typename T, qualifier P>
401 GLM_FUNC_DECL vec<4, T, P> operator^(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
403 template<
typename T, qualifier P>
404 GLM_FUNC_DECL vec<4, T, P> operator<<(vec<4, T, P>
const & v, T scalar);
406 template<
typename T, qualifier P>
407 GLM_FUNC_DECL vec<4, T, P> operator<<(vec<4, T, P>
const & v, vec<1, T, P>
const & scalar);
409 template<
typename T, qualifier P>
410 GLM_FUNC_DECL vec<4, T, P> operator<<(T scalar, vec<4, T, P>
const & v);
412 template<
typename T, qualifier P>
413 GLM_FUNC_DECL vec<4, T, P> operator<<(vec<1, T, P>
const & scalar, vec<4, T, P>
const & v);
415 template<
typename T, qualifier P>
416 GLM_FUNC_DECL vec<4, T, P> operator<<(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
418 template<
typename T, qualifier P>
419 GLM_FUNC_DECL vec<4, T, P> operator>>(vec<4, T, P>
const & v, T scalar);
421 template<
typename T, qualifier P>
422 GLM_FUNC_DECL vec<4, T, P> operator>>(vec<4, T, P>
const & v, vec<1, T, P>
const & scalar);
424 template<
typename T, qualifier P>
425 GLM_FUNC_DECL vec<4, T, P> operator>>(T scalar, vec<4, T, P>
const & v);
427 template<
typename T, qualifier P>
428 GLM_FUNC_DECL vec<4, T, P> operator>>(vec<1, T, P>
const & scalar, vec<4, T, P>
const & v);
430 template<
typename T, qualifier P>
431 GLM_FUNC_DECL vec<4, T, P> operator>>(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
433 template<
typename T, qualifier P>
434 GLM_FUNC_DECL vec<4, T, P> operator~(vec<4, T, P>
const & v);
438 template<
typename T, qualifier P>
439 GLM_FUNC_DECL
bool operator==(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
441 template<
typename T, qualifier P>
442 GLM_FUNC_DECL
bool operator!=(vec<4, T, P>
const & v1, vec<4, T, P>
const & v2);
444 template<qualifier P>
445 GLM_FUNC_DECL vec<4, bool, P> operator&&(vec<4, bool, P>
const & v1, vec<4, bool, P>
const & v2);
447 template<qualifier P>
448 GLM_FUNC_DECL vec<4, bool, P> operator||(vec<4, bool, P>
const & v1, vec<4, bool, P>
const & v2);
451 #ifndef GLM_EXTERNAL_TEMPLATE
452 #include "type_vec4.inl"
453 #endif//GLM_EXTERNAL_TEMPLATE
GLM_FUNC_DECL T length(vec< L, T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).