~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/core/type_vec2.hpp

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////////////
2
 
/// OpenGL Mathematics (glm.g-truc.net)
3
 
///
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:
11
 
/// 
12
 
/// The above copyright notice and this permission notice shall be included in
13
 
/// all copies or substantial portions of the Software.
14
 
/// 
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
21
 
/// THE SOFTWARE.
22
 
///
23
 
/// @ref core
24
 
/// @file glm/core/type_vec2.hpp
25
 
/// @date 2008-08-18 / 2011-06-15
26
 
/// @author Christophe Riccio
27
 
///////////////////////////////////////////////////////////////////////////////////
28
 
 
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
 
        // The basic 2D vector type.
48
 
        // \ingroup core_template
49
 
        template <typename T>
50
 
        struct tvec2
51
 
        {
52
 
                enum ctor{null};
53
 
 
54
 
                typedef T value_type;
55
 
                typedef std::size_t size_type;
56
 
                GLM_FUNC_DECL size_type length() const;
57
 
 
58
 
                typedef tvec2<T> type;
59
 
                typedef tvec2<bool> bool_type;
60
 
 
61
 
                //////////////////////////////////////
62
 
                // Data
63
 
 
64
 
#       if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
65
 
                union 
66
 
                {
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))
78
 
 
79
 
                        struct{value_type r, g;};
80
 
                        struct{value_type s, t;};
81
 
                        struct{value_type x, y;};
82
 
                };
83
 
#       elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
84
 
                union {value_type x, r, s;};
85
 
                union {value_type y, g, t;};
86
 
 
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)
93
 
                value_type x, y;
94
 
 
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
101
 
 
102
 
                //////////////////////////////////////
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
 
 
108
 
                //////////////////////////////////////
109
 
                // Implicit basic constructors
110
 
 
111
 
                GLM_FUNC_DECL tvec2();
112
 
                GLM_FUNC_DECL tvec2(tvec2<T> const & v);
113
 
 
114
 
                //////////////////////////////////////
115
 
                // Explicit basic constructors
116
 
 
117
 
                GLM_FUNC_DECL explicit tvec2(
118
 
                        ctor);
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);
124
 
 
125
 
                //////////////////////////////////////
126
 
                // Swizzle constructors
127
 
 
128
 
                tvec2(tref2<T> const & r);
129
 
 
130
 
        template <int E0, int E1>
131
 
        GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2<T>,E0,E1,-1,-2>& that)
132
 
        {
133
 
            *this = that();
134
 
        }
135
 
 
136
 
                //////////////////////////////////////
137
 
                // Convertion constructors
138
 
 
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(
142
 
                        U const & x);
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(
146
 
                        U const & x, 
147
 
                        V const & y);
148
 
 
149
 
                //////////////////////////////////////
150
 
                // Convertion vector constructors
151
 
 
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);
161
 
 
162
 
                //////////////////////////////////////
163
 
                // Unary arithmetic operators
164
 
 
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);
168
 
 
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--();
187
 
 
188
 
                //////////////////////////////////////
189
 
                // Unary bit operators
190
 
 
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);
215
 
 
216
 
                //////////////////////////////////////
217
 
                // Swizzle operators
218
 
 
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);
224
 
        };
225
 
 
226
 
        template <typename T>
227
 
        struct tref2
228
 
        {
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);
232
 
 
233
 
                GLM_FUNC_DECL tref2<T> & operator= (tref2<T> const & r);
234
 
                GLM_FUNC_DECL tref2<T> & operator= (tvec2<T> const & v);
235
 
 
236
 
                GLM_FUNC_DECL tvec2<T> operator() ();
237
 
 
238
 
                T & x;
239
 
                T & y;
240
 
        };
241
 
 
242
 
        GLM_DETAIL_IS_VECTOR(tvec2);
243
 
 
244
 
} //namespace detail
245
 
 
246
 
        /// @addtogroup core_precision
247
 
        /// @{
248
 
 
249
 
        /// 2 components vector of high precision floating-point numbers. 
250
 
        /// There is no guarantee on the actual precision.
251
 
        /// 
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;
255
 
 
256
 
        /// 2 components vector of medium precision floating-point numbers. 
257
 
        /// There is no guarantee on the actual precision.
258
 
        /// 
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;
262
 
 
263
 
        /// 2 components vector of low precision floating-point numbers. 
264
 
        /// There is no guarantee on the actual precision.
265
 
        /// 
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;
269
 
 
270
 
        /// 2 components vector of high precision signed integer numbers. 
271
 
        /// There is no guarantee on the actual precision.
272
 
        /// 
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;
276
 
 
277
 
        /// 2 components vector of medium precision signed integer numbers. 
278
 
        /// There is no guarantee on the actual precision.
279
 
        /// 
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;
283
 
 
284
 
        /// 2 components vector of low precision signed integer numbers.
285
 
        /// There is no guarantee on the actual precision.
286
 
        /// 
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;
290
 
        
291
 
        /// 2 components vector of high precision unsigned integer numbers. 
292
 
        /// There is no guarantee on the actual precision.
293
 
        /// 
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;
297
 
 
298
 
        /// 2 components vector of medium precision unsigned integer numbers. 
299
 
        /// There is no guarantee on the actual precision.
300
 
        /// 
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;
304
 
 
305
 
        /// 2 components vector of low precision unsigned integer numbers.
306
 
        /// There is no guarantee on the actual precision.
307
 
        /// 
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;
311
 
 
312
 
        /// @}
313
 
}//namespace glm
314
 
 
315
 
#ifndef GLM_EXTERNAL_TEMPLATE
316
 
#include "type_vec2.inl"
317
 
#endif//GLM_EXTERNAL_TEMPLATE
318
 
 
319
 
#endif//glm_core_type_gentype2