type_vec3.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 #ifndef glm_core_type_gentype3
00030 #define glm_core_type_gentype3
00031 
00032 #include "type_vec.hpp"
00033 #include "type_float.hpp"
00034 #include "type_int.hpp"
00035 #include "type_size.hpp"
00036 #include "_swizzle.hpp"
00037 
00038 namespace glm{
00039 namespace detail
00040 {
00041         template <typename T> struct tref2;
00042         template <typename T> struct tref3;
00043         template <typename T> struct tref4;
00044         template <typename T> struct tvec2;
00045         template <typename T> struct tvec4;
00046 
00049         template <typename T>
00050         struct tvec3
00051         {       
00052                 enum ctor{null};
00053 
00054                 typedef T value_type;
00055                 typedef std::size_t size_type;
00056                 GLM_FUNC_DECL size_type length() const;
00057                 static GLM_FUNC_DECL size_type value_size();
00058 
00059                 typedef tvec3<T> type;
00060                 typedef tvec3<bool> bool_type;
00061 
00063                 // Data
00064 
00065 #       if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
00066                 value_type x, y, z;
00067 #       elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
00068                 union 
00069                 {
00070                         struct{value_type x, y, z;};
00071                         struct{value_type r, g, b;};
00072                         struct{value_type s, t, p;};
00073                 };
00074 #       else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
00075                 union {value_type x, r, s;};
00076                 union {value_type y, g, t;};
00077                 union {value_type z, b, p;};
00078 #       endif//GLM_COMPONENT
00079 
00081                 // Accesses
00082 
00083                 GLM_FUNC_DECL value_type & operator[](size_type i);
00084                 GLM_FUNC_DECL value_type const & operator[](size_type i) const;
00085 
00087                 // Implicit basic constructors
00088 
00089                 GLM_FUNC_DECL tvec3();
00090                 GLM_FUNC_DECL tvec3(tvec3<T> const & v);
00091 
00093                 // Explicit basic constructors
00094 
00095                 GLM_FUNC_DECL explicit tvec3(
00096                         ctor);
00097                 GLM_FUNC_DECL explicit tvec3(
00098                         value_type const & s);
00099                 GLM_FUNC_DECL explicit tvec3(
00100                         value_type const & s1, 
00101                         value_type const & s2, 
00102                         value_type const & s3);
00103 
00105                 // Swizzle constructors
00106 
00107                 GLM_FUNC_DECL tvec3(tref3<T> const & r);
00108 
00110                 // Convertion scalar constructors
00111 
00113                 template <typename U> 
00114                 GLM_FUNC_DECL explicit tvec3(
00115                         U const & x);
00117                 template <typename U, typename V, typename W> 
00118                 GLM_FUNC_DECL explicit tvec3(
00119                         U const & x, 
00120                         V const & y, 
00121                         W const & z);                   
00122 
00124                 // Convertion vector constructors
00125 
00127                 template <typename A, typename B> 
00128                 GLM_FUNC_DECL explicit tvec3(tvec2<A> const & v, B const & s);
00130                 template <typename A, typename B> 
00131                 GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B> const & v);
00133                 template <typename U> 
00134                 GLM_FUNC_DECL explicit tvec3(tvec3<U> const & v);
00136                 template <typename U> 
00137                 GLM_FUNC_DECL explicit tvec3(tvec4<U> const & v);
00138 
00140                 // Unary arithmetic operators
00141 
00142                 GLM_FUNC_DECL tvec3<T> & operator= (tvec3<T> const & v);
00143                 template <typename U> 
00144                 GLM_FUNC_DECL tvec3<T> & operator= (tvec3<U> const & v);
00145 
00146                 template <typename U> 
00147                 GLM_FUNC_DECL tvec3<T> & operator+=(U const & s);
00148                 template <typename U> 
00149                 GLM_FUNC_DECL tvec3<T> & operator+=(tvec3<U> const & v);
00150                 template <typename U> 
00151                 GLM_FUNC_DECL tvec3<T> & operator-=(U const & s);
00152                 template <typename U> 
00153                 GLM_FUNC_DECL tvec3<T> & operator-=(tvec3<U> const & v);
00154                 template <typename U> 
00155                 GLM_FUNC_DECL tvec3<T> & operator*=(U const & s);
00156                 template <typename U> 
00157                 GLM_FUNC_DECL tvec3<T> & operator*=(tvec3<U> const & v);
00158                 template <typename U> 
00159                 GLM_FUNC_DECL tvec3<T> & operator/=(U const & s);
00160                 template <typename U> 
00161                 GLM_FUNC_DECL tvec3<T> & operator/=(tvec3<U> const & v);
00162                 GLM_FUNC_DECL tvec3<T> & operator++();
00163                 GLM_FUNC_DECL tvec3<T> & operator--();
00164 
00166                 // Unary bit operators
00167 
00168                 template <typename U>
00169                 GLM_FUNC_DECL tvec3<T> & operator%= (U const & s);
00170                 template <typename U>
00171                 GLM_FUNC_DECL tvec3<T> & operator%= (tvec3<U> const & v);
00172                 template <typename U>
00173                 GLM_FUNC_DECL tvec3<T> & operator&= (U const & s);
00174                 template <typename U>
00175                 GLM_FUNC_DECL tvec3<T> & operator&= (tvec3<U> const & v);
00176                 template <typename U>
00177                 GLM_FUNC_DECL tvec3<T> & operator|= (U const & s);
00178                 template <typename U>
00179                 GLM_FUNC_DECL tvec3<T> & operator|= (tvec3<U> const & v);
00180                 template <typename U>
00181                 GLM_FUNC_DECL tvec3<T> & operator^= (U const & s);
00182                 template <typename U>
00183                 GLM_FUNC_DECL tvec3<T> & operator^= (tvec3<U> const & v);
00184                 template <typename U>
00185                 GLM_FUNC_DECL tvec3<T> & operator<<=(U const & s);
00186                 template <typename U>
00187                 GLM_FUNC_DECL tvec3<T> & operator<<=(tvec3<U> const & v);
00188                 template <typename U>
00189                 GLM_FUNC_DECL tvec3<T> & operator>>=(U const & s);
00190                 template <typename U>
00191                 GLM_FUNC_DECL tvec3<T> & operator>>=(tvec3<U> const & v);
00192 
00194                 // Swizzle operators
00195 
00196                 GLM_FUNC_DECL value_type swizzle(comp X) const;
00197                 GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
00198                 GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
00199                 GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
00200                 GLM_FUNC_DECL tref3<T> swizzle(comp X, comp Y, comp Z);
00201         };
00202 
00203         template <typename T>
00204         struct tref3
00205         {
00206                 GLM_FUNC_DECL tref3(T & x, T & y, T & z);
00207                 GLM_FUNC_DECL tref3(tref3<T> const & r);
00208                 GLM_FUNC_DECL tref3(tvec3<T> const & v);
00209 
00210                 GLM_FUNC_DECL tref3<T> & operator= (tref3<T> const & r);
00211                 GLM_FUNC_DECL tref3<T> & operator= (tvec3<T> const & v);
00212 
00213                 T & x;
00214                 T & y;
00215                 T & z;
00216         };
00217 
00218         GLM_DETAIL_IS_VECTOR(tvec3);
00219 } //namespace detail
00220 
00225         typedef detail::tvec3<highp_float>              highp_vec3;
00226 
00231         typedef detail::tvec3<mediump_float>    mediump_vec3;
00232 
00237         typedef detail::tvec3<lowp_float>               lowp_vec3;
00238 
00243         typedef detail::tvec3<highp_int>                highp_ivec3;
00244 
00249         typedef detail::tvec3<mediump_int>              mediump_ivec3;
00250 
00255         typedef detail::tvec3<lowp_int>                 lowp_ivec3;
00256 
00261         typedef detail::tvec3<highp_uint>               highp_uvec3;
00262 
00267         typedef detail::tvec3<mediump_uint>             mediump_uvec3;
00268 
00273         typedef detail::tvec3<lowp_uint>                lowp_uvec3;
00274 
00275 }//namespace glm
00276 
00277 #ifndef GLM_EXTERNAL_TEMPLATE
00278 #include "type_vec3.inl"
00279 #endif//GLM_EXTERNAL_TEMPLATE
00280 
00281 #endif//glm_core_type_gentype3