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
23
/// @ref gtc_half_float
24
/// @file glm/gtc/half_float.hpp
25
/// @date 2009-04-29 / 2011-06-05
26
/// @author Christophe Riccio
28
/// @see core (dependence)
30
/// @defgroup gtc_half_float GLM_GTC_half_float: Half-precision floating-point based types and functions
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
///////////////////////////////////////////////////////////////////////////////////
37
#ifndef GLM_GTC_half_float
38
#define GLM_GTC_half_float GLM_VERSION
43
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
44
# pragma message("GLM: GLM_GTC_half_float extension included")
50
#if(GLM_COMPONENT == GLM_COMPONENT_CXX98)
55
typedef half value_type;
56
typedef std::size_t size_type;
58
GLM_FUNC_DECL size_type length() const;
59
static GLM_FUNC_DECL size_type value_size();
61
typedef tvec2<half> type;
62
typedef tvec2<bool> bool_type;
64
//////////////////////////////////////
69
//////////////////////////////////////
72
half & operator[](size_type i);
73
half const & operator[](size_type i) const;
75
//////////////////////////////////////
76
// Implicit basic constructors
79
tvec2(tvec2<half> const & v);
81
//////////////////////////////////////
82
// Explicit basic constructors
91
//////////////////////////////////////
92
// Swizzle constructors
94
tvec2(tref2<half> const & r);
96
//////////////////////////////////////
97
// Convertion scalar constructors
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);
106
//////////////////////////////////////
107
// Convertion vector constructors
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);
119
//////////////////////////////////////
120
// Unary arithmetic operators
122
tvec2<half>& operator= (tvec2<half> const & v);
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--();
135
//////////////////////////////////////
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);
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();
154
typedef tvec3<half> type;
155
typedef tvec3<bool> bool_type;
157
//////////////////////////////////////
162
//////////////////////////////////////
165
half & operator[](size_type i);
166
half const & operator[](size_type i) const;
168
//////////////////////////////////////
169
// Implicit basic constructors
172
tvec3(tvec3<half> const & v);
174
//////////////////////////////////////
175
// Explicit basic constructors
177
explicit tvec3(ctor);
185
//////////////////////////////////////
186
// Swizzle constructors
188
tvec3(tref3<half> const & r);
190
//////////////////////////////////////
191
// Convertion scalar constructors
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);
200
//////////////////////////////////////
201
// Convertion vector constructors
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);
216
//////////////////////////////////////
217
// Unary arithmetic operators
219
tvec3<half>& operator= (tvec3<half> const & v);
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--();
232
//////////////////////////////////////
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);
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();
251
typedef tvec4<half> type;
252
typedef tvec4<bool> bool_type;
254
//////////////////////////////////////
259
//////////////////////////////////////
262
half & operator[](size_type i);
263
half const & operator[](size_type i) const;
265
//////////////////////////////////////
266
// Implicit basic constructors
269
tvec4(tvec4<half> const & v);
271
//////////////////////////////////////
272
// Explicit basic constructors
274
explicit tvec4(ctor);
283
//////////////////////////////////////
284
// Swizzle constructors
286
tvec4(tref4<half> const & r);
288
//////////////////////////////////////
289
// Convertion scalar constructors
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);
298
//////////////////////////////////////
299
// Convertion vector constructors
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);
323
//////////////////////////////////////
324
// Unary arithmetic operators
326
tvec4<half>& operator= (tvec4<half> const & v);
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--();
339
//////////////////////////////////////
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);
348
#endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98)
352
/// @addtogroup gtc_half_float
355
/// Type for half-precision floating-point numbers.
356
/// @see gtc_half_float
357
typedef detail::half half;
359
/// Vector of 2 half-precision floating-point numbers.
360
/// @see gtc_half_float
361
typedef detail::tvec2<detail::half> hvec2;
363
/// Vector of 3 half-precision floating-point numbers.
364
/// @see gtc_half_float
365
typedef detail::tvec3<detail::half> hvec3;
367
/// Vector of 4 half-precision floating-point numbers.
368
/// @see gtc_half_float
369
typedef detail::tvec4<detail::half> hvec4;
371
/// 2 * 2 matrix of half-precision floating-point numbers.
372
/// @see gtc_half_float
373
typedef detail::tmat2x2<detail::half> hmat2;
375
/// 3 * 3 matrix of half-precision floating-point numbers.
376
/// @see gtc_half_float
377
typedef detail::tmat3x3<detail::half> hmat3;
379
/// 4 * 4 matrix of half-precision floating-point numbers.
380
/// @see gtc_half_float
381
typedef detail::tmat4x4<detail::half> hmat4;
383
/// 2 * 2 matrix of half-precision floating-point numbers.
384
/// @see gtc_half_float
385
typedef detail::tmat2x2<detail::half> hmat2x2;
387
/// 2 * 3 matrix of half-precision floating-point numbers.
388
/// @see gtc_half_float
389
typedef detail::tmat2x3<detail::half> hmat2x3;
391
/// 2 * 4 matrix of half-precision floating-point numbers.
392
/// @see gtc_half_float
393
typedef detail::tmat2x4<detail::half> hmat2x4;
395
/// 3 * 2 matrix of half-precision floating-point numbers.
396
/// @see gtc_half_float
397
typedef detail::tmat3x2<detail::half> hmat3x2;
399
/// 3 * 3 matrix of half-precision floating-point numbers.
400
/// @see gtc_half_float
401
typedef detail::tmat3x3<detail::half> hmat3x3;
403
/// 3 * 4 matrix of half-precision floating-point numbers.
404
/// @see gtc_half_float
405
typedef detail::tmat3x4<detail::half> hmat3x4;
407
/// 4 * 2 matrix of half-precision floating-point numbers.
408
/// @see gtc_half_float
409
typedef detail::tmat4x2<detail::half> hmat4x2;
411
/// 4 * 3 matrix of half-precision floating-point numbers.
412
/// @see gtc_half_float
413
typedef detail::tmat4x3<detail::half> hmat4x3;
415
/// 4 * 4 matrix of half-precision floating-point numbers.
416
/// @see gtc_half_float
417
typedef detail::tmat4x4<detail::half> hmat4x4;
422
#include "half_float.inl"
424
#endif//GLM_GTC_half_float