00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #pragma once
00030
00031
00032 #include "setup.hpp"
00033 #include "type_vec.hpp"
00034 #ifdef GLM_SWIZZLE
00035 # if GLM_HAS_ANONYMOUS_UNION
00036 # include "_swizzle.hpp"
00037 # else
00038 # include "_swizzle_func.hpp"
00039 # endif
00040 #endif //GLM_SWIZZLE
00041 #include <cstddef>
00042
00043 namespace glm{
00044 namespace detail
00045 {
00046 template <typename T>
00047 struct simd
00048 {
00049 typedef T type[4];
00050 };
00051
00052 # if(GLM_ARCH & GLM_ARCH_SSE2)
00053 template <>
00054 struct simd<float>
00055 {
00056 typedef __m128 type;
00057 };
00058 # endif
00059
00060 # if(GLM_ARCH & GLM_ARCH_AVX)
00061 template <>
00062 struct simd<double>
00063 {
00064 typedef __m256d type;
00065 };
00066 # endif
00067
00068 template <typename T, precision P>
00069 struct tvec4
00070 {
00072
00073
00074 enum ctor{_null};
00075
00076 typedef tvec4<T, P> type;
00077 typedef tvec4<bool, P> bool_type;
00078 typedef T value_type;
00079 typedef int size_type;
00080
00082
00083
00084 GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
00085
00087
00088
00089 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
00090 union
00091 {
00092 typename simd<T>::type data;
00093 struct { T r, g, b, a; };
00094 struct { T s, t, p, q; };
00095 struct { T x, y, z, w;};
00096
00097 _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w)
00098 _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, r, g, b, a)
00099 _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, s, t, p, q)
00100 _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, x, y, z, w)
00101 _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, r, g, b, a)
00102 _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, s, t, p, q)
00103 _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, x, y, z, w)
00104 _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, r, g, b, a)
00105 _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, s, t, p, q)
00106 };
00107 # else
00108 # if(GLM_HAS_UNRESTRICTED_UNIONS)
00109 union
00110 {
00111 typename simd<T>::type data;
00112 struct
00113 {
00114 union { T x, r, s; };
00115 union { T y, g, t; };
00116 union { T z, b, p; };
00117 union { T w, a, q; };
00118 };
00119 };
00120 # else
00121 union { T x, r, s; };
00122 union { T y, g, t; };
00123 union { T z, b, p; };
00124 union { T w, a, q; };
00125 # endif
00126
00127 # ifdef GLM_SWIZZLE
00128 GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4)
00129 # endif
00130 # endif//GLM_LANG
00131
00133
00134
00135 GLM_FUNC_DECL T & operator[](length_t i);
00136 GLM_FUNC_DECL T const & operator[](length_t i) const;
00137
00139
00140
00141 GLM_FUNC_DECL tvec4();
00142 GLM_FUNC_DECL tvec4(type const & v);
00143 template <precision Q>
00144 GLM_FUNC_DECL tvec4(tvec4<T, Q> const & v);
00145
00147
00148
00149 GLM_FUNC_DECL explicit tvec4(
00150 ctor);
00151 GLM_FUNC_DECL explicit tvec4(
00152 T const & s);
00153 GLM_FUNC_DECL tvec4(
00154 T const & s0,
00155 T const & s1,
00156 T const & s2,
00157 T const & s3);
00158
00160
00161
00163 template <typename A, typename B, typename C, typename D>
00164 GLM_FUNC_DECL tvec4(
00165 A const & x,
00166 B const & y,
00167 C const & z,
00168 D const & w);
00169
00171
00172
00174 template <typename A, typename B, typename C, precision Q>
00175 GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & v, B const & s1, C const & s2);
00177 template <typename A, typename B, typename C, precision Q>
00178 GLM_FUNC_DECL explicit tvec4(A const & s1, tvec2<B, Q> const & v, C const & s2);
00180 template <typename A, typename B, typename C, precision Q>
00181 GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tvec2<C, Q> const & v);
00183 template <typename A, typename B, precision Q>
00184 GLM_FUNC_DECL explicit tvec4(tvec3<A, Q> const & v, B const & s);
00186 template <typename A, typename B, precision Q>
00187 GLM_FUNC_DECL explicit tvec4(A const & s, tvec3<B, Q> const & v);
00189 template <typename A, typename B, precision Q>
00190 GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & v1, tvec2<B, Q> const & v2);
00192 template <typename U, precision Q>
00193 GLM_FUNC_DECL explicit tvec4(tvec4<U, Q> const & v);
00194
00196
00197
00198 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
00199 template <int E0, int E1, int E2, int E3>
00200 GLM_FUNC_DECL tvec4(_swizzle<4, T, P, tvec4<T, P>, E0, E1, E2, E3> const & that)
00201 {
00202 *this = that();
00203 }
00204
00205 template <int E0, int E1, int F0, int F1>
00206 GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, _swizzle<2, T, P, tvec2<T, P>, F0, F1, -1, -2> const & u)
00207 {
00208 *this = tvec4<T, P>(v(), u());
00209 }
00210
00211 template <int E0, int E1>
00212 GLM_FUNC_DECL tvec4(T const & x, T const & y, _swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v)
00213 {
00214 *this = tvec4<T, P>(x, y, v());
00215 }
00216
00217 template <int E0, int E1>
00218 GLM_FUNC_DECL tvec4(T const & x, _swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & w)
00219 {
00220 *this = tvec4<T, P>(x, v(), w);
00221 }
00222
00223 template <int E0, int E1>
00224 GLM_FUNC_DECL tvec4(_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & z, T const & w)
00225 {
00226 *this = tvec4<T, P>(v(), z, w);
00227 }
00228
00229 template <int E0, int E1, int E2>
00230 GLM_FUNC_DECL tvec4(_swizzle<3, T, P, tvec3<T, P>, E0, E1, E2, -1> const & v, T const & w)
00231 {
00232 *this = tvec4<T, P>(v(), w);
00233 }
00234
00235 template <int E0, int E1, int E2>
00236 GLM_FUNC_DECL tvec4(T const & x, _swizzle<3, T, P, tvec3<T, P>, E0, E1, E2, -1> const & v)
00237 {
00238 *this = tvec4<T, P>(x, v());
00239 }
00240 # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
00241
00243
00244
00245 GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<T, P> const & v);
00246
00247 GLM_FUNC_DECL tvec4<T, P> & operator+=(T v);
00248 GLM_FUNC_DECL tvec4<T, P> & operator+=(tvec4<T, P> const & v);
00249 GLM_FUNC_DECL tvec4<T, P> & operator-=(T v);
00250 GLM_FUNC_DECL tvec4<T, P> & operator-=(tvec4<T, P> const & v);
00251 GLM_FUNC_DECL tvec4<T, P> & operator*=(T v);
00252 GLM_FUNC_DECL tvec4<T, P> & operator*=(tvec4<T, P> const & v);
00253 GLM_FUNC_DECL tvec4<T, P> & operator/=(T v);
00254 GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec4<T, P> const & v);
00255
00256 template <typename U, precision Q>
00257 GLM_FUNC_DECL tvec4<T, P> & operator= (tvec4<U, Q> const & v);
00258 template <typename U>
00259 GLM_FUNC_DECL tvec4<T, P> & operator+=(U s);
00260 template <typename U>
00261 GLM_FUNC_DECL tvec4<T, P> & operator+=(tvec4<U, P> const & v);
00262 template <typename U>
00263 GLM_FUNC_DECL tvec4<T, P> & operator-=(U s);
00264 template <typename U>
00265 GLM_FUNC_DECL tvec4<T, P> & operator-=(tvec4<U, P> const & v);
00266 template <typename U>
00267 GLM_FUNC_DECL tvec4<T, P> & operator*=(U s);
00268 template <typename U>
00269 GLM_FUNC_DECL tvec4<T, P> & operator*=(tvec4<U, P> const & v);
00270 template <typename U>
00271 GLM_FUNC_DECL tvec4<T, P> & operator/=(U s);
00272 template <typename U>
00273 GLM_FUNC_DECL tvec4<T, P> & operator/=(tvec4<U, P> const & v);
00274
00276
00277
00278 GLM_FUNC_DECL tvec4<T, P> & operator++();
00279 GLM_FUNC_DECL tvec4<T, P> & operator--();
00280 GLM_FUNC_DECL tvec4<T, P> operator++(int);
00281 GLM_FUNC_DECL tvec4<T, P> operator--(int);
00282
00284
00285
00286 template <typename U>
00287 GLM_FUNC_DECL tvec4<T, P> & operator%= (U s);
00288 template <typename U>
00289 GLM_FUNC_DECL tvec4<T, P> & operator%= (tvec4<U, P> const & v);
00290 template <typename U>
00291 GLM_FUNC_DECL tvec4<T, P> & operator&= (U s);
00292 template <typename U>
00293 GLM_FUNC_DECL tvec4<T, P> & operator&= (tvec4<U, P> const & v);
00294 template <typename U>
00295 GLM_FUNC_DECL tvec4<T, P> & operator|= (U s);
00296 template <typename U>
00297 GLM_FUNC_DECL tvec4<T, P> & operator|= (tvec4<U, P> const & v);
00298 template <typename U>
00299 GLM_FUNC_DECL tvec4<T, P> & operator^= (U s);
00300 template <typename U>
00301 GLM_FUNC_DECL tvec4<T, P> & operator^= (tvec4<U, P> const & v);
00302 template <typename U>
00303 GLM_FUNC_DECL tvec4<T, P> & operator<<=(U s);
00304 template <typename U>
00305 GLM_FUNC_DECL tvec4<T, P> & operator<<=(tvec4<U, P> const & v);
00306 template <typename U>
00307 GLM_FUNC_DECL tvec4<T, P> & operator>>=(U s);
00308 template <typename U>
00309 GLM_FUNC_DECL tvec4<T, P> & operator>>=(tvec4<U, P> const & v);
00310 };
00311
00312 template <typename T, precision P>
00313 GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, T const & s);
00314
00315 template <typename T, precision P>
00316 GLM_FUNC_DECL tvec4<T, P> operator+(T const & s, tvec4<T, P> const & v);
00317
00318 template <typename T, precision P>
00319 GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00320
00321 template <typename T, precision P>
00322 GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v, T const & s);
00323
00324 template <typename T, precision P>
00325 GLM_FUNC_DECL tvec4<T, P> operator-(T const & s, tvec4<T, P> const & v);
00326
00327 template <typename T, precision P>
00328 GLM_FUNC_DECL tvec4<T, P> operator- (tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00329
00330 template <typename T, precision P>
00331 GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v, T const & s);
00332
00333 template <typename T, precision P>
00334 GLM_FUNC_DECL tvec4<T, P> operator*(T const & s, tvec4<T, P> const & v);
00335
00336 template <typename T, precision P>
00337 GLM_FUNC_DECL tvec4<T, P> operator*(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00338
00339 template <typename T, precision P>
00340 GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v, T const & s);
00341
00342 template <typename T, precision P>
00343 GLM_FUNC_DECL tvec4<T, P> operator/(T const & s, tvec4<T, P> const & v);
00344
00345 template <typename T, precision P>
00346 GLM_FUNC_DECL tvec4<T, P> operator/(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00347
00348 template <typename T, precision P>
00349 GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v);
00350
00351 template <typename T, precision P>
00352 GLM_FUNC_DECL bool operator==(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00353
00354 template <typename T, precision P>
00355 GLM_FUNC_DECL bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00356
00357 template <typename T, precision P>
00358 GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v, T const & s);
00359
00360 template <typename T, precision P>
00361 GLM_FUNC_DECL tvec4<T, P> operator%(T const & s, tvec4<T, P> const & v);
00362
00363 template <typename T, precision P>
00364 GLM_FUNC_DECL tvec4<T, P> operator%(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00365
00366 template <typename T, precision P>
00367 GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v, T const & s);
00368
00369 template <typename T, precision P>
00370 GLM_FUNC_DECL tvec4<T, P> operator&(T const & s, tvec4<T, P> const & v);
00371
00372 template <typename T, precision P>
00373 GLM_FUNC_DECL tvec4<T, P> operator&(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00374
00375 template <typename T, precision P>
00376 GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v, T const & s);
00377
00378 template <typename T, precision P>
00379 GLM_FUNC_DECL tvec4<T, P> operator|(T const & s, tvec4<T, P> const & v);
00380
00381 template <typename T, precision P>
00382 GLM_FUNC_DECL tvec4<T, P> operator|(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00383
00384 template <typename T, precision P>
00385 GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v, T const & s);
00386
00387 template <typename T, precision P>
00388 GLM_FUNC_DECL tvec4<T, P> operator^(T const & s, tvec4<T, P> const & v);
00389
00390 template <typename T, precision P>
00391 GLM_FUNC_DECL tvec4<T, P> operator^(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00392
00393 template <typename T, precision P>
00394 GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v, T const & s);
00395
00396 template <typename T, precision P>
00397 GLM_FUNC_DECL tvec4<T, P> operator<<(T const & s, tvec4<T, P> const & v);
00398
00399 template <typename T, precision P>
00400 GLM_FUNC_DECL tvec4<T, P> operator<<(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00401
00402 template <typename T, precision P>
00403 GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v, T const & s);
00404
00405 template <typename T, precision P>
00406 GLM_FUNC_DECL tvec4<T, P> operator>>(T const & s, tvec4<T, P> const & v);
00407
00408 template <typename T, precision P>
00409 GLM_FUNC_DECL tvec4<T, P> operator>>(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
00410
00411 template <typename T, precision P>
00412 GLM_FUNC_DECL tvec4<T, P> operator~(tvec4<T, P> const & v);
00413
00414 }
00415 }
00416
00417 #ifndef GLM_EXTERNAL_TEMPLATE
00418 #include "type_vec4.inl"
00419 #endif//GLM_EXTERNAL_TEMPLATE