type_vec3.hpp

00001 
00002 // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
00004 // Created : 2008-08-22
00005 // Updated : 2010-02-03
00006 // Licence : This source is under MIT License
00007 // File    : glm/core/type_tvec3.hpp
00009 
00010 #ifndef glm_core_type_gentype3
00011 #define glm_core_type_gentype3
00012 
00013 #include "type_vec.hpp"
00014 #include "type_float.hpp"
00015 #include "type_int.hpp"
00016 #include "type_size.hpp"
00017 #include "_swizzle.hpp"
00018 
00019 namespace glm{
00020 namespace detail
00021 {
00022         template <typename T> struct tref2;
00023         template <typename T> struct tref3;
00024         template <typename T> struct tref4;
00025         template <typename T> struct tvec2;
00026         template <typename T> struct tvec4;
00027 
00030         template <typename T>
00031         struct tvec3
00032         {       
00033                 enum ctor{null};
00034 
00035                 typedef T value_type;
00036                 typedef std::size_t size_type;
00037                 GLM_FUNC_DECL size_type length() const;
00038                 static GLM_FUNC_DECL size_type value_size();
00039 
00040                 typedef tvec3<T> type;
00041                 typedef tvec3<bool> bool_type;
00042 
00044                 // Data
00045 
00046 #       if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
00047                 value_type x, y, z;
00048 #       elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
00049                 union 
00050                 {
00051                         struct{value_type x, y, z;};
00052                         struct{value_type r, g, b;};
00053                         struct{value_type s, t, p;};
00054                 };
00055 #       else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
00056                 union {value_type x, r, s;};
00057                 union {value_type y, g, t;};
00058                 union {value_type z, b, p;};
00059 #       endif//GLM_COMPONENT
00060 
00062                 // Accesses
00063 
00064                 GLM_FUNC_DECL value_type & operator[](size_type i);
00065                 GLM_FUNC_DECL value_type const & operator[](size_type i) const;
00066 
00068                 // Implicit basic constructors
00069 
00070                 GLM_FUNC_DECL tvec3();
00071                 GLM_FUNC_DECL tvec3(tvec3<T> const & v);
00072 
00074                 // Explicit basic constructors
00075 
00076                 GLM_FUNC_DECL explicit tvec3(
00077                         ctor);
00078                 GLM_FUNC_DECL explicit tvec3(
00079                         value_type const & s);
00080                 GLM_FUNC_DECL explicit tvec3(
00081                         value_type const & s1, 
00082                         value_type const & s2, 
00083                         value_type const & s3);
00084 
00086                 // Swizzle constructors
00087 
00088                 GLM_FUNC_DECL tvec3(tref3<T> const & r);
00089 
00091                 // Convertion scalar constructors
00092 
00094                 template <typename U> 
00095                 GLM_FUNC_DECL explicit tvec3(
00096                         U const & x);
00098                 template <typename U, typename V, typename W> 
00099                 GLM_FUNC_DECL explicit tvec3(
00100                         U const & x, 
00101                         V const & y, 
00102                         W const & z);                   
00103 
00105                 // Convertion vector constructors
00106 
00108                 template <typename A, typename B> 
00109                 GLM_FUNC_DECL explicit tvec3(tvec2<A> const & v, B const & s);
00111                 template <typename A, typename B> 
00112                 GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B> const & v);
00114                 template <typename U> 
00115                 GLM_FUNC_DECL explicit tvec3(tvec3<U> const & v);
00117                 template <typename U> 
00118                 GLM_FUNC_DECL explicit tvec3(tvec4<U> const & v);
00119 
00121                 // Unary arithmetic operators
00122 
00123                 GLM_FUNC_DECL tvec3<T> & operator= (tvec3<T> const & v);
00124                 template <typename U> 
00125                 GLM_FUNC_DECL tvec3<T> & operator= (tvec3<U> const & v);
00126 
00127                 template <typename U> 
00128                 GLM_FUNC_DECL tvec3<T> & operator+=(U const & s);
00129                 template <typename U> 
00130                 GLM_FUNC_DECL tvec3<T> & operator+=(tvec3<U> const & v);
00131                 template <typename U> 
00132                 GLM_FUNC_DECL tvec3<T> & operator-=(U const & s);
00133                 template <typename U> 
00134                 GLM_FUNC_DECL tvec3<T> & operator-=(tvec3<U> const & v);
00135                 template <typename U> 
00136                 GLM_FUNC_DECL tvec3<T> & operator*=(U const & s);
00137                 template <typename U> 
00138                 GLM_FUNC_DECL tvec3<T> & operator*=(tvec3<U> const & v);
00139                 template <typename U> 
00140                 GLM_FUNC_DECL tvec3<T> & operator/=(U const & s);
00141                 template <typename U> 
00142                 GLM_FUNC_DECL tvec3<T> & operator/=(tvec3<U> const & v);
00143                 GLM_FUNC_DECL tvec3<T> & operator++();
00144                 GLM_FUNC_DECL tvec3<T> & operator--();
00145 
00147                 // Unary bit operators
00148 
00149                 template <typename U>
00150                 GLM_FUNC_DECL tvec3<T> & operator%= (U const & s);
00151                 template <typename U>
00152                 GLM_FUNC_DECL tvec3<T> & operator%= (tvec3<U> const & v);
00153                 template <typename U>
00154                 GLM_FUNC_DECL tvec3<T> & operator&= (U const & s);
00155                 template <typename U>
00156                 GLM_FUNC_DECL tvec3<T> & operator&= (tvec3<U> const & v);
00157                 template <typename U>
00158                 GLM_FUNC_DECL tvec3<T> & operator|= (U const & s);
00159                 template <typename U>
00160                 GLM_FUNC_DECL tvec3<T> & operator|= (tvec3<U> const & v);
00161                 template <typename U>
00162                 GLM_FUNC_DECL tvec3<T> & operator^= (U const & s);
00163                 template <typename U>
00164                 GLM_FUNC_DECL tvec3<T> & operator^= (tvec3<U> const & v);
00165                 template <typename U>
00166                 GLM_FUNC_DECL tvec3<T> & operator<<=(U const & s);
00167                 template <typename U>
00168                 GLM_FUNC_DECL tvec3<T> & operator<<=(tvec3<U> const & v);
00169                 template <typename U>
00170                 GLM_FUNC_DECL tvec3<T> & operator>>=(U const & s);
00171                 template <typename U>
00172                 GLM_FUNC_DECL tvec3<T> & operator>>=(tvec3<U> const & v);
00173 
00175                 // Swizzle operators
00176 
00177                 GLM_FUNC_DECL value_type swizzle(comp X) const;
00178                 GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
00179                 GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
00180                 GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
00181                 GLM_FUNC_DECL tref3<T> swizzle(comp X, comp Y, comp Z);
00182         };
00183 
00184         template <typename T>
00185         struct tref3
00186         {
00187                 GLM_FUNC_DECL tref3(T & x, T & y, T & z);
00188                 GLM_FUNC_DECL tref3(tref3<T> const & r);
00189                 GLM_FUNC_DECL tref3(tvec3<T> const & v);
00190 
00191                 GLM_FUNC_DECL tref3<T> & operator= (tref3<T> const & r);
00192                 GLM_FUNC_DECL tref3<T> & operator= (tvec3<T> const & v);
00193 
00194                 T & x;
00195                 T & y;
00196                 T & z;
00197         };
00198 
00199         GLM_DETAIL_IS_VECTOR(tvec3);
00200 } //namespace detail
00201 
00202 namespace core{
00203 namespace type{
00204 namespace precision
00205 {
00210         typedef detail::tvec3<highp_float>              highp_vec3;
00211 
00216         typedef detail::tvec3<mediump_float>    mediump_vec3;
00217 
00222         typedef detail::tvec3<lowp_float>               lowp_vec3;
00223 
00228         typedef detail::tvec3<highp_int>                highp_ivec3;
00229 
00234         typedef detail::tvec3<mediump_int>              mediump_ivec3;
00235 
00240         typedef detail::tvec3<lowp_int>                 lowp_ivec3;
00241 
00246         typedef detail::tvec3<highp_uint>               highp_uvec3;
00247 
00252         typedef detail::tvec3<mediump_uint>             mediump_uvec3;
00253 
00258         typedef detail::tvec3<lowp_uint>                lowp_uvec3;
00259 
00260 }//namespace precision
00261 }//namespace type
00262 }//namespace core
00263 }//namespace glm
00264 
00265 #ifndef GLM_EXTERNAL_TEMPLATE
00266 #include "type_vec3.inl"
00267 #endif//GLM_EXTERNAL_TEMPLATE
00268 
00269 #endif//glm_core_type_gentype3