Flow Visualisation
type_vec4.hpp
Go to the documentation of this file.
1 
29 #ifndef glm_core_type_gentype4
30 #define glm_core_type_gentype4
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 tvec3;
46 
47  template <typename T>
48  struct tvec4
49  {
50  enum ctor{null};
51 
52  typedef T value_type;
53  typedef std::size_t size_type;
54  typedef tvec4<T> 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))
67  _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b, a)
68  _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p, q)
69  _GLM_SWIZZLE4_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y, z, w)
70  _GLM_SWIZZLE4_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g, b, a)
71  _GLM_SWIZZLE4_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t, p, q)
72  _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z, w)
73  _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b, a)
74  _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p, q)
75 # endif//(defined(GLM_SWIZZLE))
76 
77  struct{value_type r, g, b, a;};
78  struct{value_type s, t, p, q;};
79  struct{value_type x, y, z, w;};
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  union {value_type w, a, q;};
86 
87 # if(defined(GLM_SWIZZLE))
88  // Defines all he swizzle operator as functions
89  GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, detail::tvec4, detail::tref2, detail::tref3, detail::tref4)
90  GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4)
91 # endif//(defined(GLM_SWIZZLE))
92 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
93  value_type x, y, z, w;
94 
95 # if(defined(GLM_SWIZZLE))
96  // Defines all he swizzle operator as functions
98  GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z, w)
99 # endif//(defined(GLM_SWIZZLE))
100 # endif//GLM_COMPONENT
101 
103  // Accesses
104 
105  GLM_FUNC_DECL value_type & operator[](size_type i);
106  GLM_FUNC_DECL value_type const & operator[](size_type i) const;
107 
109  // Implicit basic constructors
110 
112  GLM_FUNC_DECL tvec4(type const & v);
113 
115  // Explicit basic constructors
116 
117  GLM_FUNC_DECL explicit tvec4(
118  ctor);
119  GLM_FUNC_DECL explicit tvec4(
120  value_type const & s);
121  GLM_FUNC_DECL explicit tvec4(
122  value_type const & s0,
123  value_type const & s1,
124  value_type const & s2,
125  value_type const & s3);
126 
128  // Convertion scalar constructors
129 
131  template <typename U>
132  GLM_FUNC_DECL explicit tvec4(
133  U const & x);
135  template <typename A, typename B, typename C, typename D>
136  GLM_FUNC_DECL explicit tvec4(
137  A const & x,
138  B const & y,
139  C const & z,
140  D const & w);
141 
143  // Convertion vector constructors
144 
146  template <typename A, typename B, typename C>
147  GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
149  template <typename A, typename B, typename C>
150  GLM_FUNC_DECL explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
152  template <typename A, typename B, typename C>
153  GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
155  template <typename A, typename B>
156  GLM_FUNC_DECL explicit tvec4(tvec3<A> const & v, B const & s);
158  template <typename A, typename B>
159  GLM_FUNC_DECL explicit tvec4(A const & s, tvec3<B> const & v);
161  template <typename A, typename B>
162  GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
164  template <typename U>
165  GLM_FUNC_DECL explicit tvec4(tvec4<U> const & v);
166 
167  template <int E0, int E1, int E2, int E3>
168  GLM_FUNC_DECL tvec4(glm::detail::swizzle<4, T, tvec4<T>, E0, E1, E2, E3> const & that)
169  {
170  *this = that();
171  }
172 
173  template <int E0, int E1, int F0, int F1>
174  GLM_FUNC_DECL tvec4(glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, glm::detail::swizzle<2, T, tvec2<T>, F0, F1, -1, -2> const & u)
175  {
176  *this = tvec4<T>(v(), u());
177  }
178 
179  template <int E0, int E1>
180  GLM_FUNC_DECL tvec4(T const & x, T const & y, glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v)
181  {
182  *this = tvec4<T>(x, y, v());
183  }
184 
185  template <int E0, int E1>
186  GLM_FUNC_DECL tvec4(T const & x, glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, T const & w)
187  {
188  *this = tvec4<T>(x, v(), w);
189  }
190 
191  template <int E0, int E1>
192  GLM_FUNC_DECL tvec4(glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, T const & z, T const & w)
193  {
194  *this = tvec4<T>(v(), z, w);
195  }
196 
197  template <int E0, int E1, int E2>
198  GLM_FUNC_DECL tvec4(glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & v, T const & w)
199  {
200  *this = tvec4<T>(v(), w);
201  }
202 
203  template <int E0, int E1, int E2>
204  GLM_FUNC_DECL tvec4(T const & x, glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & v)
205  {
206  *this = tvec4<T>(x, v());
207  }
208 
210  // Swizzle constructors
211 
212  GLM_FUNC_DECL tvec4(tref4<T> const & r);
213 
215  template <typename A, typename B, typename C>
216  GLM_FUNC_DECL explicit tvec4(tref2<A> const & v, B const & s1, C const & s2);
218  template <typename A, typename B, typename C>
219  GLM_FUNC_DECL explicit tvec4(A const & s1, tref2<B> const & v, C const & s2);
221  template <typename A, typename B, typename C>
222  GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tref2<C> const & v);
224  template <typename A, typename B>
225  GLM_FUNC_DECL explicit tvec4(tref3<A> const & v, B const & s);
227  template <typename A, typename B>
228  GLM_FUNC_DECL explicit tvec4(A const & s, tref3<B> const & v);
230  template <typename A, typename B>
231  GLM_FUNC_DECL explicit tvec4(tref2<A> const & v1, tref2<B> const & v2);
233  template <typename A, typename B>
234  GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v1, tref2<B> const & v2);
236  template <typename A, typename B>
237  GLM_FUNC_DECL explicit tvec4(tref2<A> const & v1, tvec2<B> const & v2);
238 
240  // Unary arithmetic operators
241 
243  template <typename U>
245 
246  template <typename U>
247  GLM_FUNC_DECL tvec4<T> & operator+=(U const & s);
248  template <typename U>
250  template <typename U>
251  GLM_FUNC_DECL tvec4<T> & operator-=(U const & s);
252  template <typename U>
254  template <typename U>
255  GLM_FUNC_DECL tvec4<T> & operator*=(U const & s);
256  template <typename U>
258  template <typename U>
259  GLM_FUNC_DECL tvec4<T> & operator/=(U const & s);
260  template <typename U>
264 
266  // Unary bit operators
267 
268  template <typename U>
269  GLM_FUNC_DECL tvec4<T> & operator%= (U const & s);
270  template <typename U>
272  template <typename U>
273  GLM_FUNC_DECL tvec4<T> & operator&= (U const & s);
274  template <typename U>
276  template <typename U>
277  GLM_FUNC_DECL tvec4<T> & operator|= (U const & s);
278  template <typename U>
280  template <typename U>
281  GLM_FUNC_DECL tvec4<T> & operator^= (U const & s);
282  template <typename U>
284  template <typename U>
285  GLM_FUNC_DECL tvec4<T> & operator<<=(U const & s);
286  template <typename U>
287  GLM_FUNC_DECL tvec4<T> & operator<<=(tvec4<U> const & v);
288  template <typename U>
289  GLM_FUNC_DECL tvec4<T> & operator>>=(U const & s);
290  template <typename U>
292 
294  // Swizzle operators
295 
296  GLM_FUNC_DECL value_type swizzle(comp X) const;
303  };
304 
305  template <typename T>
306  struct tref4
307  {
308  GLM_FUNC_DECL tref4(T & x, T & y, T & z, T & w);
309  GLM_FUNC_DECL tref4(tref4<T> const & r);
310  GLM_FUNC_DECL explicit tref4(tvec4<T> const & v);
311 
312  GLM_FUNC_DECL tref4<T> & operator= (tref4<T> const & r);
313  GLM_FUNC_DECL tref4<T> & operator= (tvec4<T> const & v);
314 
315  GLM_FUNC_DECL tvec4<T> operator() ();
316 
317  T & x;
318  T & y;
319  T & z;
320  T & w;
321  };
322 
323  GLM_DETAIL_IS_VECTOR(tvec4);
324 }//namespace detail
325 
328 
335 
342 
349 
356 
363 
370 
377 
384 
391 
393 }//namespace glm
394 
395 #ifndef GLM_EXTERNAL_TEMPLATE
396 #include "type_vec4.inl"
397 #endif//GLM_EXTERNAL_TEMPLATE
398 
399 #endif//glm_core_type_gentype4
detail::tvec4< lowp_float > lowp_vec4
Definition: type_vec4.hpp:348
#define GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D)
Definition: _swizzle_func.hpp:177
tvec4< T > type
Definition: type_vec4.hpp:54
GLM_FUNC_DECL tvec4(T const &x, glm::detail::swizzle< 3, T, tvec3< T >, E0, E1, E2,-1 > const &v)
Definition: type_vec4.hpp:204
detail::tvec4< highp_float > highp_vec4
Definition: type_vec4.hpp:334
GLM_FUNC_DECL tvec4(glm::detail::swizzle< 2, T, tvec2< T >, E0, E1,-1,-2 > const &v, T const &z, T const &w)
Definition: type_vec4.hpp:192
#define GLM_CONSTEXPR
Definition: _detail.hpp:479
Definition: _swizzle.hpp:204
value_type z
Definition: type_vec4.hpp:93
GLM_FUNC_DECL tvec4< T > & operator+=(U const &s)
tvec4< bool > bool_type
Definition: type_vec4.hpp:55
Definition: _detail.hpp:38
detail::tvec4< lowp_uint > lowp_uvec4
Definition: type_vec4.hpp:390
GLM_FUNC_DECL tvec4< T > & operator++()
Definition: type_vec4.inl:510
Definition: type_mat2x2.hpp:38
GLM_FUNC_DECL tvec4< T > & operator<<=(U const &s)
GLM_FUNC_DECL value_type swizzle(comp X) const
Definition: type_vec4.inl:706
detail::tvec4< lowp_int > lowp_ivec4
Definition: type_vec4.hpp:369
Definition: _swizzle.hpp:43
detail::tvec4< mediump_uint > mediump_uvec4
Definition: type_vec4.hpp:383
GLM_FUNC_DECL tvec4()
Definition: type_vec4.inl:67
value_type y
Definition: type_vec4.hpp:93
GLM_FUNC_DECL tvec4(glm::detail::swizzle< 2, T, tvec2< T >, E0, E1,-1,-2 > const &v, glm::detail::swizzle< 2, T, tvec2< T >, F0, F1,-1,-2 > const &u)
Definition: type_vec4.hpp:174
GLM_FUNC_DECL tvec4(glm::detail::swizzle< 3, T, tvec3< T >, E0, E1, E2,-1 > const &v, T const &w)
Definition: type_vec4.hpp:198
#define GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D)
Definition: _swizzle_func.hpp:775
detail::tvec4< mediump_int > mediump_ivec4
Definition: type_vec4.hpp:362
Definition: type_vec4.hpp:50
#define GLM_SWIZZLE_GEN_REF_FROM_VEC4(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE)
Definition: _swizzle_func.hpp:182
GLM_FUNC_DECL tvec4(T const &x, glm::detail::swizzle< 2, T, tvec2< T >, E0, E1,-1,-2 > const &v, T const &w)
Definition: type_vec4.hpp:186
value_type w
Definition: type_vec4.hpp:93
GLM_FUNC_DECL tvec4(glm::detail::swizzle< 4, T, tvec4< T >, E0, E1, E2, E3 > const &that)
Definition: type_vec4.hpp:168
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const
Definition: type_vec4.inl:33
T & y
Definition: type_vec4.hpp:318
T value_type
Definition: type_vec4.hpp:52
Definition: _swizzle.hpp:45
GLM_FUNC_DECL tvec4< T > & operator&=(U const &s)
ctor
Definition: type_vec4.hpp:50
Definition: type_vec1.hpp:42
T & x
Definition: type_vec4.hpp:317
T & w
Definition: type_vec4.hpp:320
Definition: type_mat2x2.hpp:39
Definition: _swizzle.hpp:44
#define _GLM_SWIZZLE4_4_MEMBERS(T, P, E0, E1, E2, E3)
Definition: _swizzle.hpp:594
#define GLM_SWIZZLE_GEN_VEC_FROM_VEC4(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE)
Definition: _swizzle_func.hpp:780
detail::tvec4< highp_int > highp_ivec4
Definition: type_vec4.hpp:355
GLM_FUNC_DECL tref4< T > & operator=(tref4< T > const &r)
Definition: type_vec4.inl:1347
GLM_FUNC_DECL value_type & operator[](size_type i)
Definition: type_vec4.inl:44
GLM_FUNC_DECL tvec4< T > operator()()
Definition: type_vec4.inl:1372
GLM_FUNC_DECL tvec4< T > & operator/=(U const &s)
GLM_FUNC_DECL tvec4< T > & operator^=(U const &s)
T & z
Definition: type_vec4.hpp:319
#define _GLM_SWIZZLE4_2_MEMBERS(T, P, E0, E1, E2, E3)
Definition: _swizzle.hpp:510
Definition: _swizzle.hpp:48
GLM_FUNC_DECL tvec4< T > & operator=(tvec4< T > const &v)
Definition: type_vec4.inl:372
GLM_FUNC_DECL tvec4< T > & operator*=(U const &s)
Definition: type_mat2x2.hpp:40
detail::tvec4< mediump_float > mediump_vec4
Definition: type_vec4.hpp:341
Definition: type_vec1.hpp:43
GLM_FUNC_DECL tref4(T &x, T &y, T &z, T &w)
Definition: type_vec4.inl:1311
GLM_FUNC_DECL tvec4< T > & operator%=(U const &s)
value_type x
Definition: type_vec4.hpp:93
Definition: _swizzle.hpp:47
GLM_FUNC_DECL tvec4< T > & operator|=(U const &s)
GLM_FUNC_DECL tvec4< T > & operator--()
Definition: type_vec4.inl:520
detail::tvec4< highp_uint > highp_uvec4
Definition: type_vec4.hpp:376
GLM_FUNC_DECL tvec4(T const &x, T const &y, glm::detail::swizzle< 2, T, tvec2< T >, E0, E1,-1,-2 > const &v)
Definition: type_vec4.hpp:180
GLM_FUNC_DECL tvec4< T > & operator>>=(U const &s)
#define _GLM_SWIZZLE4_3_MEMBERS(T, P, E0, E1, E2, E3)
Definition: _swizzle.hpp:528
GLM_DETAIL_IS_VECTOR(tvec1)
comp
Definition: _swizzle.hpp:36
#define GLM_FUNC_DECL
Definition: setup.hpp:678
Definition: _swizzle.hpp:38
GLM_FUNC_DECL tvec4< T > & operator-=(U const &s)
Definition: _swizzle.hpp:41
std::size_t size_type
Definition: type_vec4.hpp:53
Definition: type_vec1.hpp:44