1
///////////////////////////////////////////////////////////////////////////////////
2
/// OpenGL Mathematics (glm.g-truc.net)
4
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6
/// of this software and associated documentation files (the "Software"), to deal
7
/// in the Software without restriction, including without limitation the rights
8
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
/// copies of the Software, and to permit persons to whom the Software is
10
/// furnished to do so, subject to the following conditions:
12
/// The above copyright notice and this permission notice shall be included in
13
/// all copies or substantial portions of the Software.
15
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
/// @file glm/core/type_vec2.hpp
25
/// @date 2008-08-18 / 2011-06-15
26
/// @author Christophe Riccio
27
///////////////////////////////////////////////////////////////////////////////////
29
#ifndef glm_core_type_gentype2
30
#define glm_core_type_gentype2
32
#include "type_vec.hpp"
33
#include "type_float.hpp"
34
#include "type_int.hpp"
35
#include "type_size.hpp"
36
#include "_swizzle.hpp"
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;
47
// The basic 2D vector type.
48
// \ingroup core_template
55
typedef std::size_t size_type;
56
GLM_FUNC_DECL size_type length() const;
58
typedef tvec2<T> type;
59
typedef tvec2<bool> bool_type;
61
//////////////////////////////////////
64
# if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
67
# if(defined(GLM_SWIZZLE))
68
_GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y)
69
_GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g)
70
_GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t)
71
_GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y)
72
_GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g)
73
_GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t)
74
_GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y)
75
_GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g)
76
_GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t)
77
# endif//(defined(GLM_SWIZZLE))
79
struct{value_type r, g;};
80
struct{value_type s, t;};
81
struct{value_type x, y;};
83
# elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
84
union {value_type x, r, s;};
85
union {value_type y, g, t;};
87
# if(defined(GLM_SWIZZLE))
88
// Defines all he swizzle operator as functions
89
GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2)
90
GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
91
# endif//(defined(GLM_SWIZZLE))
92
# else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
95
# if(defined(GLM_SWIZZLE))
96
// Defines all he swizzle operator as functions
97
GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(value_type, detail::tvec2, detail::tref2, x, y)
98
GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4, x, y)
99
# endif//(defined(GLM_SWIZZLE))
100
# endif//GLM_COMPONENT
102
//////////////////////////////////////
105
GLM_FUNC_DECL value_type & operator[](size_type i);
106
GLM_FUNC_DECL value_type const & operator[](size_type i) const;
108
//////////////////////////////////////
109
// Implicit basic constructors
111
GLM_FUNC_DECL tvec2();
112
GLM_FUNC_DECL tvec2(tvec2<T> const & v);
114
//////////////////////////////////////
115
// Explicit basic constructors
117
GLM_FUNC_DECL explicit tvec2(
119
GLM_FUNC_DECL explicit tvec2(
120
value_type const & s);
121
GLM_FUNC_DECL explicit tvec2(
122
value_type const & s1,
123
value_type const & s2);
125
//////////////////////////////////////
126
// Swizzle constructors
128
tvec2(tref2<T> const & r);
130
template <int E0, int E1>
131
GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2<T>,E0,E1,-1,-2>& that)
136
//////////////////////////////////////
137
// Convertion constructors
139
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
140
template <typename U>
141
GLM_FUNC_DECL explicit tvec2(
143
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
144
template <typename U, typename V>
145
GLM_FUNC_DECL explicit tvec2(
149
//////////////////////////////////////
150
// Convertion vector constructors
152
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
153
template <typename U>
154
GLM_FUNC_DECL explicit tvec2(tvec2<U> const & v);
155
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
156
template <typename U>
157
GLM_FUNC_DECL explicit tvec2(tvec3<U> const & v);
158
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
159
template <typename U>
160
GLM_FUNC_DECL explicit tvec2(tvec4<U> const & v);
162
//////////////////////////////////////
163
// Unary arithmetic operators
165
GLM_FUNC_DECL tvec2<T> & operator= (tvec2<T> const & v);
166
template <typename U>
167
GLM_FUNC_DECL tvec2<T> & operator= (tvec2<U> const & v);
169
template <typename U>
170
GLM_FUNC_DECL tvec2<T> & operator+=(U const & s);
171
template <typename U>
172
GLM_FUNC_DECL tvec2<T> & operator+=(tvec2<U> const & v);
173
template <typename U>
174
GLM_FUNC_DECL tvec2<T> & operator-=(U const & s);
175
template <typename U>
176
GLM_FUNC_DECL tvec2<T> & operator-=(tvec2<U> const & v);
177
template <typename U>
178
GLM_FUNC_DECL tvec2<T> & operator*=(U const & s);
179
template <typename U>
180
GLM_FUNC_DECL tvec2<T> & operator*=(tvec2<U> const & v);
181
template <typename U>
182
GLM_FUNC_DECL tvec2<T> & operator/=(U const & s);
183
template <typename U>
184
GLM_FUNC_DECL tvec2<T> & operator/=(tvec2<U> const & v);
185
GLM_FUNC_DECL tvec2<T> & operator++();
186
GLM_FUNC_DECL tvec2<T> & operator--();
188
//////////////////////////////////////
189
// Unary bit operators
191
template <typename U>
192
GLM_FUNC_DECL tvec2<T> & operator%= (U const & s);
193
template <typename U>
194
GLM_FUNC_DECL tvec2<T> & operator%= (tvec2<U> const & v);
195
template <typename U>
196
GLM_FUNC_DECL tvec2<T> & operator&= (U const & s);
197
template <typename U>
198
GLM_FUNC_DECL tvec2<T> & operator&= (tvec2<U> const & v);
199
template <typename U>
200
GLM_FUNC_DECL tvec2<T> & operator|= (U const & s);
201
template <typename U>
202
GLM_FUNC_DECL tvec2<T> & operator|= (tvec2<U> const & v);
203
template <typename U>
204
GLM_FUNC_DECL tvec2<T> & operator^= (U const & s);
205
template <typename U>
206
GLM_FUNC_DECL tvec2<T> & operator^= (tvec2<U> const & v);
207
template <typename U>
208
GLM_FUNC_DECL tvec2<T> & operator<<=(U const & s);
209
template <typename U>
210
GLM_FUNC_DECL tvec2<T> & operator<<=(tvec2<U> const & v);
211
template <typename U>
212
GLM_FUNC_DECL tvec2<T> & operator>>=(U const & s);
213
template <typename U>
214
GLM_FUNC_DECL tvec2<T> & operator>>=(tvec2<U> const & v);
216
//////////////////////////////////////
219
GLM_FUNC_DECL value_type swizzle(comp X) const;
220
GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
221
GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
222
GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
223
GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
226
template <typename T>
229
GLM_FUNC_DECL tref2(T & x, T & y);
230
GLM_FUNC_DECL tref2(tref2<T> const & r);
231
GLM_FUNC_DECL explicit tref2(tvec2<T> const & v);
233
GLM_FUNC_DECL tref2<T> & operator= (tref2<T> const & r);
234
GLM_FUNC_DECL tref2<T> & operator= (tvec2<T> const & v);
236
GLM_FUNC_DECL tvec2<T> operator() ();
242
GLM_DETAIL_IS_VECTOR(tvec2);
246
/// @addtogroup core_precision
249
/// 2 components vector of high precision floating-point numbers.
250
/// There is no guarantee on the actual precision.
252
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
253
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
254
typedef detail::tvec2<highp_float> highp_vec2;
256
/// 2 components vector of medium precision floating-point numbers.
257
/// There is no guarantee on the actual precision.
259
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
260
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
261
typedef detail::tvec2<mediump_float> mediump_vec2;
263
/// 2 components vector of low precision floating-point numbers.
264
/// There is no guarantee on the actual precision.
266
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
267
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
268
typedef detail::tvec2<lowp_float> lowp_vec2;
270
/// 2 components vector of high precision signed integer numbers.
271
/// There is no guarantee on the actual precision.
273
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
274
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
275
typedef detail::tvec2<highp_int> highp_ivec2;
277
/// 2 components vector of medium precision signed integer numbers.
278
/// There is no guarantee on the actual precision.
280
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
281
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
282
typedef detail::tvec2<mediump_int> mediump_ivec2;
284
/// 2 components vector of low precision signed integer numbers.
285
/// There is no guarantee on the actual precision.
287
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
288
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
289
typedef detail::tvec2<lowp_int> lowp_ivec2;
291
/// 2 components vector of high precision unsigned integer numbers.
292
/// There is no guarantee on the actual precision.
294
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
295
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
296
typedef detail::tvec2<highp_uint> highp_uvec2;
298
/// 2 components vector of medium precision unsigned integer numbers.
299
/// There is no guarantee on the actual precision.
301
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
302
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
303
typedef detail::tvec2<mediump_uint> mediump_uvec2;
305
/// 2 components vector of low precision unsigned integer numbers.
306
/// There is no guarantee on the actual precision.
308
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
309
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
310
typedef detail::tvec2<lowp_uint> lowp_uvec2;
315
#ifndef GLM_EXTERNAL_TEMPLATE
316
#include "type_vec2.inl"
317
#endif//GLM_EXTERNAL_TEMPLATE
319
#endif//glm_core_type_gentype2