- Main Page
- Related Pages
- Modules
- Files

- File List

half_float.hpp
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
65 // Data
66
67 half x, y;
68
70 // Accesses
71
72 half & operator[](size_type i);
73 half const & operator[](size_type i) const;
74
76 // Implicit basic constructors
77
78 tvec2();
79 tvec2(tvec2<half> const & v);
80
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
92 // Swizzle constructors
93
94 tvec2(tref2<half> const & r);
95
97 // Convertion scalar constructors
98
100 template <typename U>
101 explicit tvec2(U const & x);
103 template <typename U, typename V>
104 explicit tvec2(U const & x, V const & y);
105
107 // Convertion vector constructors
108
110 template <typename U>
111 explicit tvec2(tvec2<U> const & v);
113 template <typename U>
114 explicit tvec2(tvec3<U> const & v);
116 template <typename U>
117 explicit tvec2(tvec4<U> const & v);
118
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
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
158 // Data
159
160 half x, y, z;
161
163 // Accesses
164
165 half & operator[](size_type i);
166 half const & operator[](size_type i) const;
167
169 // Implicit basic constructors
170
171 tvec3();
172 tvec3(tvec3<half> const & v);
173
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
186 // Swizzle constructors
187
188 tvec3(tref3<half> const & r);
189
191 // Convertion scalar constructors
192
194 template <typename U>
195 explicit tvec3(U const & x);
197 template <typename U, typename V, typename W>
198 explicit tvec3(U const & x, V const & y, W const & z);
199
201 // Convertion vector constructors
202
204 template <typename A, typename B>
205 explicit tvec3(tvec2<A> const & v, B const & s);
207 template <typename A, typename B>
208 explicit tvec3(A const & s, tvec2<B> const & v);
210 template <typename U>
211 explicit tvec3(tvec3<U> const & v);
213 template <typename U>
214 explicit tvec3(tvec4<U> const & v);
215
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
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
255 // Data
256
257 half x, y, z, w;
258
260 // Accesses
261
262 half & operator[](size_type i);
263 half const & operator[](size_type i) const;
264
266 // Implicit basic constructors
267
268 tvec4();
269 tvec4(tvec4<half> const & v);
270
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
284 // Swizzle constructors
285
286 tvec4(tref4<half> const & r);
287
289 // Convertion scalar constructors
290
292 template <typename U>
293 explicit tvec4(U const & x);
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
299 // Convertion vector constructors
300
302 template <typename A, typename B, typename C>
303 explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
305 template <typename A, typename B, typename C>
306 explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
308 template <typename A, typename B, typename C>
309 explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
311 template <typename A, typename B>
312 explicit tvec4(tvec3<A> const & v, B const & s);
314 template <typename A, typename B>
315 explicit tvec4(A const & s, tvec3<B> const & v);
317 template <typename A, typename B>
318 explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
320 template <typename U>
321 explicit tvec4(tvec4<U> const & v);
322
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
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
354
357 typedef detail::half half;
358
361 typedef detail::tvec2<detail::half> hvec2;
362
365 typedef detail::tvec3<detail::half> hvec3;
366
369 typedef detail::tvec4<detail::half> hvec4;
370
373 typedef detail::tmat2x2<detail::half> hmat2;
374
377 typedef detail::tmat3x3<detail::half> hmat3;
378
381 typedef detail::tmat4x4<detail::half> hmat4;
382
385 typedef detail::tmat2x2<detail::half> hmat2x2;
386
389 typedef detail::tmat2x3<detail::half> hmat2x3;
390
393 typedef detail::tmat2x4<detail::half> hmat2x4;
394
397 typedef detail::tmat3x2<detail::half> hmat3x2;
398
401 typedef detail::tmat3x3<detail::half> hmat3x3;
402
405 typedef detail::tmat3x4<detail::half> hmat3x4;
406
409 typedef detail::tmat4x2<detail::half> hmat4x2;
410
413 typedef detail::tmat4x3<detail::half> hmat4x3;
414
417 typedef detail::tmat4x4<detail::half> hmat4x4;
418
421 half abs(half const & x);
422
425 hvec2 abs(hvec2 const & x);
426
429 hvec3 abs(hvec3 const & x);
430
433 hvec4 abs(hvec4 const & x);
434
436 }// namespace glm
437
438 #include "half_float.inl"
439
440 #endif//GLM_GTC_half_float