type_vec1.hpp

00001 
00002 // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
00004 // Created : 2008-08-25
00005 // Updated : 2010-02-04
00006 // Licence : This source is under MIT License
00007 // File    : glm/core/type_vec1.hpp
00009 
00010 #ifndef glm_core_type_gentype1
00011 #define glm_core_type_gentype1
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 {
00021         namespace test
00022         {
00023                 void main_vec1();
00024         }//namespace test
00025 
00026         namespace detail
00027         {
00028                 template <typename T> struct tref1;
00029                 template <typename T> struct tref2;
00030                 template <typename T> struct tref3;
00031                 template <typename T> struct tref4;
00032                 template <typename T> struct tvec1;
00033                 template <typename T> struct tvec2;
00034                 template <typename T> struct tvec3;
00035                 template <typename T> struct tvec4;
00036 
00037                 template <typename T>
00038                 struct tvec1
00039                 {
00040                         enum ctor{null};
00041 
00042                         typedef T value_type;
00043                         typedef std::size_t size_type;
00044                         static size_type value_size();
00045 
00046                         typedef tvec1<T> type;
00047                         typedef tvec1<bool> bool_type;
00048 
00050                         // Data
00051 
00052 #               if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
00053                         value_type x;
00054 #               else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
00055                         union {value_type x, r, s;};
00056 #               endif//GLM_COMPONENT
00057 
00059                         // Accesses
00060 
00061                         value_type & operator[](size_type i);
00062                         value_type const & operator[](size_type i) const;
00063 
00065                         // Implicit basic constructors
00066 
00067                         tvec1();
00068                         tvec1(tvec1<T> const & v);
00069 
00071                         // Explicit basic constructors
00072 
00073                         explicit tvec1(
00074                                 ctor);
00075                         explicit tvec1(
00076                                 value_type const & s);
00077 
00079                         // Swizzle constructors
00080 
00081                         tvec1(tref1<T> const & r);
00082 
00084                         // Convertion scalar constructors
00085 
00087                         template <typename U> 
00088                         explicit tvec1(U const & s);
00089 
00091                         // Convertion vector constructors
00092 
00094                         template <typename U> 
00095                         explicit tvec1(tvec2<U> const & v);
00097                         template <typename U> 
00098                         explicit tvec1(tvec3<U> const & v);
00100                         template <typename U> 
00101                         explicit tvec1(tvec4<U> const & v);
00102 
00104                         // Unary arithmetic operators
00105 
00106                         tvec1<T> & operator= (tvec1<T> const & v);
00107 
00108                         tvec1<T> & operator+=(value_type const & s);
00109                         tvec1<T> & operator+=(tvec1<T> const & v);
00110                         tvec1<T> & operator-=(value_type const & s);
00111                         tvec1<T> & operator-=(tvec1<T> const & v);
00112                         tvec1<T> & operator*=(value_type const & s);
00113                         tvec1<T> & operator*=(tvec1<T> const & v);
00114                         tvec1<T> & operator/=(value_type const & s);
00115                         tvec1<T> & operator/=(tvec1<T> const & v);
00116                         tvec1<T> & operator++();
00117                         tvec1<T> & operator--();
00118 
00120                         // Unary bit operators
00121 
00122                         tvec1<T> & operator%=(value_type const & s);
00123                         tvec1<T> & operator%=(tvec1<T> const & v);
00124                         tvec1<T> & operator&=(value_type const & s);
00125                         tvec1<T> & operator&=(tvec1<T> const & v);
00126                         tvec1<T> & operator|=(value_type const & s);
00127                         tvec1<T> & operator|=(tvec1<T> const & v);
00128                         tvec1<T> & operator^=(value_type const & s);
00129                         tvec1<T> & operator^=(tvec1<T> const & v);
00130                         tvec1<T> & operator<<=(value_type const & s);
00131                         tvec1<T> & operator<<=(tvec1<T> const & v);
00132                         tvec1<T> & operator>>=(value_type const & s);
00133                         tvec1<T> & operator>>=(tvec1<T> const & v);
00134 
00136                         // Swizzle operators
00137 
00138                         value_type swizzle(comp X) const;
00139                         tvec2<T> swizzle(comp X, comp Y) const;
00140                         tvec3<T> swizzle(comp X, comp Y, comp Z) const;
00141                         tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
00142                         tref1<T> swizzle(comp X);
00143                 };
00144 
00145                 template <typename T>
00146                 struct tref1
00147                 {
00148                         tref1(T & x);
00149                         tref1(tref1<T> const & r);
00150                         tref1(tvec1<T> const & v);
00151 
00152                         tref1<T> & operator= (tref1<T> const & r);
00153                         tref1<T> & operator= (tvec1<T> const & v);
00154 
00155                         T& x;
00156                 };
00157 
00158                 GLM_DETAIL_IS_VECTOR(tvec1);
00159 
00160                 typedef detail::tvec1<core::type::precision::highp_float>               highp_vec1_t;
00161                 typedef detail::tvec1<core::type::precision::mediump_float>             mediump_vec1_t;
00162                 typedef detail::tvec1<core::type::precision::lowp_float>                lowp_vec1_t;
00163                 typedef detail::tvec1<core::type::precision::highp_int>                 highp_ivec1_t;
00164                 typedef detail::tvec1<core::type::precision::mediump_int>               mediump_ivec1_t;
00165                 typedef detail::tvec1<core::type::precision::lowp_int>                  lowp_ivec1_t;
00166                 typedef detail::tvec1<core::type::precision::highp_uint>                highp_uvec1_t;
00167                 typedef detail::tvec1<core::type::precision::mediump_uint>              mediump_uvec1_t;
00168                 typedef detail::tvec1<core::type::precision::lowp_uint>                 lowp_uvec1_t;
00169 
00170         } //namespace detail
00171 }//namespace glm
00172 
00173 #ifndef GLM_EXTERNAL_TEMPLATE
00174 #include "type_vec1.inl"
00175 #endif
00176 
00177 #endif//glm_core_type_gentype1