- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List

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
    00047         // The basic 2D vector type.
    00048         // \ingroup core_template
    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
    00058                 typedef tvec2<T> type;
    00059                 typedef tvec2<bool> bool_type;
    00060
    00062                 // Data
    00063
    00064 #       if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
    00065                 union
    00066                 {
    00067 #               if(defined(GLM_SWIZZLE))
    00068                         _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y)
    00069                         _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g)
    00070                         _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t)
    00071                         _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y)
    00072                         _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g)
    00073                         _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t)
    00074                         _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y)
    00075                         _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g)
    00076                         _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t)
    00077 #               endif//(defined(GLM_SWIZZLE))
    00078
    00079                         struct{value_type r, g;};
    00080                         struct{value_type s, t;};
    00081                         struct{value_type x, y;};
    00082                 };
    00083 #       elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
    00084                 union {value_type x, r, s;};
    00085                 union {value_type y, g, t;};
    00086
    00087 #               if(defined(GLM_SWIZZLE))
    00088                         // Defines all he swizzle operator as functions
    00089                         GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2)
    00090                         GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
    00091 #               endif//(defined(GLM_SWIZZLE))
    00092 #       else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
    00093                 value_type x, y;
    00094
    00095 #               if(defined(GLM_SWIZZLE))
    00096                         // Defines all he swizzle operator as functions
    00097                         GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(value_type, detail::tvec2, detail::tref2, x, y)
    00098                         GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4, x, y)
    00099 #               endif//(defined(GLM_SWIZZLE))
    00100 #       endif//GLM_COMPONENT
    00101
    00103                 // Accesses
    00104
    00105                 GLM_FUNC_DECL value_type & operator[](size_type i);
    00106                 GLM_FUNC_DECL value_type const & operator[](size_type i) const;
    00107
    00109                 // Implicit basic constructors
    00110
    00111                 GLM_FUNC_DECL tvec2();
    00112                 GLM_FUNC_DECL tvec2(tvec2<T> const & v);
    00113
    00115                 // Explicit basic constructors
    00116
    00117                 GLM_FUNC_DECL explicit tvec2(
    00118                         ctor);
    00119                 GLM_FUNC_DECL explicit tvec2(
    00120                         value_type const & s);
    00121                 GLM_FUNC_DECL explicit tvec2(
    00122                         value_type const & s1,
    00123                         value_type const & s2);
    00124
    00126                 // Swizzle constructors
    00127
    00128                 tvec2(tref2<T> const & r);
    00129
    00130         template <int E0, int E1>
    00131         GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2<T>,E0,E1,-1,-2>& that)
    00132         {
    00133             *this = that();
    00134         }
    00135
    00137                 // Convertion constructors
    00138
    00140                 template <typename U>
    00141                 GLM_FUNC_DECL explicit tvec2(
    00142                         U const & x);
    00144                 template <typename U, typename V>
    00145                 GLM_FUNC_DECL explicit tvec2(
    00146                         U const & x,
    00147                         V const & y);
    00148
    00150                 // Convertion vector constructors
    00151
    00153                 template <typename U>
    00154                 GLM_FUNC_DECL explicit tvec2(tvec2<U> const & v);
    00156                 template <typename U>
    00157                 GLM_FUNC_DECL explicit tvec2(tvec3<U> const & v);
    00159                 template <typename U>
    00160                 GLM_FUNC_DECL explicit tvec2(tvec4<U> const & v);
    00161
    00163                 // Unary arithmetic operators
    00164
    00165                 GLM_FUNC_DECL tvec2<T> & operator= (tvec2<T> const & v);
    00166                 template <typename U>
    00167                 GLM_FUNC_DECL tvec2<T> & operator= (tvec2<U> const & v);
    00168
    00169                 template <typename U>
    00170                 GLM_FUNC_DECL tvec2<T> & operator+=(U const & s);
    00171                 template <typename U>
    00172                 GLM_FUNC_DECL tvec2<T> & operator+=(tvec2<U> const & v);
    00173                 template <typename U>
    00174                 GLM_FUNC_DECL tvec2<T> & operator-=(U const & s);
    00175                 template <typename U>
    00176                 GLM_FUNC_DECL tvec2<T> & operator-=(tvec2<U> const & v);
    00177                 template <typename U>
    00178                 GLM_FUNC_DECL tvec2<T> & operator*=(U const & s);
    00179                 template <typename U>
    00180                 GLM_FUNC_DECL tvec2<T> & operator*=(tvec2<U> const & v);
    00181                 template <typename U>
    00182                 GLM_FUNC_DECL tvec2<T> & operator/=(U const & s);
    00183                 template <typename U>
    00184                 GLM_FUNC_DECL tvec2<T> & operator/=(tvec2<U> const & v);
    00185                 GLM_FUNC_DECL tvec2<T> & operator++();
    00186                 GLM_FUNC_DECL tvec2<T> & operator--();
    00187
    00189                 // Unary bit operators
    00190
    00191                 template <typename U>
    00192                 GLM_FUNC_DECL tvec2<T> & operator%= (U const & s);
    00193                 template <typename U>
    00194                 GLM_FUNC_DECL tvec2<T> & operator%= (tvec2<U> const & v);
    00195                 template <typename U>
    00196                 GLM_FUNC_DECL tvec2<T> & operator&= (U const & s);
    00197                 template <typename U>
    00198                 GLM_FUNC_DECL tvec2<T> & operator&= (tvec2<U> const & v);
    00199                 template <typename U>
    00200                 GLM_FUNC_DECL tvec2<T> & operator|= (U const & s);
    00201                 template <typename U>
    00202                 GLM_FUNC_DECL tvec2<T> & operator|= (tvec2<U> const & v);
    00203                 template <typename U>
    00204                 GLM_FUNC_DECL tvec2<T> & operator^= (U const & s);
    00205                 template <typename U>
    00206                 GLM_FUNC_DECL tvec2<T> & operator^= (tvec2<U> const & v);
    00207                 template <typename U>
    00208                 GLM_FUNC_DECL tvec2<T> & operator<<=(U const & s);
    00209                 template <typename U>
    00210                 GLM_FUNC_DECL tvec2<T> & operator<<=(tvec2<U> const & v);
    00211                 template <typename U>
    00212                 GLM_FUNC_DECL tvec2<T> & operator>>=(U const & s);
    00213                 template <typename U>
    00214                 GLM_FUNC_DECL tvec2<T> & operator>>=(tvec2<U> const & v);
    00215
    00217                 // Swizzle operators
    00218
    00219                 GLM_FUNC_DECL value_type swizzle(comp X) const;
    00220                 GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
    00221                 GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
    00222                 GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
    00223                 GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
    00224         };
    00225
    00226         template <typename T>
    00227         struct tref2
    00228         {
    00229                 GLM_FUNC_DECL tref2(T & x, T & y);
    00230                 GLM_FUNC_DECL tref2(tref2<T> const & r);
    00231                 GLM_FUNC_DECL explicit tref2(tvec2<T> const & v);
    00232
    00233                 GLM_FUNC_DECL tref2<T> & operator= (tref2<T> const & r);
    00234                 GLM_FUNC_DECL tref2<T> & operator= (tvec2<T> const & v);
    00235
    00236                 GLM_FUNC_DECL tvec2<T> operator() ();
    00237
    00238                 T & x;
    00239                 T & y;
    00240         };
    00241
    00242         GLM_DETAIL_IS_VECTOR(tvec2);
    00243
    00244 } //namespace detail
    00245
    00248
    00254         typedef detail::tvec2<highp_float>              highp_vec2;
    00255
    00261         typedef detail::tvec2<mediump_float>    mediump_vec2;
    00262
    00268         typedef detail::tvec2<lowp_float>               lowp_vec2;
    00269
    00275         typedef detail::tvec2<highp_int>                highp_ivec2;
    00276
    00282         typedef detail::tvec2<mediump_int>              mediump_ivec2;
    00283
    00289         typedef detail::tvec2<lowp_int>                 lowp_ivec2;
    00290
    00296         typedef detail::tvec2<highp_uint>               highp_uvec2;
    00297
    00303         typedef detail::tvec2<mediump_uint>             mediump_uvec2;
    00304
    00310         typedef detail::tvec2<lowp_uint>                lowp_uvec2;
    00311
    00313 }//namespace glm
    00314
    00315 #ifndef GLM_EXTERNAL_TEMPLATE
    00316 #include "type_vec2.inl"
    00317 #endif//GLM_EXTERNAL_TEMPLATE
    00318
    00319 #endif//glm_core_type_gentype2