Flow Visualisation
type_vec2.hpp
Go to the documentation of this file.
1 
29 #ifndef glm_core_type_gentype2
30 #define glm_core_type_gentype2
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 tvec3;
45  template <typename T> struct tvec4;
46 
47  template <typename T>
48  struct tvec2
49  {
50  enum ctor{null};
51 
52  typedef T value_type;
53  typedef std::size_t size_type;
54  typedef tvec2<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_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g)
68  _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t)
69  _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y)
70  _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g)
71  _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t)
72  _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y)
73  _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g)
74  _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t)
75 # endif//(defined(GLM_SWIZZLE))
76 
77  struct{value_type r, g;};
78  struct{value_type s, t;};
79  struct{value_type x, y;};
80  };
81 # elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
82  union {value_type x, r, s;};
83  union {value_type y, g, t;};
84 
85 # if(defined(GLM_SWIZZLE))
86  // Defines all he swizzle operator as functions
87  GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2)
88  GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
89 # endif//(defined(GLM_SWIZZLE))
90 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
91  value_type x, y;
92 
93 # if(defined(GLM_SWIZZLE))
94  // Defines all he swizzle operator as functions
96  GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4, x, y)
97 # endif//(defined(GLM_SWIZZLE))
98 # endif//GLM_COMPONENT
99 
101  // Accesses
102 
103  GLM_FUNC_DECL value_type & operator[](size_type i);
104  GLM_FUNC_DECL value_type const & operator[](size_type i) const;
105 
107  // Implicit basic constructors
108 
110  GLM_FUNC_DECL tvec2(tvec2<T> const & v);
111 
113  // Explicit basic constructors
114 
115  GLM_FUNC_DECL explicit tvec2(
116  ctor);
117  GLM_FUNC_DECL explicit tvec2(
118  value_type const & s);
119  GLM_FUNC_DECL explicit tvec2(
120  value_type const & s1,
121  value_type const & s2);
122 
124  // Swizzle constructors
125 
126  GLM_FUNC_DECL tvec2(tref2<T> const & r);
127 
128  template <int E0, int E1>
129  GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2<T>,E0,E1,-1,-2>& that)
130  {
131  *this = that();
132  }
133 
135  // Convertion constructors
136 
138  template <typename U>
139  GLM_FUNC_DECL explicit tvec2(
140  U const & x);
142  template <typename U, typename V>
143  GLM_FUNC_DECL explicit tvec2(
144  U const & x,
145  V const & y);
146 
148  // Convertion vector constructors
149 
151  template <typename U>
152  GLM_FUNC_DECL explicit tvec2(tvec2<U> const & v);
154  template <typename U>
155  GLM_FUNC_DECL explicit tvec2(tvec3<U> const & v);
157  template <typename U>
158  GLM_FUNC_DECL explicit tvec2(tvec4<U> const & v);
159 
161  // Unary arithmetic operators
162 
164  template <typename U>
166 
167  template <typename U>
168  GLM_FUNC_DECL tvec2<T> & operator+=(U const & s);
169  template <typename U>
171  template <typename U>
172  GLM_FUNC_DECL tvec2<T> & operator-=(U const & s);
173  template <typename U>
175  template <typename U>
176  GLM_FUNC_DECL tvec2<T> & operator*=(U const & s);
177  template <typename U>
179  template <typename U>
180  GLM_FUNC_DECL tvec2<T> & operator/=(U const & s);
181  template <typename U>
185 
187  // Unary bit operators
188 
189  template <typename U>
190  GLM_FUNC_DECL tvec2<T> & operator%= (U const & s);
191  template <typename U>
193  template <typename U>
194  GLM_FUNC_DECL tvec2<T> & operator&= (U const & s);
195  template <typename U>
197  template <typename U>
198  GLM_FUNC_DECL tvec2<T> & operator|= (U const & s);
199  template <typename U>
201  template <typename U>
202  GLM_FUNC_DECL tvec2<T> & operator^= (U const & s);
203  template <typename U>
205  template <typename U>
206  GLM_FUNC_DECL tvec2<T> & operator<<=(U const & s);
207  template <typename U>
208  GLM_FUNC_DECL tvec2<T> & operator<<=(tvec2<U> const & v);
209  template <typename U>
210  GLM_FUNC_DECL tvec2<T> & operator>>=(U const & s);
211  template <typename U>
213 
215  // Swizzle operators
216 
217  GLM_FUNC_DECL value_type swizzle(comp X) const;
222  };
223 
224  template <typename T>
225  struct tref2
226  {
227  GLM_FUNC_DECL tref2(T & x, T & y);
228  GLM_FUNC_DECL tref2(tref2<T> const & r);
229  GLM_FUNC_DECL explicit tref2(tvec2<T> const & v);
230 
231  GLM_FUNC_DECL tref2<T> & operator= (tref2<T> const & r);
232  GLM_FUNC_DECL tref2<T> & operator= (tvec2<T> const & v);
233 
234  GLM_FUNC_DECL tvec2<T> operator() ();
235 
236  T & x;
237  T & y;
238  };
239 
240  GLM_DETAIL_IS_VECTOR(tvec2);
241 
242 } //namespace detail
243 
246 
253 
260 
267 
274 
281 
288 
295 
302 
309 
311 }//namespace glm
312 
313 #ifndef GLM_EXTERNAL_TEMPLATE
314 #include "type_vec2.inl"
315 #endif//GLM_EXTERNAL_TEMPLATE
316 
317 #endif//glm_core_type_gentype2
Definition: type_vec2.hpp:50
T & y
Definition: type_vec2.hpp:237
GLM_FUNC_DECL tvec2< T > & operator+=(U const &s)
GLM_FUNC_DECL tvec2< T > & operator=(tvec2< T > const &v)
Definition: type_vec2.inl:184
#define GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, CLASS_TYPE, SWIZZLED_TYPE, A, B)
Definition: _swizzle_func.hpp:73
std::size_t size_type
Definition: type_vec2.hpp:53
detail::tvec2< lowp_uint > lowp_uvec2
Definition: type_vec2.hpp:308
GLM_FUNC_DECL tvec2< T > & operator/=(U const &s)
detail::tvec2< highp_int > highp_ivec2
Definition: type_vec2.hpp:273
#define GLM_CONSTEXPR
Definition: _detail.hpp:479
Definition: _swizzle.hpp:204
GLM_FUNC_DECL tvec2< T > & operator&=(U const &s)
#define GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B)
Definition: _swizzle_func.hpp:223
GLM_FUNC_DECL tvec2< T > & operator++()
Definition: type_vec2.inl:302
Definition: _detail.hpp:38
Definition: type_mat2x2.hpp:38
GLM_FUNC_DECL tvec2(const glm::detail::swizzle< 2, T, tvec2< T >, E0, E1,-1,-2 > &that)
Definition: type_vec2.hpp:129
GLM_FUNC_DECL tvec2()
Definition: type_vec2.inl:67
Definition: _swizzle.hpp:43
GLM_FUNC_DECL tvec2< T > & operator*=(U const &s)
detail::tvec2< mediump_uint > mediump_uvec2
Definition: type_vec2.hpp:301
GLM_FUNC_DECL tvec2< T > & operator-=(U const &s)
#define GLM_SWIZZLE_GEN_VEC_FROM_VEC2(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE)
Definition: _swizzle_func.hpp:228
GLM_FUNC_DECL tref2< T > & operator=(tref2< T > const &r)
Definition: type_vec2.inl:1002
detail::tvec2< mediump_float > mediump_vec2
Definition: type_vec2.hpp:259
detail::tvec2< lowp_int > lowp_ivec2
Definition: type_vec2.hpp:287
#define _GLM_SWIZZLE2_2_MEMBERS(T, P, E0, E1)
Definition: _swizzle.hpp:353
GLM_FUNC_DECL tref2(T &x, T &y)
Definition: type_vec2.inl:974
#define _GLM_SWIZZLE2_3_MEMBERS(T, P2, E0, E1)
Definition: _swizzle.hpp:359
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const
Definition: type_vec2.inl:33
GLM_FUNC_DECL tvec2< T > operator()()
Definition: type_vec2.inl:1023
Definition: type_vec1.hpp:42
#define GLM_SWIZZLE_GEN_REF_FROM_VEC2(TMPL_TYPE, CLASS_TYPE, SWIZZLED_VEC2_TYPE)
Definition: _swizzle_func.hpp:77
GLM_FUNC_DECL tvec2< T > & operator<<=(U const &s)
T value_type
Definition: type_vec2.hpp:52
Definition: type_mat2x2.hpp:39
Definition: _swizzle.hpp:44
tvec2< T > type
Definition: type_vec2.hpp:54
GLM_FUNC_DECL tvec2< T > & operator^=(U const &s)
value_type x
Definition: type_vec2.hpp:91
GLM_FUNC_DECL tvec2< T > & operator|=(U const &s)
T & x
Definition: type_vec2.hpp:236
GLM_FUNC_DECL tvec2< T > & operator%=(U const &s)
ctor
Definition: type_vec2.hpp:50
GLM_FUNC_DECL value_type & operator[](size_type i)
Definition: type_vec2.inl:44
Definition: type_mat2x2.hpp:40
value_type y
Definition: type_vec2.hpp:91
GLM_FUNC_DECL tvec2< T > & operator>>=(U const &s)
detail::tvec2< mediump_int > mediump_ivec2
Definition: type_vec2.hpp:280
#define _GLM_SWIZZLE2_4_MEMBERS(T, P2, E0, E1)
Definition: _swizzle.hpp:369
GLM_FUNC_DECL value_type swizzle(comp X) const
Definition: type_vec2.inl:492
tvec2< bool > bool_type
Definition: type_vec2.hpp:55
Definition: _swizzle.hpp:47
detail::tvec2< lowp_float > lowp_vec2
Definition: type_vec2.hpp:266
detail::tvec2< highp_float > highp_vec2
Definition: type_vec2.hpp:252
GLM_DETAIL_IS_VECTOR(tvec1)
comp
Definition: _swizzle.hpp:36
GLM_FUNC_DECL tvec2< T > & operator--()
Definition: type_vec2.inl:310
#define GLM_FUNC_DECL
Definition: setup.hpp:678
Definition: _swizzle.hpp:38
detail::tvec2< highp_uint > highp_uvec2
Definition: type_vec2.hpp:294
Definition: _swizzle.hpp:41