- Main Page
- Namespaces
- Files

- File List

# type_vec4.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_tvec4.h
    00009
    00010 #ifndef glm_core_type_gentype4
    00011 #define glm_core_type_gentype4
    00012
    00013 #include "type_float.hpp"
    00014 #include "type_int.hpp"
    00015 #include "type_size.hpp"
    00016 #include "_swizzle.hpp"
    00017 #include "_detail.hpp"
    00018
    00019 namespace glm
    00020 {
    00021         namespace test
    00022         {
    00023                 void main_vec4();
    00024         }//namespace test
    00025
    00026         namespace detail
    00027         {
    00028                 template <typename T> struct tref2;
    00029                 template <typename T> struct tref3;
    00030                 template <typename T> struct tref4;
    00031                 template <typename T> struct tvec2;
    00032                 template <typename T> struct tvec3;
    00033
    00034                 template <typename valType>
    00035                 struct tvec4
    00036                 {
    00037                         enum ctor{null};
    00038
    00040                         // Typedef (Implementation details)
    00041
    00042                         typedef valType value_type;
    00043                         typedef valType & value_reference;
    00044                         typedef valType * value_pointer;
    00045                         typedef tvec4<bool> bool_type;
    00046
    00047                         typedef glm::sizeType size_type;
    00048                         static size_type value_size();
    00049                         static bool is_vector();
    00050
    00051                         typedef tvec4<valType> type;
    00052                         typedef tvec4<valType> * pointer;
    00053                         typedef tvec4<valType> const * const_pointer;
    00054                         typedef tvec4<valType> const * const const_pointer_const;
    00055                         typedef tvec4<valType> * const pointer_const;
    00056                         typedef tvec4<valType> & reference;
    00057                         typedef tvec4<valType> const & const_reference;
    00058                         typedef tvec4<valType> const & param_type;
    00059
    00061                         // Data
    00062
    00063 #       if defined(GLM_USE_ONLY_XYZW)
    00064                         value_type x, y, z, w;
    00065 #       else//GLM_USE_ONLY_XYZW
    00066 #               ifdef GLM_USE_ANONYMOUS_UNION
    00067                         union
    00068                         {
    00069                                 struct{value_type x, y, z, w;};
    00070                                 struct{value_type r, g, b, a;};
    00071                                 struct{value_type s, t, p, q;};
    00072
    00073                         };
    00074 #               else//GLM_USE_ANONYMOUS_UNION
    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_USE_ANONYMOUS_UNION
    00080 #       endif//GLM_USE_ONLY_XYZW
    00081
    00083                         // Accesses
    00084
    00085                         valType & operator[](size_type i);
    00086                         valType const & operator[](size_type i) const;
    00087
    00089                         // Address (Implementation details)
    00090
    00091                         value_type * _address(){return (value_type*)(this);}
    00092                         value_type const * const _address() const{return (value_type*)(this);}
    00093
    00095                         // Implicit basic constructors
    00096
    00097                         tvec4();
    00098                         tvec4(typename tvec4<valType>::ctor);
    00099                         tvec4(tvec4<valType> const & v);
    00100
    00102                         // Explicit basic constructors
    00103
    00104                         explicit tvec4(valType const & s);
    00105                         explicit tvec4(valType const & s0, valType const & s1, valType const & s2, valType const & s3);
    00106
    00108                         // Swizzle constructors
    00109
    00110                         tvec4(tref4<valType> const & r);
    00111
    00113                         // Convertion scalar constructors
    00114
    00116                         template <typename valTypeU>
    00117                         explicit tvec4(valTypeU const & x);
    00119                         template <typename A, typename B, typename C, typename D>
    00120                         explicit tvec4(A const & x, B const & y, C const & z, D const & w);
    00121
    00123                         // Convertion vector constructors
    00124
    00126                         template <typename A, typename B, typename C>
    00127                         explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
    00129                         template <typename A, typename B, typename C>
    00130                         explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
    00132                         template <typename A, typename B, typename C>
    00133                         explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
    00135                         template <typename A, typename B>
    00136                         explicit tvec4(tvec3<A> const & v, B const & s);
    00138                         template <typename A, typename B>
    00139                         explicit tvec4(A const & s, tvec3<B> const & v);
    00141                         template <typename A, typename B>
    00142                         explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
    00144                         template <typename U>
    00145                         explicit tvec4(tvec4<U> const & v);
    00146
    00148                         // Unary arithmetic operators
    00149
    00150                         tvec4<valType>& operator= (tvec4<valType> const & v);
    00151
    00152                         tvec4<valType>& operator+=(valType const & s);
    00153                         tvec4<valType>& operator+=(tvec4<valType> const & v);
    00154                         tvec4<valType>& operator-=(valType const & s);
    00155                         tvec4<valType>& operator-=(tvec4<valType> const & v);
    00156                         tvec4<valType>& operator*=(valType const & s);
    00157                         tvec4<valType>& operator*=(tvec4<valType> const & v);
    00158                         tvec4<valType>& operator/=(valType const & s);
    00159                         tvec4<valType>& operator/=(tvec4<valType> const & v);
    00160                         tvec4<valType>& operator++();
    00161                         tvec4<valType>& operator--();
    00162
    00164                         // Unary bit operators
    00165
    00166                         tvec4<valType>& operator%= (valType const & s);
    00167                         tvec4<valType>& operator%= (tvec4<valType> const & v);
    00168                         tvec4<valType>& operator&= (valType const & s);
    00169                         tvec4<valType>& operator&= (tvec4<valType> const & v);
    00170                         tvec4<valType>& operator|= (valType const & s);
    00171                         tvec4<valType>& operator|= (tvec4<valType> const & v);
    00172                         tvec4<valType>& operator^= (valType const & s);
    00173                         tvec4<valType>& operator^= (tvec4<valType> const & v);
    00174                         tvec4<valType>& operator<<=(valType const & s);
    00175                         tvec4<valType>& operator<<=(tvec4<valType> const & v);
    00176                         tvec4<valType>& operator>>=(valType const & s);
    00177                         tvec4<valType>& operator>>=(tvec4<valType> const & v);
    00178
    00180                         // Swizzle operators
    00181
    00182                         valType swizzle(comp X) const;
    00183                         tvec2<valType> swizzle(comp X, comp Y) const;
    00184                         tvec3<valType> swizzle(comp X, comp Y, comp Z) const;
    00185                         tvec4<valType> swizzle(comp X, comp Y, comp Z, comp W) const;
    00186                         tref4<valType> swizzle(comp X, comp Y, comp Z, comp W);
    00187                 };
    00188
    00189                 template <typename valType>
    00190                 struct tref4
    00191                 {
    00192                         tref4(valType & x, valType & y, valType & z, valType & w);
    00193                         tref4(tref4<valType> const & r);
    00194                         tref4(tvec4<valType> const & v);
    00195
    00196                         tref4<valType>& operator= (tref4<valType> const & r);
    00197                         tref4<valType>& operator= (tvec4<valType> const & v);
    00198
    00199                         valType & x;
    00200                         valType & y;
    00201                         valType & z;
    00202                         valType & w;
    00203                 };
    00204         } //namespace detail
    00205
    00206         namespace core{
    00207         namespace type{
    00208         namespace vector{
    00209
    00211         // Boolean definition
    00212
    00215         typedef detail::tvec4<bool>                             bvec4;
    00216
    00218         // Float definition
    00219
    00220 #ifndef GLM_PRECISION
    00223         typedef detail::tvec4<mediump_float>    vec4;
    00224 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_FLOAT)
    00225         typedef detail::tvec4<highp_float>              vec4;
    00226 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_FLOAT)
    00227         typedef detail::tvec4<mediump_float>    vec4;
    00228 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_FLOAT)
    00229         typedef detail::tvec4<lowp_float>               vec4;
    00230 #endif//GLM_PRECISION
    00231
    00232         namespace precision
    00233         {
    00237                 typedef detail::tvec4<highp_float>              highp_vec4;
    00241                 typedef detail::tvec4<mediump_float>    mediump_vec4;
    00245                 typedef detail::tvec4<lowp_float>               lowp_vec4;
    00246         }
    00247         //namespace precision
    00248
    00250         // Signed integer definition
    00251
    00252 #ifndef GLM_PRECISION
    00255         typedef detail::tvec4<mediump_int>              ivec4;
    00256 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_INT)
    00257         typedef detail::tvec4<highp_int>                ivec4;
    00258 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_INT)
    00259         typedef detail::tvec4<mediump_int>              ivec4;
    00260 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_INT)
    00261         typedef detail::tvec4<lowp_int>                 ivec4;
    00262 #endif//GLM_PRECISION
    00263
    00264         namespace precision
    00265         {
    00269                 typedef detail::tvec4<highp_int>                highp_ivec4;
    00273                 typedef detail::tvec4<mediump_int>              mediump_ivec4;
    00277                 typedef detail::tvec4<lowp_int>                 lowp_ivec4;
    00278         }
    00279         //namespace precision
    00280
    00282         // Unsigned integer definition
    00283
    00284 #ifndef GLM_PRECISION
    00287         typedef detail::tvec4<mediump_uint>             uvec4;
    00288 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_UINT)
    00289         typedef detail::tvec4<highp_uint>               uvec4;
    00290 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_UINT)
    00291         typedef detail::tvec4<mediump_uint>             uvec4;
    00292 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_UINT)
    00293         typedef detail::tvec4<lowp_uint>                uvec4;
    00294 #endif//GLM_PRECISION
    00295
    00296         namespace precision
    00297         {
    00301                 typedef detail::tvec4<highp_uint>               highp_uvec4;
    00305                 typedef detail::tvec4<mediump_uint>             mediump_uvec4;
    00309                 typedef detail::tvec4<lowp_uint>                lowp_uvec4;
    00310         }
    00311         //namespace precision
    00312
    00313         }//namespace vector
    00314         }//namespace type
    00315         }//namespace core
    00316
    00317         using namespace core::type;
    00318
    00319 }//namespace glm
    00320
    00321 #include "type_vec4.inl"
    00322
    00323 #endif//glm_core_type_gentype4