swizzle.hpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 #ifndef GLM_GTC_swizzle
00039 #define GLM_GTC_swizzle GLM_VERSION
00040 
00041 // Dependency:
00042 #include "../glm.hpp"
00043 #include "../gtc/type_precision.hpp"
00044 
00045 #if(defined(GLM_MESSAGES) && !defined(glm_ext))
00046 #       pragma message("GLM: GLM_GTC_swizzle extension included")
00047 #endif
00048 
00049 namespace glm
00050 {
00053         
00054 
00055         template <typename T, template <typename> class vecType>
00056         T const & swizzle(      
00057                 vecType<T> const & v,
00058                 comp x);
00059 
00067         template <typename T, template <typename> class vecType>
00068         detail::tvec2<T> const & swizzle(
00069                 vecType<T> const & v,
00070                 comp x, comp y);
00071 
00072         template <typename T, template <typename> class vecType>
00073         detail::tvec3<T> const & swizzle(
00074                 vecType<T> const & v,
00075                 comp x, comp y, comp z);
00076 
00077         template <typename T, template <typename> class vecType>
00078         detail::tvec4<T> const & swizzle(
00079                 vecType<T> const & v,
00080                 comp x, comp y, comp z, comp w);
00081 
00082         template <typename T, template <typename> class vecType>
00083         T & swizzle(
00084                 vecType<T> & v,
00085                 comp x);
00086 
00087         template <typename T, template <typename> class vecType>
00088         detail::tref2<T> swizzle(
00089                 vecType<T> & v,
00090                 comp x, comp y);
00091 
00092         template <typename T, template <typename> class vecType>
00093         detail::tref3<T> swizzle(
00094                 vecType<T> & v,
00095                 comp x, comp y, comp z);
00096 
00097         template <typename T, template <typename> class vecType>
00098         detail::tref4<T> swizzle(
00099                 vecType<T> & v,
00100                 comp x, comp y, comp z, comp w);
00101 
00102 #       define static_swizzle1_const(TYPE, SIZE)                                                        \
00103                 template <comp x>                                                                               \
00104                 GLM_FUNC_QUALIFIER TYPE swizzle(detail::tvec##SIZE<TYPE> const & v)     \
00105                 {return v[x];}                                                                                  
00106                                                                                                                                 
00107 #       define static_swizzle1_ref(TYPE, SIZE)                                                                  \
00108                 template <comp x>                                                                                                       \
00109                 GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE<TYPE> & v)          \
00110                 {return v[x];}
00111 
00112         static_swizzle1_ref(detail::float16, 2)
00113         static_swizzle1_ref(detail::float16, 3)
00114         static_swizzle1_ref(detail::float16, 4)
00115         static_swizzle1_ref(detail::float32, 2)
00116         static_swizzle1_ref(detail::float32, 3)
00117         static_swizzle1_ref(detail::float32, 4)
00118         static_swizzle1_ref(detail::float64, 2)
00119         static_swizzle1_ref(detail::float64, 3)
00120         static_swizzle1_ref(detail::float64, 4)
00121 
00122         static_swizzle1_ref(detail::int8,  2)
00123         static_swizzle1_ref(detail::int8,  3)
00124         static_swizzle1_ref(detail::int8,  4)
00125         static_swizzle1_ref(detail::int16, 2)
00126         static_swizzle1_ref(detail::int16, 3)
00127         static_swizzle1_ref(detail::int16, 4)
00128         static_swizzle1_ref(detail::int32, 2)
00129         static_swizzle1_ref(detail::int32, 3)
00130         static_swizzle1_ref(detail::int32, 4)
00131         static_swizzle1_ref(detail::int64, 2)
00132         static_swizzle1_ref(detail::int64, 3)
00133         static_swizzle1_ref(detail::int64, 4)
00134 
00135         static_swizzle1_ref(detail::uint8,  2)
00136         static_swizzle1_ref(detail::uint8,  3)
00137         static_swizzle1_ref(detail::uint8,  4)
00138         static_swizzle1_ref(detail::uint16, 2)
00139         static_swizzle1_ref(detail::uint16, 3)
00140         static_swizzle1_ref(detail::uint16, 4)
00141         static_swizzle1_ref(detail::uint32, 2)
00142         static_swizzle1_ref(detail::uint32, 3)
00143         static_swizzle1_ref(detail::uint32, 4)
00144         static_swizzle1_ref(detail::uint64, 2)
00145         static_swizzle1_ref(detail::uint64, 3)
00146         static_swizzle1_ref(detail::uint64, 4)
00147 /*
00148 #       define static_swizzle2_const(TYPE) \
00149                 template <comp x, comp y> \
00150                 GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
00151                 {return TYPE(v[x], v[y]);}
00152 
00153 #       define static_swizzle3_const(TYPE) \
00154                 template <comp x, comp y, comp z> \
00155                 GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
00156                 {return TYPE(v[x], v[y], v[z]);}
00157 
00158 #       define static_swizzle4_const(TYPE) \
00159                 template <comp x, comp y, comp z, comp w> \
00160                 GLM_FUNC_QUALIFIER TYPE swizzle(TYPE const & v) \
00161                 {return TYPE(v[x], v[y], v[z], v[w]);}
00162 */
00163 
00164 #       define static_swizzle2_const(TYPE, SIZE)                                                                        \
00165                 template <comp x, comp y>                                                                                               \
00166                 GLM_FUNC_QUALIFIER detail::tvec2<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v)      \
00167                 {return detail::tvec2<TYPE>(v[x], v[y]);}
00168 
00169 #       define static_swizzle3_const(TYPE, SIZE)                                                                        \
00170                 template <comp x, comp y, comp z>                                                                               \
00171                 GLM_FUNC_QUALIFIER detail::tvec3<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v)      \
00172                 {return detail::tvec3<TYPE>(v[x], v[y], v[z]);}
00173 
00174 #       define static_swizzle4_const(TYPE, SIZE)                                                                        \
00175                 template <comp x, comp y, comp z, comp w>                                                               \
00176                 GLM_FUNC_QUALIFIER detail::tvec4<TYPE> swizzle(detail::tvec##SIZE<TYPE> const & v)      \
00177                 {return detail::tvec4<TYPE>(v[x], v[y], v[z], v[w]);}
00178 
00179 
00180         static_swizzle2_const(glm::f16, 2)
00181         static_swizzle2_const(glm::f16, 3)
00182         static_swizzle2_const(glm::f16, 4)
00183         static_swizzle2_const(glm::f32, 2)
00184         static_swizzle2_const(glm::f32, 3)
00185         static_swizzle2_const(glm::f32, 4)
00186         static_swizzle2_const(glm::f64, 2)
00187         static_swizzle2_const(glm::f64, 3)
00188         static_swizzle2_const(glm::f64, 4)
00189 
00190         static_swizzle2_const(glm::i8, 2)
00191         static_swizzle2_const(glm::i8, 3)
00192         static_swizzle2_const(glm::i8, 4)
00193         static_swizzle2_const(glm::i16, 2)
00194         static_swizzle2_const(glm::i16, 3)
00195         static_swizzle2_const(glm::i16, 4)
00196         static_swizzle2_const(glm::i32, 2)
00197         static_swizzle2_const(glm::i32, 3)
00198         static_swizzle2_const(glm::i32, 4)
00199         static_swizzle2_const(glm::i64, 2)
00200         static_swizzle2_const(glm::i64, 3)
00201         static_swizzle2_const(glm::i64, 4)
00202 
00203         static_swizzle2_const(glm::u8, 2)
00204         static_swizzle2_const(glm::u8, 3)
00205         static_swizzle2_const(glm::u8, 4)
00206         static_swizzle2_const(glm::u16, 2)
00207         static_swizzle2_const(glm::u16, 3)
00208         static_swizzle2_const(glm::u16, 4)
00209         static_swizzle2_const(glm::u32, 2)
00210         static_swizzle2_const(glm::u32, 3)
00211         static_swizzle2_const(glm::u32, 4)
00212         static_swizzle2_const(glm::u64, 2)
00213         static_swizzle2_const(glm::u64, 3)
00214         static_swizzle2_const(glm::u64, 4)
00215 
00216         static_swizzle3_const(glm::f16, 2)
00217         static_swizzle3_const(glm::f16, 3)
00218         static_swizzle3_const(glm::f16, 4)
00219         static_swizzle3_const(glm::f32, 2)
00220         static_swizzle3_const(glm::f32, 3)
00221         static_swizzle3_const(glm::f32, 4)
00222         static_swizzle3_const(glm::f64, 2)
00223         static_swizzle3_const(glm::f64, 3)
00224         static_swizzle3_const(glm::f64, 4)
00225 
00226         static_swizzle3_const(glm::i8, 2)
00227         static_swizzle3_const(glm::i8, 3)
00228         static_swizzle3_const(glm::i8, 4)
00229         static_swizzle3_const(glm::i16, 2)
00230         static_swizzle3_const(glm::i16, 3)
00231         static_swizzle3_const(glm::i16, 4)
00232         static_swizzle3_const(glm::i32, 2)
00233         static_swizzle3_const(glm::i32, 3)
00234         static_swizzle3_const(glm::i32, 4)
00235         static_swizzle3_const(glm::i64, 2)
00236         static_swizzle3_const(glm::i64, 3)
00237         static_swizzle3_const(glm::i64, 4)
00238 
00239         static_swizzle3_const(glm::u8, 2)
00240         static_swizzle3_const(glm::u8, 3)
00241         static_swizzle3_const(glm::u8, 4)
00242         static_swizzle3_const(glm::u16, 2)
00243         static_swizzle3_const(glm::u16, 3)
00244         static_swizzle3_const(glm::u16, 4)
00245         static_swizzle3_const(glm::u32, 2)
00246         static_swizzle3_const(glm::u32, 3)
00247         static_swizzle3_const(glm::u32, 4)
00248         static_swizzle3_const(glm::u64, 2)
00249         static_swizzle3_const(glm::u64, 3)
00250         static_swizzle3_const(glm::u64, 4)
00251 
00252         static_swizzle4_const(glm::f16, 2)
00253         static_swizzle4_const(glm::f16, 3)
00254         static_swizzle4_const(glm::f16, 4)
00255         static_swizzle4_const(glm::f32, 2)
00256         static_swizzle4_const(glm::f32, 3)
00257         static_swizzle4_const(glm::f32, 4)
00258         static_swizzle4_const(glm::f64, 2)
00259         static_swizzle4_const(glm::f64, 3)
00260         static_swizzle4_const(glm::f64, 4)
00261 
00262         static_swizzle4_const(glm::i8, 2)
00263         static_swizzle4_const(glm::i8, 3)
00264         static_swizzle4_const(glm::i8, 4)
00265         static_swizzle4_const(glm::i16, 2)
00266         static_swizzle4_const(glm::i16, 3)
00267         static_swizzle4_const(glm::i16, 4)
00268         static_swizzle4_const(glm::i32, 2)
00269         static_swizzle4_const(glm::i32, 3)
00270         static_swizzle4_const(glm::i32, 4)
00271         static_swizzle4_const(glm::i64, 2)
00272         static_swizzle4_const(glm::i64, 3)
00273         static_swizzle4_const(glm::i64, 4)
00274 
00275         static_swizzle4_const(glm::u8, 2)
00276         static_swizzle4_const(glm::u8, 3)
00277         static_swizzle4_const(glm::u8, 4)
00278         static_swizzle4_const(glm::u16, 2)
00279         static_swizzle4_const(glm::u16, 3)
00280         static_swizzle4_const(glm::u16, 4)
00281         static_swizzle4_const(glm::u32, 2)
00282         static_swizzle4_const(glm::u32, 3)
00283         static_swizzle4_const(glm::u32, 4)
00284         static_swizzle4_const(glm::u64, 2)
00285         static_swizzle4_const(glm::u64, 3)
00286         static_swizzle4_const(glm::u64, 4)
00287 
00288 #       define static_swizzle2_ref(TYPE, SIZE) \
00289                 template <glm::comp x, glm::comp y> \
00290                 GLM_FUNC_QUALIFIER glm::detail::tref2<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
00291                 {return glm::detail::tref2<TYPE>(v[x], v[y]);}  
00292 
00293 #       define static_swizzle3_ref(TYPE, SIZE) \
00294                 template <glm::comp x, glm::comp y, glm::comp z> \
00295                 GLM_FUNC_QUALIFIER glm::detail::tref3<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
00296                 {return glm::detail::tref3<TYPE>(v[x], v[y], v[z]);}    
00297 
00298 #       define static_swizzle4_ref(TYPE, SIZE) \
00299                 template <glm::comp x, glm::comp y, glm::comp z, glm::comp w> \
00300                 GLM_FUNC_QUALIFIER glm::detail::tref4<TYPE> swizzle(detail::tvec##SIZE<TYPE> & v) \
00301                 {return glm::detail::tref4<TYPE>(v[x], v[y], v[z], v[w]);}      
00302 
00303         static_swizzle2_ref(glm::f16, 2)
00304         static_swizzle2_ref(glm::f16, 3)
00305         static_swizzle2_ref(glm::f16, 4)
00306         static_swizzle2_ref(glm::f32, 2)
00307         static_swizzle2_ref(glm::f32, 3)
00308         static_swizzle2_ref(glm::f32, 4)
00309         static_swizzle2_ref(glm::f64, 2)
00310         static_swizzle2_ref(glm::f64, 3)
00311         static_swizzle2_ref(glm::f64, 4)
00312 
00313         static_swizzle2_ref(glm::i8, 2)
00314         static_swizzle2_ref(glm::i8, 3)
00315         static_swizzle2_ref(glm::i8, 4)
00316         static_swizzle2_ref(glm::i16, 2)
00317         static_swizzle2_ref(glm::i16, 3)
00318         static_swizzle2_ref(glm::i16, 4)
00319         static_swizzle2_ref(glm::i32, 2)
00320         static_swizzle2_ref(glm::i32, 3)
00321         static_swizzle2_ref(glm::i32, 4)
00322         static_swizzle2_ref(glm::i64, 2)
00323         static_swizzle2_ref(glm::i64, 3)
00324         static_swizzle2_ref(glm::i64, 4)
00325 
00326         static_swizzle2_ref(glm::u8, 2)
00327         static_swizzle2_ref(glm::u8, 3)
00328         static_swizzle2_ref(glm::u8, 4)
00329         static_swizzle2_ref(glm::u16, 2)
00330         static_swizzle2_ref(glm::u16, 3)
00331         static_swizzle2_ref(glm::u16, 4)
00332         static_swizzle2_ref(glm::u32, 2)
00333         static_swizzle2_ref(glm::u32, 3)
00334         static_swizzle2_ref(glm::u32, 4)
00335         static_swizzle2_ref(glm::u64, 2)
00336         static_swizzle2_ref(glm::u64, 3)
00337         static_swizzle2_ref(glm::u64, 4)
00338 
00339         static_swizzle3_ref(glm::f16, 3)
00340         static_swizzle3_ref(glm::f16, 4)
00341         static_swizzle3_ref(glm::f32, 3)
00342         static_swizzle3_ref(glm::f32, 4)
00343         static_swizzle3_ref(glm::f64, 3)
00344         static_swizzle3_ref(glm::f64, 4)
00345 
00346         static_swizzle3_ref(glm::i8, 3)
00347         static_swizzle3_ref(glm::i8, 4)
00348         static_swizzle3_ref(glm::i16, 3)
00349         static_swizzle3_ref(glm::i16, 4)
00350         static_swizzle3_ref(glm::i32, 3)
00351         static_swizzle3_ref(glm::i32, 4)
00352         static_swizzle3_ref(glm::i64, 3)
00353         static_swizzle3_ref(glm::i64, 4)
00354 
00355         static_swizzle3_ref(glm::u8, 3)
00356         static_swizzle3_ref(glm::u8, 4)
00357         static_swizzle3_ref(glm::u16, 3)
00358         static_swizzle3_ref(glm::u16, 4)
00359         static_swizzle3_ref(glm::u32, 3)
00360         static_swizzle3_ref(glm::u32, 4)
00361         static_swizzle3_ref(glm::u64, 3)
00362         static_swizzle3_ref(glm::u64, 4)
00363 
00364         static_swizzle4_ref(glm::f16, 4)
00365         static_swizzle4_ref(glm::f32, 4)
00366         static_swizzle4_ref(glm::f64, 4)
00367 
00368         static_swizzle4_ref(glm::i8, 4)
00369         static_swizzle4_ref(glm::i16, 4)
00370         static_swizzle4_ref(glm::i32, 4)
00371         static_swizzle4_ref(glm::i64, 4)
00372 
00373         static_swizzle4_ref(glm::u8, 4)
00374         static_swizzle4_ref(glm::u16, 4)
00375         static_swizzle4_ref(glm::u32, 4)
00376         static_swizzle4_ref(glm::u64, 4)
00377 
00379 }//namespace glm
00380 
00381 #include "swizzle.inl"
00382 
00383 #endif//GLM_GTC_swizzle