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

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/gtc/half_float.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 gtc_half_float
24
 
/// @file glm/gtc/half_float.hpp
25
 
/// @date 2009-04-29 / 2011-06-05
26
 
/// @author Christophe Riccio
27
 
///
28
 
/// @see core (dependence)
29
 
///
30
 
/// @defgroup gtc_half_float GLM_GTC_half_float: Half-precision floating-point based types and functions
31
 
/// @ingroup gtc
32
 
/// 
33
 
/// Defines the half-precision floating-point type, along with various typedefs for vectors and matrices.
34
 
/// <glm/gtc/half_float.hpp> need to be included to use these functionalities.
35
 
///////////////////////////////////////////////////////////////////////////////////
36
 
 
37
 
#ifndef GLM_GTC_half_float
38
 
#define GLM_GTC_half_float GLM_VERSION
39
 
 
40
 
// Dependency:
41
 
#include "../glm.hpp"
42
 
 
43
 
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
44
 
#       pragma message("GLM: GLM_GTC_half_float extension included")
45
 
#endif
46
 
 
47
 
namespace glm{
48
 
namespace detail
49
 
{
50
 
#if(GLM_COMPONENT == GLM_COMPONENT_CXX98)
51
 
        template <>
52
 
        struct tvec2<half>
53
 
        {
54
 
                enum ctor{null};
55
 
                typedef half value_type;
56
 
                typedef std::size_t size_type;
57
 
 
58
 
        GLM_FUNC_DECL size_type length() const;
59
 
                static GLM_FUNC_DECL size_type value_size();
60
 
 
61
 
                typedef tvec2<half> type;
62
 
                typedef tvec2<bool> bool_type;
63
 
 
64
 
                //////////////////////////////////////
65
 
                // Data
66
 
 
67
 
                half x, y;
68
 
 
69
 
                //////////////////////////////////////
70
 
                // Accesses
71
 
 
72
 
                half & operator[](size_type i);
73
 
                half const & operator[](size_type i) const;
74
 
 
75
 
                //////////////////////////////////////
76
 
                // Implicit basic constructors
77
 
 
78
 
                tvec2();
79
 
                tvec2(tvec2<half> const & v);
80
 
 
81
 
                //////////////////////////////////////
82
 
                // Explicit basic constructors
83
 
 
84
 
                explicit tvec2(ctor);
85
 
                explicit tvec2(
86
 
                        half const & s);
87
 
                explicit tvec2(
88
 
                        half const & s1, 
89
 
                        half const & s2);
90
 
 
91
 
                //////////////////////////////////////
92
 
                // Swizzle constructors
93
 
 
94
 
                tvec2(tref2<half> const & r);
95
 
 
96
 
                //////////////////////////////////////
97
 
                // Convertion scalar constructors
98
 
 
99
 
                //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
100
 
                template <typename U> 
101
 
                explicit tvec2(U const & x);
102
 
                //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
103
 
                template <typename U, typename V> 
104
 
                explicit tvec2(U const & x, V const & y);                       
105
 
 
106
 
                //////////////////////////////////////
107
 
                // Convertion vector constructors
108
 
 
109
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
110
 
                template <typename U> 
111
 
                explicit tvec2(tvec2<U> const & v);
112
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
113
 
                template <typename U> 
114
 
                explicit tvec2(tvec3<U> const & v);
115
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
116
 
                template <typename U> 
117
 
                explicit tvec2(tvec4<U> const & v);
118
 
 
119
 
                //////////////////////////////////////
120
 
                // Unary arithmetic operators
121
 
 
122
 
                tvec2<half>& operator= (tvec2<half> const & v);
123
 
 
124
 
                tvec2<half>& operator+=(half const & s);
125
 
                tvec2<half>& operator+=(tvec2<half> const & v);
126
 
                tvec2<half>& operator-=(half const & s);
127
 
                tvec2<half>& operator-=(tvec2<half> const & v);
128
 
                tvec2<half>& operator*=(half const & s);
129
 
                tvec2<half>& operator*=(tvec2<half> const & v);
130
 
                tvec2<half>& operator/=(half const & s);
131
 
                tvec2<half>& operator/=(tvec2<half> const & v);
132
 
                tvec2<half>& operator++();
133
 
                tvec2<half>& operator--();
134
 
 
135
 
                //////////////////////////////////////
136
 
                // Swizzle operators
137
 
 
138
 
                half swizzle(comp X) const;
139
 
                tvec2<half> swizzle(comp X, comp Y) const;
140
 
                tvec3<half> swizzle(comp X, comp Y, comp Z) const;
141
 
                tvec4<half> swizzle(comp X, comp Y, comp Z, comp W) const;
142
 
                tref2<half> swizzle(comp X, comp Y);
143
 
        };
144
 
 
145
 
        template <>
146
 
        struct tvec3<half>
147
 
        {
148
 
                enum ctor{null};
149
 
                typedef half value_type;
150
 
                typedef std::size_t size_type;
151
 
        GLM_FUNC_DECL size_type length() const;
152
 
                static GLM_FUNC_DECL size_type value_size();
153
 
 
154
 
                typedef tvec3<half> type;
155
 
                typedef tvec3<bool> bool_type;
156
 
 
157
 
                //////////////////////////////////////
158
 
                // Data
159
 
 
160
 
                half x, y, z;
161
 
 
162
 
                //////////////////////////////////////
163
 
                // Accesses
164
 
 
165
 
                half & operator[](size_type i);
166
 
                half const & operator[](size_type i) const;
167
 
 
168
 
                //////////////////////////////////////
169
 
                // Implicit basic constructors
170
 
 
171
 
                tvec3();
172
 
                tvec3(tvec3<half> const & v);
173
 
 
174
 
                //////////////////////////////////////
175
 
                // Explicit basic constructors
176
 
 
177
 
                explicit tvec3(ctor);
178
 
                explicit tvec3(
179
 
                        half const & s);
180
 
                explicit tvec3(
181
 
                        half const & s1, 
182
 
                        half const & s2, 
183
 
                        half const & s3);
184
 
 
185
 
                //////////////////////////////////////
186
 
                // Swizzle constructors
187
 
 
188
 
                tvec3(tref3<half> const & r);
189
 
 
190
 
                //////////////////////////////////////
191
 
                // Convertion scalar constructors
192
 
 
193
 
                //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
194
 
                template <typename U> 
195
 
                explicit tvec3(U const & x);
196
 
                //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
197
 
                template <typename U, typename V, typename W> 
198
 
                explicit tvec3(U const & x, V const & y, W const & z);                  
199
 
 
200
 
                //////////////////////////////////////
201
 
                // Convertion vector constructors
202
 
 
203
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
204
 
                template <typename A, typename B> 
205
 
                explicit tvec3(tvec2<A> const & v, B const & s);
206
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
207
 
                template <typename A, typename B> 
208
 
                explicit tvec3(A const & s, tvec2<B> const & v);
209
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
210
 
                template <typename U> 
211
 
                explicit tvec3(tvec3<U> const & v);
212
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
213
 
                template <typename U> 
214
 
                explicit tvec3(tvec4<U> const & v);
215
 
 
216
 
                //////////////////////////////////////
217
 
                // Unary arithmetic operators
218
 
 
219
 
                tvec3<half>& operator= (tvec3<half> const & v);
220
 
 
221
 
                tvec3<half>& operator+=(half const & s);
222
 
                tvec3<half>& operator+=(tvec3<half> const & v);
223
 
                tvec3<half>& operator-=(half const & s);
224
 
                tvec3<half>& operator-=(tvec3<half> const & v);
225
 
                tvec3<half>& operator*=(half const & s);
226
 
                tvec3<half>& operator*=(tvec3<half> const & v);
227
 
                tvec3<half>& operator/=(half const & s);
228
 
                tvec3<half>& operator/=(tvec3<half> const & v);
229
 
                tvec3<half>& operator++();
230
 
                tvec3<half>& operator--();
231
 
 
232
 
                //////////////////////////////////////
233
 
                // Swizzle operators
234
 
 
235
 
                half swizzle(comp X) const;
236
 
                tvec2<half> swizzle(comp X, comp Y) const;
237
 
                tvec3<half> swizzle(comp X, comp Y, comp Z) const;
238
 
                tvec4<half> swizzle(comp X, comp Y, comp Z, comp W) const;
239
 
                tref3<half> swizzle(comp X, comp Y, comp Z);
240
 
        };
241
 
 
242
 
        template <>
243
 
        struct tvec4<half>
244
 
        {
245
 
                enum ctor{null};
246
 
                typedef half value_type;
247
 
                typedef std::size_t size_type;
248
 
        GLM_FUNC_DECL size_type length() const;
249
 
                static GLM_FUNC_DECL size_type value_size();
250
 
 
251
 
                typedef tvec4<half> type;
252
 
                typedef tvec4<bool> bool_type;
253
 
 
254
 
                //////////////////////////////////////
255
 
                // Data
256
 
 
257
 
                half x, y, z, w;
258
 
 
259
 
                //////////////////////////////////////
260
 
                // Accesses
261
 
 
262
 
                half & operator[](size_type i);
263
 
                half const & operator[](size_type i) const;
264
 
 
265
 
                //////////////////////////////////////
266
 
                // Implicit basic constructors
267
 
 
268
 
                tvec4();
269
 
                tvec4(tvec4<half> const & v);
270
 
 
271
 
                //////////////////////////////////////
272
 
                // Explicit basic constructors
273
 
 
274
 
                explicit tvec4(ctor);
275
 
                explicit tvec4(
276
 
                        half const & s);
277
 
                explicit tvec4(
278
 
                        half const & s0, 
279
 
                        half const & s1, 
280
 
                        half const & s2, 
281
 
                        half const & s3);
282
 
 
283
 
                //////////////////////////////////////
284
 
                // Swizzle constructors
285
 
 
286
 
                tvec4(tref4<half> const & r);
287
 
 
288
 
                //////////////////////////////////////
289
 
                // Convertion scalar constructors
290
 
 
291
 
                //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
292
 
                template <typename U> 
293
 
                explicit tvec4(U const & x);
294
 
                //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
295
 
                template <typename A, typename B, typename C, typename D> 
296
 
                explicit tvec4(A const & x, B const & y, C const & z, D const & w);                     
297
 
 
298
 
                //////////////////////////////////////
299
 
                // Convertion vector constructors
300
 
 
301
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
302
 
                template <typename A, typename B, typename C> 
303
 
                explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
304
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
305
 
                template <typename A, typename B, typename C> 
306
 
                explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
307
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
308
 
                template <typename A, typename B, typename C> 
309
 
                explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
310
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
311
 
                template <typename A, typename B> 
312
 
                explicit tvec4(tvec3<A> const & v, B const & s);
313
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
314
 
                template <typename A, typename B> 
315
 
                explicit tvec4(A const & s, tvec3<B> const & v);
316
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
317
 
                template <typename A, typename B> 
318
 
                explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
319
 
                //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
320
 
                template <typename U> 
321
 
                explicit tvec4(tvec4<U> const & v);
322
 
 
323
 
                //////////////////////////////////////
324
 
                // Unary arithmetic operators
325
 
 
326
 
                tvec4<half>& operator= (tvec4<half> const & v);
327
 
 
328
 
                tvec4<half>& operator+=(half const & s);
329
 
                tvec4<half>& operator+=(tvec4<half> const & v);
330
 
                tvec4<half>& operator-=(half const & s);
331
 
                tvec4<half>& operator-=(tvec4<half> const & v);
332
 
                tvec4<half>& operator*=(half const & s);
333
 
                tvec4<half>& operator*=(tvec4<half> const & v);
334
 
                tvec4<half>& operator/=(half const & s);
335
 
                tvec4<half>& operator/=(tvec4<half> const & v);
336
 
                tvec4<half>& operator++();
337
 
                tvec4<half>& operator--();
338
 
 
339
 
                //////////////////////////////////////
340
 
                // Swizzle operators
341
 
 
342
 
                half swizzle(comp X) const;
343
 
                tvec2<half> swizzle(comp X, comp Y) const;
344
 
                tvec3<half> swizzle(comp X, comp Y, comp Z) const;
345
 
                tvec4<half> swizzle(comp X, comp Y, comp Z, comp W) const;
346
 
                tref4<half> swizzle(comp X, comp Y, comp Z, comp W);
347
 
        };
348
 
#endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98)
349
 
}
350
 
//namespace detail
351
 
 
352
 
        /// @addtogroup gtc_half_float
353
 
        /// @{
354
 
 
355
 
        /// Type for half-precision floating-point numbers. 
356
 
        /// @see gtc_half_float
357
 
        typedef detail::half                                    half;
358
 
 
359
 
        /// Vector of 2 half-precision floating-point numbers. 
360
 
        /// @see gtc_half_float
361
 
        typedef detail::tvec2<detail::half>     hvec2;
362
 
 
363
 
        /// Vector of 3 half-precision floating-point numbers.
364
 
        /// @see gtc_half_float
365
 
        typedef detail::tvec3<detail::half>     hvec3;
366
 
 
367
 
        /// Vector of 4 half-precision floating-point numbers. 
368
 
        /// @see gtc_half_float
369
 
        typedef detail::tvec4<detail::half>     hvec4;
370
 
 
371
 
        /// 2 * 2 matrix of half-precision floating-point numbers.
372
 
        /// @see gtc_half_float
373
 
        typedef detail::tmat2x2<detail::half>   hmat2;
374
 
    
375
 
        /// 3 * 3 matrix of half-precision floating-point numbers.
376
 
        /// @see gtc_half_float
377
 
        typedef detail::tmat3x3<detail::half>   hmat3;
378
 
 
379
 
        /// 4 * 4 matrix of half-precision floating-point numbers.
380
 
        /// @see gtc_half_float
381
 
        typedef detail::tmat4x4<detail::half>   hmat4;
382
 
 
383
 
        /// 2 * 2 matrix of half-precision floating-point numbers.
384
 
        /// @see gtc_half_float
385
 
        typedef detail::tmat2x2<detail::half>   hmat2x2;
386
 
    
387
 
        /// 2 * 3 matrix of half-precision floating-point numbers.
388
 
        /// @see gtc_half_float
389
 
        typedef detail::tmat2x3<detail::half>   hmat2x3;
390
 
    
391
 
        /// 2 * 4 matrix of half-precision floating-point numbers.
392
 
        /// @see gtc_half_float
393
 
        typedef detail::tmat2x4<detail::half>   hmat2x4;
394
 
 
395
 
        /// 3 * 2 matrix of half-precision floating-point numbers.
396
 
        /// @see gtc_half_float
397
 
        typedef detail::tmat3x2<detail::half>   hmat3x2;
398
 
    
399
 
        /// 3 * 3 matrix of half-precision floating-point numbers.
400
 
        /// @see gtc_half_float
401
 
        typedef detail::tmat3x3<detail::half>   hmat3x3;
402
 
    
403
 
        /// 3 * 4 matrix of half-precision floating-point numbers.
404
 
        /// @see gtc_half_float
405
 
        typedef detail::tmat3x4<detail::half>   hmat3x4;
406
 
 
407
 
        /// 4 * 2 matrix of half-precision floating-point numbers.
408
 
        /// @see gtc_half_float
409
 
        typedef detail::tmat4x2<detail::half>   hmat4x2;    
410
 
 
411
 
        /// 4 * 3 matrix of half-precision floating-point numbers.
412
 
        /// @see gtc_half_float
413
 
        typedef detail::tmat4x3<detail::half>   hmat4x3;
414
 
    
415
 
        /// 4 * 4 matrix of half-precision floating-point numbers.
416
 
        /// @see gtc_half_float
417
 
        typedef detail::tmat4x4<detail::half>   hmat4x4;
418
 
    
419
 
        /// @}
420
 
}// namespace glm
421
 
 
422
 
#include "half_float.inl"
423
 
 
424
 
#endif//GLM_GTC_half_float