# GLM: type_vec3.hpp Source File

- Main Page
- Namespaces
- Files

- File List

# type_vec3.hpp

    00001
    00002 // OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
    00004 // Created : 2008-08-22
    00005 // Updated : 2008-08-31
    00006 // Licence : This source is under MIT License
    00007 // File    : glm/core/type_tvec3.h
    00009
    00010 #ifndef glm_core_type_gentype3
    00011 #define glm_core_type_gentype3
    00012
    00013 #include "type_float.hpp"
    00014 #include "type_int.hpp"
    00015 #include "type_size.hpp"
    00016 #include "_swizzle.hpp"
    00017
    00018 namespace glm
    00019 {
    00020         namespace test
    00021         {
    00022                 void main_vec3();
    00023         }//namespace test
    00024
    00025         namespace detail
    00026         {
    00027                 template <typename T> struct tref2;
    00028                 template <typename T> struct tref3;
    00029                 template <typename T> struct tref4;
    00030                 template <typename T> struct tvec2;
    00031                 template <typename T> struct tvec4;
    00032
    00033                 template <typename valType>
    00034                 struct tvec3
    00035                 {
    00037                         // Typedef (Implementation details)
    00038
    00039                         typedef valType value_type;
    00040                         typedef valType& value_reference;
    00041                         typedef valType* value_pointer;
    00042                         typedef tvec3<bool> bool_type;
    00043
    00044                         typedef glm::sizeType size_type;
    00045                         static size_type value_size();
    00046                         static bool is_vector();
    00047
    00048                         typedef tvec3<valType> type;
    00049                         typedef tvec3<valType>* pointer;
    00050                         typedef tvec3<valType> const * const_pointer;
    00051                         typedef tvec3<valType> const * const const_pointer_const;
    00052                         typedef tvec3<valType> * const pointer_const;
    00053                         typedef tvec3<valType>& reference;
    00054                         typedef tvec3<valType> const & const_reference;
    00055                         typedef tvec3<valType> const & param_type;
    00056
    00058                         // Data
    00059
    00060 #       if defined(GLM_USE_ONLY_XYZW)
    00061                         value_type x, y, z;
    00062 #       else//GLM_USE_ONLY_XYZW
    00063 #               ifdef GLM_USE_ANONYMOUS_UNION
    00064                         union
    00065                         {
    00066                                 struct{value_type x, y, z;};
    00067                                 struct{value_type r, g, b;};
    00068                                 struct{value_type s, t, p;};
    00069                         };
    00070 #               else//GLM_USE_ANONYMOUS_UNION
    00071                         union {value_type x, r, s;};
    00072                         union {value_type y, g, t;};
    00073                         union {value_type z, b, p;};
    00074 #               endif//GLM_USE_ANONYMOUS_UNION
    00075 #       endif//GLM_USE_ONLY_XYZW
    00076
    00078                         // Accesses
    00079
    00080                         valType & operator[](size_type i);
    00081                         valType const & operator[](size_type i) const;
    00082
    00084                         // Address (Implementation details)
    00085
    00086                         value_type const * _address() const{return (value_type*)(this);}
    00087                         value_type* _address(){return (value_type*)(this);}
    00088
    00090                         // Implicit basic constructors
    00091
    00092                         tvec3();
    00093                         tvec3(tvec3<valType> const & v);
    00094
    00096                         // Explicit basic constructors
    00097
    00098                         explicit tvec3(valType s);
    00099                         explicit tvec3(valType s1, valType s2, valType s3);
    00100
    00102                         // Swizzle constructors
    00103
    00104                         tvec3(tref3<valType> const & r);
    00105
    00107                         // Convertion scalar constructors
    00108
    00110                         template <typename U>
    00111                         explicit tvec3(U x);
    00113                         template <typename U, typename V, typename W>
    00114                         explicit tvec3(U x, V y, W z);
    00115
    00117                         // Convertion vector constructors
    00118
    00120                         template <typename A, typename B>
    00121                         explicit tvec3(tvec2<A> const & v, B s);
    00123                         template <typename A, typename B>
    00124                         explicit tvec3(A s, tvec2<B> const & v);
    00126                         template <typename U>
    00127                         explicit tvec3(tvec3<U> const & v);
    00129                         template <typename U>
    00130                         explicit tvec3(tvec4<U> const & v);
    00131
    00133                         // Unary arithmetic operators
    00134
    00135                         tvec3<valType>& operator= (tvec3<valType> const & v);
    00136
    00137                         tvec3<valType>& operator+=(valType const & s);
    00138                         tvec3<valType>& operator+=(tvec3<valType> const & v);
    00139                         tvec3<valType>& operator-=(valType const & s);
    00140                         tvec3<valType>& operator-=(tvec3<valType> const & v);
    00141                         tvec3<valType>& operator*=(valType const & s);
    00142                         tvec3<valType>& operator*=(tvec3<valType> const & v);
    00143                         tvec3<valType>& operator/=(valType const & s);
    00144                         tvec3<valType>& operator/=(tvec3<valType> const & v);
    00145                         tvec3<valType>& operator++();
    00146                         tvec3<valType>& operator--();
    00147
    00149                         // Unary bit operators
    00150
    00151                         tvec3<valType>& operator%=(valType const & s);
    00152                         tvec3<valType>& operator%=(tvec3<valType> const & v);
    00153                         tvec3<valType>& operator&=(valType const & s);
    00154                         tvec3<valType>& operator&=(tvec3<valType> const & v);
    00155                         tvec3<valType>& operator|=(valType const & s);
    00156                         tvec3<valType>& operator|=(tvec3<valType> const & v);
    00157                         tvec3<valType>& operator^=(valType const & s);
    00158                         tvec3<valType>& operator^=(tvec3<valType> const & v);
    00159                         tvec3<valType>& operator<<=(valType const & s);
    00160                         tvec3<valType>& operator<<=(tvec3<valType> const & v);
    00161                         tvec3<valType>& operator>>=(valType const & s);
    00162                         tvec3<valType>& operator>>=(tvec3<valType> const & v);
    00163
    00165                         // Swizzle operators
    00166
    00167                         valType swizzle(comp X) const;
    00168                         tvec2<valType> swizzle(comp X, comp Y) const;
    00169                         tvec3<valType> swizzle(comp X, comp Y, comp Z) const;
    00170                         tvec4<valType> swizzle(comp X, comp Y, comp Z, comp W) const;
    00171                         tref3<valType> swizzle(comp X, comp Y, comp Z);
    00172                 };
    00173
    00174                 template <typename T>
    00175                 struct tref3
    00176                 {
    00177                         tref3(T& x, T& y, T& z);
    00178                         tref3(tref3<T> const & r);
    00179                         tref3(tvec3<T> const & v);
    00180
    00181                         tref3<T>& operator= (tref3<T> const & r);
    00182                         tref3<T>& operator= (tvec3<T> const & v);
    00183
    00184                         T& x;
    00185                         T& y;
    00186                         T& z;
    00187                 };
    00188         } //namespace detail
    00189
    00190         namespace core{
    00191         namespace type{
    00192         namespace vector{
    00193
    00195         // Boolean definition
    00196
    00199         typedef detail::tvec3<bool>                             bvec3;
    00200
    00202         // Float definition
    00203
    00204 #ifndef GLM_PRECISION
    00207         typedef detail::tvec3<mediump_float>    vec3;
    00208 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_FLOAT)
    00209         typedef detail::tvec3<highp_float>              vec3;
    00210 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_FLOAT)
    00211         typedef detail::tvec3<mediump_float>    vec3;
    00212 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_FLOAT)
    00213         typedef detail::tvec3<lowp_float>               vec3;
    00214 #else
    00215         typedef detail::tvec3<mediump_float>    vec3;
    00216 #endif//GLM_PRECISION
    00217
    00218         namespace precision
    00219         {
    00223                 typedef detail::tvec3<highp_float>              highp_vec3;
    00227                 typedef detail::tvec3<mediump_float>    mediump_vec3;
    00231                 typedef detail::tvec3<lowp_float>               lowp_vec3;
    00232         }
    00233         //namespace precision
    00234
    00236         // Signed integer definition
    00237
    00238 #ifndef GLM_PRECISION
    00241         typedef detail::tvec3<mediump_int>              ivec3;
    00242 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_INT)
    00243         typedef detail::tvec3<highp_int>                ivec3;
    00244 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_INT)
    00245         typedef detail::tvec3<mediump_int>              ivec3;
    00246 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_INT)
    00247         typedef detail::tvec3<lowp_int>                 ivec3;
    00248 #else
    00249         typedef detail::tvec3<mediump_int>              ivec3;
    00250 #endif//GLM_PRECISION
    00251
    00252         namespace precision
    00253         {
    00257                 typedef detail::tvec3<highp_int>                highp_ivec3;
    00261                 typedef detail::tvec3<mediump_int>              mediump_ivec3;
    00265                 typedef detail::tvec3<lowp_int>                 lowp_ivec3;
    00266         }
    00267         //namespace precision
    00268
    00270         // Unsigned integer definition
    00271
    00272 #ifndef GLM_PRECISION
    00275         typedef detail::tvec3<mediump_uint>             uvec3;
    00276 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_UINT)
    00277         typedef detail::tvec3<highp_uint>               uvec3;
    00278 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_UINT)
    00279         typedef detail::tvec3<mediump_uint>             uvec3;
    00280 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_UINT)
    00281         typedef detail::tvec3<lowp_uint>                uvec3;
    00282 #else
    00283         typedef detail::tvec3<mediump_uint>             uvec3;
    00284 #endif//GLM_PRECISION
    00285
    00286         namespace precision
    00287         {
    00291                 typedef detail::tvec3<highp_uint>               highp_uvec3;
    00295                 typedef detail::tvec3<mediump_uint>             mediump_uvec3;
    00299                 typedef detail::tvec3<lowp_uint>                lowp_uvec3;
    00300         }
    00301         //namespace precision
    00302
    00303         }//namespace vector
    00304         }//namespace type
    00305         }//namespace core
    00306 }//namespace glm
    00307
    00308 #include "type_vec3.inl"
    00309
    00310 #endif//glm_core_type_gentype3