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

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/gtc/swizzle.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_swizzle
24
 
/// @file glm/gtc/swizzle.hpp
25
 
/// @date 2010-02-20 / 2011-06-05
26
 
/// @author Christophe Riccio
27
 
///
28
 
/// @see core (dependence)
29
 
/// 
30
 
/// @defgroup gtc_swizzle GLM_GTC_swizzle: Swizzle 'operator' implementation
31
 
/// @ingroup gtc
32
 
/// 
33
 
/// @brief Provide functions to emulate GLSL swizzle operator fonctionalities.
34
 
/// 
35
 
/// <glm/gtc/swizzle.hpp> need to be included to use these functionalities.
36
 
///////////////////////////////////////////////////////////////////////////////////
37
 
 
38
 
#ifndef GLM_GTC_swizzle
39
 
#define GLM_GTC_swizzle GLM_VERSION
40
 
 
41
 
// Dependency:
42
 
#include "../glm.hpp"
43
 
#include "../gtc/type_precision.hpp"
44
 
 
45
 
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
46
 
#       pragma message("GLM: GLM_GTC_swizzle extension included")
47
 
#endif
48
 
 
49
 
namespace glm
50
 
{
51
 
        /// @addtogroup gtc_swizzle
52
 
        /// @{
53
 
        
54
 
 
55
 
        template <typename T, template <typename> class vecType>
56
 
        T const & swizzle(      
57
 
                vecType<T> const & v,
58
 
                comp x);
59
 
 
60
 
    /// 
61
 
        /// 
62
 
        /// @param v Vector source   
63
 
        /// @param x 
64
 
        /// @tparam T  
65
 
    /// @tparam vecType 
66
 
        /// @see gtc_swizzle
67
 
        template <typename T, template <typename> class vecType>
68
 
        detail::tvec2<T> const & swizzle(
69
 
                vecType<T> const & v,
70
 
                comp x, comp y);
71
 
 
72
 
        template <typename T, template <typename> class vecType>
73
 
        detail::tvec3<T> const & swizzle(
74
 
                vecType<T> const & v,
75
 
                comp x, comp y, comp z);
76
 
 
77
 
        template <typename T, template <typename> class vecType>
78
 
        detail::tvec4<T> const & swizzle(
79
 
                vecType<T> const & v,
80
 
                comp x, comp y, comp z, comp w);
81
 
 
82
 
        template <typename T, template <typename> class vecType>
83
 
        T & swizzle(
84
 
                vecType<T> & v,
85
 
                comp x);
86
 
 
87
 
        template <typename T, template <typename> class vecType>
88
 
        detail::tref2<T> swizzle(
89
 
                vecType<T> & v,
90
 
                comp x, comp y);
91
 
 
92
 
        template <typename T, template <typename> class vecType>
93
 
        detail::tref3<T> swizzle(
94
 
                vecType<T> & v,
95
 
                comp x, comp y, comp z);
96
 
 
97
 
        template <typename T, template <typename> class vecType>
98
 
        detail::tref4<T> swizzle(
99
 
                vecType<T> & v,
100
 
                comp x, comp y, comp z, comp w);
101
 
 
102
 
#       define static_swizzle1_const(TYPE, SIZE)                                                        \
103
 
                template <comp x>                                                                               \
104
 
                GLM_FUNC_QUALIFIER TYPE swizzle(detail::tvec##SIZE<TYPE> const & v)     \
105
 
                {return v[x];}                                                                                  
106
 
                                                                                                                                
107
 
#       define static_swizzle1_ref(TYPE, SIZE)                                                                  \
108
 
                template <comp x>                                                                                                       \
109
 
                GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE<TYPE> & v)          \
110
 
                {return v[x];}
111
 
 
112
 
        static_swizzle1_ref(detail::float16, 2)
113
 
        static_swizzle1_ref(detail::float16, 3)
114
 
        static_swizzle1_ref(detail::float16, 4)
115
 
        static_swizzle1_ref(detail::float32, 2)
116
 
        static_swizzle1_ref(detail::float32, 3)
117
 
        static_swizzle1_ref(detail::float32, 4)
118
 
        static_swizzle1_ref(detail::float64, 2)
119
 
        static_swizzle1_ref(detail::float64, 3)
120
 
        static_swizzle1_ref(detail::float64, 4)
121
 
 
122
 
        static_swizzle1_ref(detail::int8,  2)
123
 
        static_swizzle1_ref(detail::int8,  3)
124
 
        static_swizzle1_ref(detail::int8,  4)
125
 
        static_swizzle1_ref(detail::int16, 2)
126
 
        static_swizzle1_ref(detail::int16, 3)
127
 
        static_swizzle1_ref(detail::int16, 4)
128
 
        static_swizzle1_ref(detail::int32, 2)
129
 
        static_swizzle1_ref(detail::int32, 3)
130
 
        static_swizzle1_ref(detail::int32, 4)
131
 
        static_swizzle1_ref(detail::int64, 2)
132
 
        static_swizzle1_ref(detail::int64, 3)
133
 
        static_swizzle1_ref(detail::int64, 4)
134
 
 
135
 
        static_swizzle1_ref(detail::uint8,  2)
136
 
        static_swizzle1_ref(detail::uint8,  3)
137
 
        static_swizzle1_ref(detail::uint8,  4)
138
 
        static_swizzle1_ref(detail::uint16, 2)
139
 
        static_swizzle1_ref(detail::uint16, 3)
140
 
        static_swizzle1_ref(detail::uint16, 4)
141
 
        static_swizzle1_ref(detail::uint32, 2)
142
 
        static_swizzle1_ref(detail::uint32, 3)
143
 
        static_swizzle1_ref(detail::uint32, 4)
144
 
        static_swizzle1_ref(detail::uint64, 2)
145
 
        static_swizzle1_ref(detail::uint64, 3)
146
 
        static_swizzle1_ref(detail::uint64, 4)
147
 
/*
148
 
#       define static_swizzle2_const(TYPE) \
149
 
                template <comp x, comp y> \
150
 
                GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
151
 
                {return TYPE(v[x], v[y]);}
152
 
 
153
 
#       define static_swizzle3_const(TYPE) \
154
 
                template <comp x, comp y, comp z> \
155
 
                GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
156
 
                {return TYPE(v[x], v[y], v[z]);}
157
 
 
158
 
#       define static_swizzle4_const(TYPE) \
159
 
                template <comp x, comp y, comp z, comp w> \
160
 
                GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
161
 
                {return TYPE(v[x], v[y], v[z], v[w]);}
162
 
*/
163
 
 
164
 
#       define static_swizzle2_const(TYPE, SIZE)                                                                        \
165
 
                template <comp x, comp y>                                                                                               \
166
 
                GLM_FUNC_QUALIFIER detail::tvec2<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v)      \
167
 
                {return detail::tvec2<TYPE>(v[x], v[y]);}
168
 
 
169
 
#       define static_swizzle3_const(TYPE, SIZE)                                                                        \
170
 
                template <comp x, comp y, comp z>                                                                               \
171
 
                GLM_FUNC_QUALIFIER detail::tvec3<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v)      \
172
 
                {return detail::tvec3<TYPE>(v[x], v[y], v[z]);}
173
 
 
174
 
#       define static_swizzle4_const(TYPE, SIZE)                                                                        \
175
 
                template <comp x, comp y, comp z, comp w>                                                               \
176
 
                GLM_FUNC_QUALIFIER detail::tvec4<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v)      \
177
 
                {return detail::tvec4<TYPE>(v[x], v[y], v[z], v[w]);}
178
 
 
179
 
 
180
 
        static_swizzle2_const(glm::f16, 2)
181
 
        static_swizzle2_const(glm::f16, 3)
182
 
        static_swizzle2_const(glm::f16, 4)
183
 
        static_swizzle2_const(glm::f32, 2)
184
 
        static_swizzle2_const(glm::f32, 3)
185
 
        static_swizzle2_const(glm::f32, 4)
186
 
        static_swizzle2_const(glm::f64, 2)
187
 
        static_swizzle2_const(glm::f64, 3)
188
 
        static_swizzle2_const(glm::f64, 4)
189
 
 
190
 
        static_swizzle2_const(glm::i8, 2)
191
 
        static_swizzle2_const(glm::i8, 3)
192
 
        static_swizzle2_const(glm::i8, 4)
193
 
        static_swizzle2_const(glm::i16, 2)
194
 
        static_swizzle2_const(glm::i16, 3)
195
 
        static_swizzle2_const(glm::i16, 4)
196
 
        static_swizzle2_const(glm::i32, 2)
197
 
        static_swizzle2_const(glm::i32, 3)
198
 
        static_swizzle2_const(glm::i32, 4)
199
 
        static_swizzle2_const(glm::i64, 2)
200
 
        static_swizzle2_const(glm::i64, 3)
201
 
        static_swizzle2_const(glm::i64, 4)
202
 
 
203
 
        static_swizzle2_const(glm::u8, 2)
204
 
        static_swizzle2_const(glm::u8, 3)
205
 
        static_swizzle2_const(glm::u8, 4)
206
 
        static_swizzle2_const(glm::u16, 2)
207
 
        static_swizzle2_const(glm::u16, 3)
208
 
        static_swizzle2_const(glm::u16, 4)
209
 
        static_swizzle2_const(glm::u32, 2)
210
 
        static_swizzle2_const(glm::u32, 3)
211
 
        static_swizzle2_const(glm::u32, 4)
212
 
        static_swizzle2_const(glm::u64, 2)
213
 
        static_swizzle2_const(glm::u64, 3)
214
 
        static_swizzle2_const(glm::u64, 4)
215
 
 
216
 
        static_swizzle3_const(glm::f16, 2)
217
 
        static_swizzle3_const(glm::f16, 3)
218
 
        static_swizzle3_const(glm::f16, 4)
219
 
        static_swizzle3_const(glm::f32, 2)
220
 
        static_swizzle3_const(glm::f32, 3)
221
 
        static_swizzle3_const(glm::f32, 4)
222
 
        static_swizzle3_const(glm::f64, 2)
223
 
        static_swizzle3_const(glm::f64, 3)
224
 
        static_swizzle3_const(glm::f64, 4)
225
 
 
226
 
        static_swizzle3_const(glm::i8, 2)
227
 
        static_swizzle3_const(glm::i8, 3)
228
 
        static_swizzle3_const(glm::i8, 4)
229
 
        static_swizzle3_const(glm::i16, 2)
230
 
        static_swizzle3_const(glm::i16, 3)
231
 
        static_swizzle3_const(glm::i16, 4)
232
 
        static_swizzle3_const(glm::i32, 2)
233
 
        static_swizzle3_const(glm::i32, 3)
234
 
        static_swizzle3_const(glm::i32, 4)
235
 
        static_swizzle3_const(glm::i64, 2)
236
 
        static_swizzle3_const(glm::i64, 3)
237
 
        static_swizzle3_const(glm::i64, 4)
238
 
 
239
 
        static_swizzle3_const(glm::u8, 2)
240
 
        static_swizzle3_const(glm::u8, 3)
241
 
        static_swizzle3_const(glm::u8, 4)
242
 
        static_swizzle3_const(glm::u16, 2)
243
 
        static_swizzle3_const(glm::u16, 3)
244
 
        static_swizzle3_const(glm::u16, 4)
245
 
        static_swizzle3_const(glm::u32, 2)
246
 
        static_swizzle3_const(glm::u32, 3)
247
 
        static_swizzle3_const(glm::u32, 4)
248
 
        static_swizzle3_const(glm::u64, 2)
249
 
        static_swizzle3_const(glm::u64, 3)
250
 
        static_swizzle3_const(glm::u64, 4)
251
 
 
252
 
        static_swizzle4_const(glm::f16, 2)
253
 
        static_swizzle4_const(glm::f16, 3)
254
 
        static_swizzle4_const(glm::f16, 4)
255
 
        static_swizzle4_const(glm::f32, 2)
256
 
        static_swizzle4_const(glm::f32, 3)
257
 
        static_swizzle4_const(glm::f32, 4)
258
 
        static_swizzle4_const(glm::f64, 2)
259
 
        static_swizzle4_const(glm::f64, 3)
260
 
        static_swizzle4_const(glm::f64, 4)
261
 
 
262
 
        static_swizzle4_const(glm::i8, 2)
263
 
        static_swizzle4_const(glm::i8, 3)
264
 
        static_swizzle4_const(glm::i8, 4)
265
 
        static_swizzle4_const(glm::i16, 2)
266
 
        static_swizzle4_const(glm::i16, 3)
267
 
        static_swizzle4_const(glm::i16, 4)
268
 
        static_swizzle4_const(glm::i32, 2)
269
 
        static_swizzle4_const(glm::i32, 3)
270
 
        static_swizzle4_const(glm::i32, 4)
271
 
        static_swizzle4_const(glm::i64, 2)
272
 
        static_swizzle4_const(glm::i64, 3)
273
 
        static_swizzle4_const(glm::i64, 4)
274
 
 
275
 
        static_swizzle4_const(glm::u8, 2)
276
 
        static_swizzle4_const(glm::u8, 3)
277
 
        static_swizzle4_const(glm::u8, 4)
278
 
        static_swizzle4_const(glm::u16, 2)
279
 
        static_swizzle4_const(glm::u16, 3)
280
 
        static_swizzle4_const(glm::u16, 4)
281
 
        static_swizzle4_const(glm::u32, 2)
282
 
        static_swizzle4_const(glm::u32, 3)
283
 
        static_swizzle4_const(glm::u32, 4)
284
 
        static_swizzle4_const(glm::u64, 2)
285
 
        static_swizzle4_const(glm::u64, 3)
286
 
        static_swizzle4_const(glm::u64, 4)
287
 
 
288
 
#       define static_swizzle2_ref(TYPE, SIZE) \
289
 
                template <glm::comp x, glm::comp y> \
290
 
                GLM_FUNC_QUALIFIER glm::detail::tref2<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
291
 
                {return glm::detail::tref2<TYPE>(v[x], v[y]);}  
292
 
 
293
 
#       define static_swizzle3_ref(TYPE, SIZE) \
294
 
                template <glm::comp x, glm::comp y, glm::comp z> \
295
 
                GLM_FUNC_QUALIFIER glm::detail::tref3<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
296
 
                {return glm::detail::tref3<TYPE>(v[x], v[y], v[z]);}    
297
 
 
298
 
#       define static_swizzle4_ref(TYPE, SIZE) \
299
 
                template <glm::comp x, glm::comp y, glm::comp z, glm::comp w> \
300
 
                GLM_FUNC_QUALIFIER glm::detail::tref4<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
301
 
                {return glm::detail::tref4<TYPE>(v[x], v[y], v[z], v[w]);}      
302
 
 
303
 
        static_swizzle2_ref(glm::f16, 2)
304
 
        static_swizzle2_ref(glm::f16, 3)
305
 
        static_swizzle2_ref(glm::f16, 4)
306
 
        static_swizzle2_ref(glm::f32, 2)
307
 
        static_swizzle2_ref(glm::f32, 3)
308
 
        static_swizzle2_ref(glm::f32, 4)
309
 
        static_swizzle2_ref(glm::f64, 2)
310
 
        static_swizzle2_ref(glm::f64, 3)
311
 
        static_swizzle2_ref(glm::f64, 4)
312
 
 
313
 
        static_swizzle2_ref(glm::i8, 2)
314
 
        static_swizzle2_ref(glm::i8, 3)
315
 
        static_swizzle2_ref(glm::i8, 4)
316
 
        static_swizzle2_ref(glm::i16, 2)
317
 
        static_swizzle2_ref(glm::i16, 3)
318
 
        static_swizzle2_ref(glm::i16, 4)
319
 
        static_swizzle2_ref(glm::i32, 2)
320
 
        static_swizzle2_ref(glm::i32, 3)
321
 
        static_swizzle2_ref(glm::i32, 4)
322
 
        static_swizzle2_ref(glm::i64, 2)
323
 
        static_swizzle2_ref(glm::i64, 3)
324
 
        static_swizzle2_ref(glm::i64, 4)
325
 
 
326
 
        static_swizzle2_ref(glm::u8, 2)
327
 
        static_swizzle2_ref(glm::u8, 3)
328
 
        static_swizzle2_ref(glm::u8, 4)
329
 
        static_swizzle2_ref(glm::u16, 2)
330
 
        static_swizzle2_ref(glm::u16, 3)
331
 
        static_swizzle2_ref(glm::u16, 4)
332
 
        static_swizzle2_ref(glm::u32, 2)
333
 
        static_swizzle2_ref(glm::u32, 3)
334
 
        static_swizzle2_ref(glm::u32, 4)
335
 
        static_swizzle2_ref(glm::u64, 2)
336
 
        static_swizzle2_ref(glm::u64, 3)
337
 
        static_swizzle2_ref(glm::u64, 4)
338
 
 
339
 
        static_swizzle3_ref(glm::f16, 3)
340
 
        static_swizzle3_ref(glm::f16, 4)
341
 
        static_swizzle3_ref(glm::f32, 3)
342
 
        static_swizzle3_ref(glm::f32, 4)
343
 
        static_swizzle3_ref(glm::f64, 3)
344
 
        static_swizzle3_ref(glm::f64, 4)
345
 
 
346
 
        static_swizzle3_ref(glm::i8, 3)
347
 
        static_swizzle3_ref(glm::i8, 4)
348
 
        static_swizzle3_ref(glm::i16, 3)
349
 
        static_swizzle3_ref(glm::i16, 4)
350
 
        static_swizzle3_ref(glm::i32, 3)
351
 
        static_swizzle3_ref(glm::i32, 4)
352
 
        static_swizzle3_ref(glm::i64, 3)
353
 
        static_swizzle3_ref(glm::i64, 4)
354
 
 
355
 
        static_swizzle3_ref(glm::u8, 3)
356
 
        static_swizzle3_ref(glm::u8, 4)
357
 
        static_swizzle3_ref(glm::u16, 3)
358
 
        static_swizzle3_ref(glm::u16, 4)
359
 
        static_swizzle3_ref(glm::u32, 3)
360
 
        static_swizzle3_ref(glm::u32, 4)
361
 
        static_swizzle3_ref(glm::u64, 3)
362
 
        static_swizzle3_ref(glm::u64, 4)
363
 
 
364
 
        static_swizzle4_ref(glm::f16, 4)
365
 
        static_swizzle4_ref(glm::f32, 4)
366
 
        static_swizzle4_ref(glm::f64, 4)
367
 
 
368
 
        static_swizzle4_ref(glm::i8, 4)
369
 
        static_swizzle4_ref(glm::i16, 4)
370
 
        static_swizzle4_ref(glm::i32, 4)
371
 
        static_swizzle4_ref(glm::i64, 4)
372
 
 
373
 
        static_swizzle4_ref(glm::u8, 4)
374
 
        static_swizzle4_ref(glm::u16, 4)
375
 
        static_swizzle4_ref(glm::u32, 4)
376
 
        static_swizzle4_ref(glm::u64, 4)
377
 
 
378
 
        /// @}
379
 
}//namespace glm
380
 
 
381
 
#include "swizzle.inl"
382
 
 
383
 
#endif//GLM_GTC_swizzle