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