38 #ifndef GLM_GTC_swizzle
39 #define GLM_GTC_swizzle GLM_VERSION
43 #include "../gtc/type_precision.hpp"
45 #if(defined(GLM_MESSAGES) && !defined(glm_ext))
46 # pragma message("GLM: GLM_GTC_swizzle extension included")
54 template <
typename T,
template <
typename>
class vecType>
59 template <
typename T,
template <
typename>
class vecType>
60 detail::tvec2<T>
const & swizzle(
64 template <
typename T,
template <
typename>
class vecType>
65 detail::tvec3<T>
const & swizzle(
67 comp x, comp y, comp z);
69 template <
typename T,
template <
typename>
class vecType>
70 detail::tvec4<T>
const & swizzle(
72 comp x, comp y, comp z, comp w);
74 template <
typename T,
template <
typename>
class vecType>
79 template <
typename T,
template <
typename>
class vecType>
80 detail::tref2<T> swizzle(
84 template <
typename T,
template <
typename>
class vecType>
85 detail::tref3<T> swizzle(
87 comp x, comp y, comp z);
89 template <
typename T,
template <
typename>
class vecType>
90 detail::tref4<T> swizzle(
92 comp x, comp y, comp z, comp w);
94 # define static_swizzle1_const(TYPE, SIZE) \
96 GLM_FUNC_QUALIFIER TYPE swizzle(detail::tvec##SIZE<TYPE> const & v) \
99 # define static_swizzle1_ref(TYPE, SIZE) \
101 GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE<TYPE> & v) \
104 static_swizzle1_ref(detail::float16, 2)
105 static_swizzle1_ref(detail::float16, 3)
106 static_swizzle1_ref(detail::float16, 4)
107 static_swizzle1_ref(detail::float32, 2)
108 static_swizzle1_ref(detail::float32, 3)
109 static_swizzle1_ref(detail::float32, 4)
110 static_swizzle1_ref(detail::float64, 2)
111 static_swizzle1_ref(detail::float64, 3)
112 static_swizzle1_ref(detail::float64, 4)
114 static_swizzle1_ref(detail::int8, 2)
115 static_swizzle1_ref(detail::int8, 3)
116 static_swizzle1_ref(detail::int8, 4)
117 static_swizzle1_ref(detail::int16, 2)
118 static_swizzle1_ref(detail::int16, 3)
119 static_swizzle1_ref(detail::int16, 4)
120 static_swizzle1_ref(detail::int32, 2)
121 static_swizzle1_ref(detail::int32, 3)
122 static_swizzle1_ref(detail::int32, 4)
123 static_swizzle1_ref(detail::int64, 2)
124 static_swizzle1_ref(detail::int64, 3)
125 static_swizzle1_ref(detail::int64, 4)
127 static_swizzle1_ref(detail::uint8, 2)
128 static_swizzle1_ref(detail::uint8, 3)
129 static_swizzle1_ref(detail::uint8, 4)
130 static_swizzle1_ref(detail::uint16, 2)
131 static_swizzle1_ref(detail::uint16, 3)
132 static_swizzle1_ref(detail::uint16, 4)
133 static_swizzle1_ref(detail::uint32, 2)
134 static_swizzle1_ref(detail::uint32, 3)
135 static_swizzle1_ref(detail::uint32, 4)
136 static_swizzle1_ref(detail::uint64, 2)
137 static_swizzle1_ref(detail::uint64, 3)
138 static_swizzle1_ref(detail::uint64, 4)
156 # define static_swizzle2_const(TYPE, SIZE) \
157 template <comp x, comp y> \
158 GLM_FUNC_QUALIFIER detail::tvec2<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v) \
159 {return detail::tvec2<TYPE>(v[x], v[y]);}
161 # define static_swizzle3_const(TYPE, SIZE) \
162 template <comp x, comp y, comp z> \
163 GLM_FUNC_QUALIFIER detail::tvec3<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v) \
164 {return detail::tvec3<TYPE>(v[x], v[y], v[z]);}
166 # define static_swizzle4_const(TYPE, SIZE) \
167 template <comp x, comp y, comp z, comp w> \
168 GLM_FUNC_QUALIFIER detail::tvec4<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v) \
169 {return detail::tvec4<TYPE>(v[x], v[y], v[z], v[w]);}
173 static_swizzle2_const(glm::
f16, 3)
174 static_swizzle2_const(glm::f16, 4)
175 static_swizzle2_const(glm::
f32, 2)
176 static_swizzle2_const(glm::f32, 3)
177 static_swizzle2_const(glm::f32, 4)
178 static_swizzle2_const(glm::
f64, 2)
179 static_swizzle2_const(glm::f64, 3)
180 static_swizzle2_const(glm::f64, 4)
182 static_swizzle2_const(glm::
i8, 2)
183 static_swizzle2_const(glm::i8, 3)
184 static_swizzle2_const(glm::i8, 4)
185 static_swizzle2_const(glm::
i16, 2)
186 static_swizzle2_const(glm::i16, 3)
187 static_swizzle2_const(glm::i16, 4)
188 static_swizzle2_const(glm::
i32, 2)
189 static_swizzle2_const(glm::i32, 3)
190 static_swizzle2_const(glm::i32, 4)
191 static_swizzle2_const(glm::
i64, 2)
192 static_swizzle2_const(glm::i64, 3)
193 static_swizzle2_const(glm::i64, 4)
195 static_swizzle2_const(glm::
u8, 2)
196 static_swizzle2_const(glm::u8, 3)
197 static_swizzle2_const(glm::u8, 4)
198 static_swizzle2_const(glm::
u16, 2)
199 static_swizzle2_const(glm::u16, 3)
200 static_swizzle2_const(glm::u16, 4)
201 static_swizzle2_const(glm::
u32, 2)
202 static_swizzle2_const(glm::u32, 3)
203 static_swizzle2_const(glm::u32, 4)
204 static_swizzle2_const(glm::
u64, 2)
205 static_swizzle2_const(glm::u64, 3)
206 static_swizzle2_const(glm::u64, 4)
208 static_swizzle3_const(glm::f16, 2)
209 static_swizzle3_const(glm::f16, 3)
210 static_swizzle3_const(glm::f16, 4)
211 static_swizzle3_const(glm::f32, 2)
212 static_swizzle3_const(glm::f32, 3)
213 static_swizzle3_const(glm::f32, 4)
214 static_swizzle3_const(glm::f64, 2)
215 static_swizzle3_const(glm::f64, 3)
216 static_swizzle3_const(glm::f64, 4)
218 static_swizzle3_const(glm::i8, 2)
219 static_swizzle3_const(glm::i8, 3)
220 static_swizzle3_const(glm::i8, 4)
221 static_swizzle3_const(glm::i16, 2)
222 static_swizzle3_const(glm::i16, 3)
223 static_swizzle3_const(glm::i16, 4)
224 static_swizzle3_const(glm::i32, 2)
225 static_swizzle3_const(glm::i32, 3)
226 static_swizzle3_const(glm::i32, 4)
227 static_swizzle3_const(glm::i64, 2)
228 static_swizzle3_const(glm::i64, 3)
229 static_swizzle3_const(glm::i64, 4)
231 static_swizzle3_const(glm::u8, 2)
232 static_swizzle3_const(glm::u8, 3)
233 static_swizzle3_const(glm::u8, 4)
234 static_swizzle3_const(glm::u16, 2)
235 static_swizzle3_const(glm::u16, 3)
236 static_swizzle3_const(glm::u16, 4)
237 static_swizzle3_const(glm::u32, 2)
238 static_swizzle3_const(glm::u32, 3)
239 static_swizzle3_const(glm::u32, 4)
240 static_swizzle3_const(glm::u64, 2)
241 static_swizzle3_const(glm::u64, 3)
242 static_swizzle3_const(glm::u64, 4)
244 static_swizzle4_const(glm::f16, 2)
245 static_swizzle4_const(glm::f16, 3)
246 static_swizzle4_const(glm::f16, 4)
247 static_swizzle4_const(glm::f32, 2)
248 static_swizzle4_const(glm::f32, 3)
249 static_swizzle4_const(glm::f32, 4)
250 static_swizzle4_const(glm::f64, 2)
251 static_swizzle4_const(glm::f64, 3)
252 static_swizzle4_const(glm::f64, 4)
254 static_swizzle4_const(glm::i8, 2)
255 static_swizzle4_const(glm::i8, 3)
256 static_swizzle4_const(glm::i8, 4)
257 static_swizzle4_const(glm::i16, 2)
258 static_swizzle4_const(glm::i16, 3)
259 static_swizzle4_const(glm::i16, 4)
260 static_swizzle4_const(glm::i32, 2)
261 static_swizzle4_const(glm::i32, 3)
262 static_swizzle4_const(glm::i32, 4)
263 static_swizzle4_const(glm::i64, 2)
264 static_swizzle4_const(glm::i64, 3)
265 static_swizzle4_const(glm::i64, 4)
267 static_swizzle4_const(glm::u8, 2)
268 static_swizzle4_const(glm::u8, 3)
269 static_swizzle4_const(glm::u8, 4)
270 static_swizzle4_const(glm::u16, 2)
271 static_swizzle4_const(glm::u16, 3)
272 static_swizzle4_const(glm::u16, 4)
273 static_swizzle4_const(glm::u32, 2)
274 static_swizzle4_const(glm::u32, 3)
275 static_swizzle4_const(glm::u32, 4)
276 static_swizzle4_const(glm::u64, 2)
277 static_swizzle4_const(glm::u64, 3)
278 static_swizzle4_const(glm::u64, 4)
280 # define static_swizzle2_ref(TYPE, SIZE) \
281 template <glm::comp x, glm::comp y> \
282 GLM_FUNC_QUALIFIER glm::detail::tref2<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
283 {return glm::detail::tref2<TYPE>(v[x], v[y]);}
285 # define static_swizzle3_ref(TYPE, SIZE) \
286 template <glm::comp x, glm::comp y, glm::comp z> \
287 GLM_FUNC_QUALIFIER glm::detail::tref3<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
288 {return glm::detail::tref3<TYPE>(v[x], v[y], v[z]);}
290 # define static_swizzle4_ref(TYPE, SIZE) \
291 template <glm::comp x, glm::comp y, glm::comp z, glm::comp w> \
292 GLM_FUNC_QUALIFIER glm::detail::tref4<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
293 {return glm::detail::tref4<TYPE>(v[x], v[y], v[z], v[w]);}
296 static_swizzle2_ref(glm::f16, 3)
297 static_swizzle2_ref(glm::f16, 4)
298 static_swizzle2_ref(glm::f32, 2)
299 static_swizzle2_ref(glm::f32, 3)
300 static_swizzle2_ref(glm::f32, 4)
301 static_swizzle2_ref(glm::f64, 2)
302 static_swizzle2_ref(glm::f64, 3)
303 static_swizzle2_ref(glm::f64, 4)
305 static_swizzle2_ref(glm::i8, 2)
306 static_swizzle2_ref(glm::i8, 3)
307 static_swizzle2_ref(glm::i8, 4)
308 static_swizzle2_ref(glm::i16, 2)
309 static_swizzle2_ref(glm::i16, 3)
310 static_swizzle2_ref(glm::i16, 4)
311 static_swizzle2_ref(glm::i32, 2)
312 static_swizzle2_ref(glm::i32, 3)
313 static_swizzle2_ref(glm::i32, 4)
314 static_swizzle2_ref(glm::i64, 2)
315 static_swizzle2_ref(glm::i64, 3)
316 static_swizzle2_ref(glm::i64, 4)
318 static_swizzle2_ref(glm::u8, 2)
319 static_swizzle2_ref(glm::u8, 3)
320 static_swizzle2_ref(glm::u8, 4)
321 static_swizzle2_ref(glm::u16, 2)
322 static_swizzle2_ref(glm::u16, 3)
323 static_swizzle2_ref(glm::u16, 4)
324 static_swizzle2_ref(glm::u32, 2)
325 static_swizzle2_ref(glm::u32, 3)
326 static_swizzle2_ref(glm::u32, 4)
327 static_swizzle2_ref(glm::u64, 2)
328 static_swizzle2_ref(glm::u64, 3)
329 static_swizzle2_ref(glm::u64, 4)
331 static_swizzle3_ref(glm::f16, 3)
332 static_swizzle3_ref(glm::f16, 4)
333 static_swizzle3_ref(glm::f32, 3)
334 static_swizzle3_ref(glm::f32, 4)
335 static_swizzle3_ref(glm::f64, 3)
336 static_swizzle3_ref(glm::f64, 4)
338 static_swizzle3_ref(glm::i8, 3)
339 static_swizzle3_ref(glm::i8, 4)
340 static_swizzle3_ref(glm::i16, 3)
341 static_swizzle3_ref(glm::i16, 4)
342 static_swizzle3_ref(glm::i32, 3)
343 static_swizzle3_ref(glm::i32, 4)
344 static_swizzle3_ref(glm::i64, 3)
345 static_swizzle3_ref(glm::i64, 4)
347 static_swizzle3_ref(glm::u8, 3)
348 static_swizzle3_ref(glm::u8, 4)
349 static_swizzle3_ref(glm::u16, 3)
350 static_swizzle3_ref(glm::u16, 4)
351 static_swizzle3_ref(glm::u32, 3)
352 static_swizzle3_ref(glm::u32, 4)
353 static_swizzle3_ref(glm::u64, 3)
354 static_swizzle3_ref(glm::u64, 4)
356 static_swizzle4_ref(glm::f16, 4)
357 static_swizzle4_ref(glm::f32, 4)
358 static_swizzle4_ref(glm::f64, 4)
360 static_swizzle4_ref(glm::i8, 4)
361 static_swizzle4_ref(glm::i16, 4)
362 static_swizzle4_ref(glm::i32, 4)
363 static_swizzle4_ref(glm::i64, 4)
365 static_swizzle4_ref(glm::u8, 4)
366 static_swizzle4_ref(glm::u16, 4)
367 static_swizzle4_ref(glm::u32, 4)
368 static_swizzle4_ref(glm::u64, 4)
373 #include "swizzle.inl"
375 #endif//GLM_GTC_swizzle