- Main Page
- Namespaces
- Files

- File List

# type_vec1.hpp

    00001
    00002 // OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
    00004 // Created : 2008-08-25
    00005 // Updated : 2008-08-31
    00006 // Licence : This source is under MIT License
    00007 // File    : glm/core/type_vec1.h
    00009
    00010 #ifndef glm_core_type_gentype1
    00011 #define glm_core_type_gentype1
    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_vec1();
    00023         }//namespace test
    00024
    00025         namespace detail
    00026         {
    00027                 template <typename T> struct tref1;
    00028                 template <typename T> struct tref2;
    00029                 template <typename T> struct tref3;
    00030                 template <typename T> struct tref4;
    00031                 template <typename T> struct tvec1;
    00032                 template <typename T> struct tvec2;
    00033                 template <typename T> struct tvec3;
    00034                 template <typename T> struct tvec4;
    00035
    00036                 template <typename valType>
    00037                 struct tvec1
    00038                 {
    00040                         // Typedef (Implementation details)
    00041
    00042                         typedef valType value_type;
    00043                         typedef valType& value_reference;
    00044                         typedef valType* value_pointer;
    00045                         typedef tvec1<bool> bool_type;
    00046
    00047                         typedef glm::sizeType size_type;
    00048                         static size_type value_size();
    00049                         static bool is_vector();
    00050
    00051                         typedef tvec1<valType> type;
    00052                         typedef tvec1<valType>* pointer;
    00053                         typedef const tvec1<valType>* const_pointer;
    00054                         typedef const tvec1<valType>*const const_pointer_const;
    00055                         typedef tvec1<valType>*const pointer_const;
    00056                         typedef tvec1<valType>& reference;
    00057                         typedef const tvec1<valType>& const_reference;
    00058                         typedef const tvec1<valType>& param_type;
    00059
    00061                         // Data
    00062
    00063 #       if defined(GLM_USE_ONLY_XYZW)
    00064                         value_type x, y;
    00065 #       else//GLM_USE_ONLY_XYZW
    00066                         union {value_type x, r, s;};
    00067 #       endif//GLM_USE_ONLY_XYZW
    00068
    00070                         // Accesses
    00071
    00072                         valType& operator[](size_type i);
    00073                         valType const & operator[](size_type i) const;
    00074
    00076                         // Address (Implementation details)
    00077
    00078                         const value_type* _address() const{return (value_type*)(this);}
    00079                         value_type* _address(){return (value_type*)(this);}
    00080
    00082                         // Implicit basic constructors
    00083
    00084                         tvec1();
    00085                         tvec1(const tvec1<valType>& v);
    00086
    00088                         // Explicit basic constructors
    00089
    00090                         tvec1(valType s);
    00091
    00093                         // Swizzle constructors
    00094
    00095                         tvec1(const tref1<valType>& r);
    00096
    00098                         // Convertion scalar constructors
    00099
    00101                         template <typename U>
    00102                         explicit tvec1(U x);
    00103
    00105                         // Convertion vector constructors
    00106
    00108                         template <typename U>
    00109                         explicit tvec1(const tvec2<U>& v);
    00111                         template <typename U>
    00112                         explicit tvec1(const tvec3<U>& v);
    00114                         template <typename U>
    00115                         explicit tvec1(const tvec4<U>& v);
    00116
    00118                         // Unary arithmetic operators
    00119
    00120                         tvec1<valType>& operator= (const tvec1<valType>& v);
    00121
    00122                         tvec1<valType>& operator+=(valType const & s);
    00123                         tvec1<valType>& operator+=(const tvec1<valType>& v);
    00124                         tvec1<valType>& operator-=(valType const & s);
    00125                         tvec1<valType>& operator-=(const tvec1<valType>& v);
    00126                         tvec1<valType>& operator*=(valType const & s);
    00127                         tvec1<valType>& operator*=(const tvec1<valType>& v);
    00128                         tvec1<valType>& operator/=(valType const & s);
    00129                         tvec1<valType>& operator/=(const tvec1<valType>& v);
    00130                         tvec1<valType>& operator++();
    00131                         tvec1<valType>& operator--();
    00132
    00134                         // Unary bit operators
    00135
    00136                         tvec1<valType>& operator%=(valType const & s);
    00137                         tvec1<valType>& operator%=(const tvec1<valType>& v);
    00138                         tvec1<valType>& operator&=(valType const & s);
    00139                         tvec1<valType>& operator&=(const tvec1<valType>& v);
    00140                         tvec1<valType>& operator|=(valType const & s);
    00141                         tvec1<valType>& operator|=(const tvec1<valType>& v);
    00142                         tvec1<valType>& operator^=(valType const & s);
    00143                         tvec1<valType>& operator^=(const tvec1<valType>& v);
    00144                         tvec1<valType>& operator<<=(valType const & s);
    00145                         tvec1<valType>& operator<<=(const tvec1<valType>& v);
    00146                         tvec1<valType>& operator>>=(valType const & s);
    00147                         tvec1<valType>& operator>>=(const tvec1<valType>& v);
    00148
    00150                         // Swizzle operators
    00151
    00152                         valType swizzle(comp X) const;
    00153                         tvec2<valType> swizzle(comp X, comp Y) const;
    00154                         tvec3<valType> swizzle(comp X, comp Y, comp Z) const;
    00155                         tvec4<valType> swizzle(comp X, comp Y, comp Z, comp W) const;
    00156                         tref1<valType> swizzle(comp X);
    00157                 };
    00158
    00159                 template <typename T>
    00160                 struct tref1
    00161                 {
    00162                         tref1(T& x);
    00163                         tref1(const tref1<T>& r);
    00164                         tref1(const tvec1<T>& v);
    00165
    00166                         tref1<T>& operator= (const tref1<T>& r);
    00167                         tref1<T>& operator= (const tvec1<T>& v);
    00168
    00169                         T& x;
    00170                 };
    00171         } //namespace detail
    00172
    00173         namespace core{
    00174         namespace type{
    00175         namespace vector{
    00176
    00178         // Boolean definition
    00179
    00180         typedef detail::tvec1<bool>                             bvec1;
    00181
    00183         // Float definition
    00184
    00185 #ifndef GLM_PRECISION
    00186         typedef detail::tvec1<mediump_float>    vec1;
    00187 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_FLOAT)
    00188         typedef detail::tvec1<highp_float>              vec1;
    00189 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_FLOAT)
    00190         typedef detail::tvec1<mediump_float>    vec1;
    00191 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_FLOAT)
    00192         typedef detail::tvec1<lowp_float>               vec1;
    00193 #else
    00194         typedef detail::tvec1<mediump_float>    vec1;
    00195 #endif//GLM_PRECISION
    00196
    00197         namespace precision
    00198         {
    00199                 typedef detail::tvec1<highp_float>              highp_vec1;
    00200                 typedef detail::tvec1<mediump_float>    mediump_vec1;
    00201                 typedef detail::tvec1<lowp_float>               lowp_vec1;
    00202         }
    00203         //namespace precision
    00204
    00206         // Signed integer definition
    00207
    00208 #ifndef GLM_PRECISION
    00209         typedef detail::tvec1<mediump_int>              ivec1;
    00210 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_INT)
    00211         typedef detail::tvec1<highp_int>                ivec1;
    00212 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_INT)
    00213         typedef detail::tvec1<mediump_int>              ivec1;
    00214 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_INT)
    00215         typedef detail::tvec1<lowp_int>                 ivec1;
    00216 #endif//GLM_PRECISION
    00217
    00218         namespace precision
    00219         {
    00220                 typedef detail::tvec1<highp_int>                highp_ivec1;
    00221                 typedef detail::tvec1<mediump_int>              mediump_ivec1;
    00222                 typedef detail::tvec1<lowp_int>                 lowp_ivec1;
    00223         }
    00224         //namespace precision
    00225
    00227         // Unsigned integer definition
    00228
    00229 #ifndef GLM_PRECISION
    00230         typedef detail::tvec1<mediump_uint>             uvec1;
    00231 #elif(GLM_PRECISION & GLM_PRECISION_HIGHP_UINT)
    00232         typedef detail::tvec1<highp_uint>               uvec1;
    00233 #elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_UINT)
    00234         typedef detail::tvec1<mediump_uint>             uvec1;
    00235 #elif(GLM_PRECISION & GLM_PRECISION_LOWP_UINT)
    00236         typedef detail::tvec1<lowp_uint>                uvec1;
    00237 #endif//GLM_PRECISION
    00238
    00239         namespace precision
    00240         {
    00241                 typedef detail::tvec1<highp_uint>               highp_uvec1;
    00242                 typedef detail::tvec1<mediump_uint>             mediump_uvec1;
    00243                 typedef detail::tvec1<lowp_uint>                lowp_uvec1;
    00244         }
    00245         //namespace precision
    00246
    00247         }//namespace vector
    00248         }//namespace type
    00249         }//namespace core
    00250 }//namespace glm
    00251
    00252 #include "type_vec1.inl"
    00253
    00254 #endif//glm_core_type_gentype1