type_vec2.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_gentype2
00030 #define glm_core_type_gentype2
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 tvec3;
00045         template <typename T> struct tvec4;
00046 
00049         template <typename T>
00050         struct tvec2
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 tvec2<T> type;
00060                 typedef tvec2<bool> bool_type;
00061 
00063                 // Data
00064 
00065 #               if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
00066                 value_type x, y;
00067 #               elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
00068                 union 
00069                 {
00070                         struct{value_type x, y;};
00071                         struct{value_type r, g;};
00072                         struct{value_type s, t;};
00073                 };
00074 #               else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
00075                 union {value_type x, r, s;};
00076                 union {value_type y, g, t;};
00077 #               endif//GLM_COMPONENT
00078 
00080                 // Accesses
00081 
00082                 GLM_FUNC_DECL value_type & operator[](size_type i);
00083                 GLM_FUNC_DECL value_type const & operator[](size_type i) const;
00084 
00086                 // Implicit basic constructors
00087 
00088                 GLM_FUNC_DECL tvec2();
00089                 GLM_FUNC_DECL tvec2(tvec2<T> const & v);
00090 
00092                 // Explicit basic constructors
00093 
00094                 GLM_FUNC_DECL explicit tvec2(
00095                         ctor);
00096                 GLM_FUNC_DECL explicit tvec2(
00097                         value_type const & s);
00098                 GLM_FUNC_DECL explicit tvec2(
00099                         value_type const & s1, 
00100                         value_type const & s2);
00101 
00103                 // Swizzle constructors
00104 
00105                 tvec2(tref2<T> const & r);
00106 
00108                 // Convertion constructors
00109 
00111                 template <typename U> 
00112                 GLM_FUNC_DECL explicit tvec2(
00113                         U const & x);
00115                 template <typename U, typename V> 
00116                 GLM_FUNC_DECL explicit tvec2(
00117                         U const & x, 
00118                         V const & y);
00119 
00121                 // Convertion vector constructors
00122 
00124                 template <typename U> 
00125                 GLM_FUNC_DECL explicit tvec2(tvec2<U> const & v);
00127                 template <typename U> 
00128                 GLM_FUNC_DECL explicit tvec2(tvec3<U> const & v);
00130                 template <typename U> 
00131                 GLM_FUNC_DECL explicit tvec2(tvec4<U> const & v);
00132 
00134                 // Unary arithmetic operators
00135 
00136                 GLM_FUNC_DECL tvec2<T> & operator= (tvec2<T> const & v);
00137                 template <typename U> 
00138                 GLM_FUNC_DECL tvec2<T> & operator= (tvec2<U> const & v);
00139 
00140                 template <typename U> 
00141                 GLM_FUNC_DECL tvec2<T> & operator+=(U const & s);
00142                 template <typename U> 
00143                 GLM_FUNC_DECL tvec2<T> & operator+=(tvec2<U> const & v);
00144                 template <typename U> 
00145                 GLM_FUNC_DECL tvec2<T> & operator-=(U const & s);
00146                 template <typename U> 
00147                 GLM_FUNC_DECL tvec2<T> & operator-=(tvec2<U> const & v);
00148                 template <typename U> 
00149                 GLM_FUNC_DECL tvec2<T> & operator*=(U const & s);
00150                 template <typename U> 
00151                 GLM_FUNC_DECL tvec2<T> & operator*=(tvec2<U> const & v);
00152                 template <typename U> 
00153                 GLM_FUNC_DECL tvec2<T> & operator/=(U const & s);
00154                 template <typename U> 
00155                 GLM_FUNC_DECL tvec2<T> & operator/=(tvec2<U> const & v);
00156                 GLM_FUNC_DECL tvec2<T> & operator++();
00157                 GLM_FUNC_DECL tvec2<T> & operator--();
00158 
00160                 // Unary bit operators
00161 
00162                 template <typename U> 
00163                 GLM_FUNC_DECL tvec2<T> & operator%= (U const & s);
00164                 template <typename U> 
00165                 GLM_FUNC_DECL tvec2<T> & operator%= (tvec2<U> const & v);
00166                 template <typename U> 
00167                 GLM_FUNC_DECL tvec2<T> & operator&= (U const & s);
00168                 template <typename U> 
00169                 GLM_FUNC_DECL tvec2<T> & operator&= (tvec2<U> const & v);
00170                 template <typename U> 
00171                 GLM_FUNC_DECL tvec2<T> & operator|= (U const & s);
00172                 template <typename U> 
00173                 GLM_FUNC_DECL tvec2<T> & operator|= (tvec2<U> const & v);
00174                 template <typename U> 
00175                 GLM_FUNC_DECL tvec2<T> & operator^= (U const & s);
00176                 template <typename U> 
00177                 GLM_FUNC_DECL tvec2<T> & operator^= (tvec2<U> const & v);
00178                 template <typename U> 
00179                 GLM_FUNC_DECL tvec2<T> & operator<<=(U const & s);
00180                 template <typename U> 
00181                 GLM_FUNC_DECL tvec2<T> & operator<<=(tvec2<U> const & v);
00182                 template <typename U> 
00183                 GLM_FUNC_DECL tvec2<T> & operator>>=(U const & s);
00184                 template <typename U> 
00185                 GLM_FUNC_DECL tvec2<T> & operator>>=(tvec2<U> const & v);
00186 
00188                 // Swizzle operators
00189 
00190                 GLM_FUNC_DECL value_type swizzle(comp X) const;
00191                 GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
00192                 GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
00193                 GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
00194                 GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
00195         };
00196 
00197         template <typename T>
00198         struct tref2
00199         {
00200                 GLM_FUNC_DECL tref2(T & x, T & y);
00201                 GLM_FUNC_DECL tref2(tref2<T> const & r);
00202                 GLM_FUNC_DECL tref2(tvec2<T> const & v);
00203 
00204                 GLM_FUNC_DECL tref2<T> & operator= (tref2<T> const & r);
00205                 GLM_FUNC_DECL tref2<T> & operator= (tvec2<T> const & v);
00206 
00207                 T& x;
00208                 T& y;
00209         };
00210 
00211         GLM_DETAIL_IS_VECTOR(tvec2);
00212 
00213 } //namespace detail
00214 
00219         typedef detail::tvec2<highp_float>              highp_vec2;
00220 
00225         typedef detail::tvec2<mediump_float>    mediump_vec2;
00226 
00231         typedef detail::tvec2<lowp_float>               lowp_vec2;
00232 
00237         typedef detail::tvec2<highp_int>                highp_ivec2;
00238 
00243         typedef detail::tvec2<mediump_int>              mediump_ivec2;
00244 
00249         typedef detail::tvec2<lowp_int>                 lowp_ivec2;
00250         
00255         typedef detail::tvec2<highp_uint>               highp_uvec2;
00256 
00261         typedef detail::tvec2<mediump_uint>             mediump_uvec2;
00262 
00267         typedef detail::tvec2<lowp_uint>                lowp_uvec2;
00268 
00269 }//namespace glm
00270 
00271 #ifndef GLM_EXTERNAL_TEMPLATE
00272 #include "type_vec2.inl"
00273 #endif//GLM_EXTERNAL_TEMPLATE
00274 
00275 #endif//glm_core_type_gentype2