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