type_vec4.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_gentype4
00030 #define glm_core_type_gentype4
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 tvec3;
00046 
00049         template <typename T>
00050         struct tvec4
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 tvec4<T> type;
00060                 typedef tvec4<bool> bool_type;
00061 
00063                 // Data
00064 
00065 #       if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
00066                 value_type x, y, z, w;
00067 #       elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
00068                 union 
00069                 {
00070                         struct{value_type x, y, z, w;};
00071                         struct{value_type r, g, b, a;};
00072                         struct{value_type s, t, p, q;};
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                 union {value_type w, a, q;};
00079 #       endif//GLM_COMPONENT
00080 
00082                 // Accesses
00083 
00084                 GLM_FUNC_DECL value_type & operator[](size_type i);
00085                 GLM_FUNC_DECL value_type const & operator[](size_type i) const;
00086 
00088                 // Implicit basic constructors
00089 
00090                 GLM_FUNC_DECL tvec4();
00091                 GLM_FUNC_DECL tvec4(type const & v);
00092 
00094                 // Explicit basic constructors
00095 
00096                 GLM_FUNC_DECL explicit tvec4(
00097                         ctor);
00098                 GLM_FUNC_DECL explicit tvec4(
00099                         value_type const & s);
00100                 GLM_FUNC_DECL explicit tvec4(
00101                         value_type const & s0, 
00102                         value_type const & s1, 
00103                         value_type const & s2, 
00104                         value_type const & s3);
00105 
00107                 // Swizzle constructors
00108 
00109                 GLM_FUNC_DECL tvec4(tref4<T> const & r);
00110 
00112                 // Convertion scalar constructors
00113 
00115                 template <typename U> 
00116                 GLM_FUNC_DECL explicit tvec4(
00117                         U const & x);
00119                 template <typename A, typename B, typename C, typename D> 
00120                 GLM_FUNC_DECL explicit tvec4(
00121                         A const & x, 
00122                         B const & y, 
00123                         C const & z, 
00124                         D const & w);                   
00125 
00127                 // Convertion vector constructors
00128 
00130                 template <typename A, typename B, typename C> 
00131                 GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
00133                 template <typename A, typename B, typename C> 
00134                 GLM_FUNC_DECL explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
00136                 template <typename A, typename B, typename C> 
00137                 GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
00139                 template <typename A, typename B> 
00140                 GLM_FUNC_DECL explicit tvec4(tvec3<A> const & v, B const & s);
00142                 template <typename A, typename B> 
00143                 GLM_FUNC_DECL explicit tvec4(A const & s, tvec3<B> const & v);
00145                 template <typename A, typename B> 
00146                 GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
00148                 template <typename U> 
00149                 GLM_FUNC_DECL explicit tvec4(tvec4<U> const & v);
00150 
00152                 // Unary arithmetic operators
00153 
00154                 GLM_FUNC_DECL tvec4<T> & operator= (tvec4<T> const & v);
00155                 template <typename U>
00156                 GLM_FUNC_DECL tvec4<T> & operator= (tvec4<U> const & v);
00157 
00158                 template <typename U>
00159                 GLM_FUNC_DECL tvec4<T> & operator+=(U const & s);
00160                 template <typename U>
00161                 GLM_FUNC_DECL tvec4<T> & operator+=(tvec4<U> const & v);
00162                 template <typename U>
00163                 GLM_FUNC_DECL tvec4<T> & operator-=(U const & s);
00164                 template <typename U>
00165                 GLM_FUNC_DECL tvec4<T> & operator-=(tvec4<U> const & v);
00166                 template <typename U>
00167                 GLM_FUNC_DECL tvec4<T> & operator*=(U const & s);
00168                 template <typename U>
00169                 GLM_FUNC_DECL tvec4<T> & operator*=(tvec4<U> const & v);
00170                 template <typename U>
00171                 GLM_FUNC_DECL tvec4<T> & operator/=(U const & s);
00172                 template <typename U>
00173                 GLM_FUNC_DECL tvec4<T> & operator/=(tvec4<U> const & v);
00174                 GLM_FUNC_DECL tvec4<T> & operator++();
00175                 GLM_FUNC_DECL tvec4<T> & operator--();
00176 
00178                 // Unary bit operators
00179 
00180                 template <typename U>
00181                 GLM_FUNC_DECL tvec4<T> & operator%= (U const & s);
00182                 template <typename U>
00183                 GLM_FUNC_DECL tvec4<T> & operator%= (tvec4<U> const & v);
00184                 template <typename U>
00185                 GLM_FUNC_DECL tvec4<T> & operator&= (U const & s);
00186                 template <typename U>
00187                 GLM_FUNC_DECL tvec4<T> & operator&= (tvec4<U> const & v);
00188                 template <typename U>
00189                 GLM_FUNC_DECL tvec4<T> & operator|= (U const & s);
00190                 template <typename U>
00191                 GLM_FUNC_DECL tvec4<T> & operator|= (tvec4<U> const & v);
00192                 template <typename U>
00193                 GLM_FUNC_DECL tvec4<T> & operator^= (U const & s);
00194                 template <typename U>
00195                 GLM_FUNC_DECL tvec4<T> & operator^= (tvec4<U> const & v);
00196                 template <typename U>
00197                 GLM_FUNC_DECL tvec4<T> & operator<<=(U const & s);
00198                 template <typename U>
00199                 GLM_FUNC_DECL tvec4<T> & operator<<=(tvec4<U> const & v);
00200                 template <typename U>
00201                 GLM_FUNC_DECL tvec4<T> & operator>>=(U const & s);
00202                 template <typename U>
00203                 GLM_FUNC_DECL tvec4<T> & operator>>=(tvec4<U> const & v);
00204 
00206                 // Swizzle operators
00207 
00208                 GLM_FUNC_DECL value_type swizzle(comp X) const;
00209                 GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
00210                 GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
00211                 GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
00212                 GLM_FUNC_DECL tref4<T> swizzle(comp X, comp Y, comp Z, comp W);
00213         };
00214 
00215         template <typename T>
00216         struct tref4
00217         {
00218                 GLM_FUNC_DECL tref4(T & x, T & y, T & z, T & w);
00219                 GLM_FUNC_DECL tref4(tref4<T> const & r);
00220                 GLM_FUNC_DECL tref4(tvec4<T> const & v);
00221 
00222                 GLM_FUNC_DECL tref4<T> & operator= (tref4<T> const & r);
00223                 GLM_FUNC_DECL tref4<T> & operator= (tvec4<T> const & v);
00224 
00225                 T & x;
00226                 T & y;
00227                 T & z;
00228                 T & w;
00229         };
00230 
00231         GLM_DETAIL_IS_VECTOR(tvec4);
00232 }//namespace detail
00233 
00238         typedef detail::tvec4<highp_float>              highp_vec4;
00239 
00244         typedef detail::tvec4<mediump_float>    mediump_vec4;
00245 
00250         typedef detail::tvec4<lowp_float>               lowp_vec4;
00251 
00256         typedef detail::tvec4<highp_int>                highp_ivec4;
00257 
00262         typedef detail::tvec4<mediump_int>              mediump_ivec4;
00263 
00268         typedef detail::tvec4<lowp_int>                 lowp_ivec4;
00269 
00274         typedef detail::tvec4<highp_uint>               highp_uvec4;
00275 
00280         typedef detail::tvec4<mediump_uint>             mediump_uvec4;
00281 
00286         typedef detail::tvec4<lowp_uint>                lowp_uvec4;
00287 
00288 }//namespace glm
00289 
00290 #ifndef GLM_EXTERNAL_TEMPLATE
00291 #include "type_vec4.inl"
00292 #endif//GLM_EXTERNAL_TEMPLATE
00293 
00294 #endif//glm_core_type_gentype4