Home | History | Annotate | Download | only in detail
      1 ///////////////////////////////////////////////////////////////////////////////////
      2 /// OpenGL Mathematics (glm.g-truc.net)
      3 ///
      4 /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
      5 /// Permission is hereby granted, free of charge, to any person obtaining a copy
      6 /// of this software and associated documentation files (the "Software"), to deal
      7 /// in the Software without restriction, including without limitation the rights
      8 /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9 /// copies of the Software, and to permit persons to whom the Software is
     10 /// furnished to do so, subject to the following conditions:
     11 ///
     12 /// The above copyright notice and this permission notice shall be included in
     13 /// all copies or substantial portions of the Software.
     14 ///
     15 /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16 /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17 /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18 /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19 /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     21 /// THE SOFTWARE.
     22 ///
     23 /// @ref core
     24 /// @file glm/core/type_vec1.hpp
     25 /// @date 2008-08-25 / 2011-06-15
     26 /// @author Christophe Riccio
     27 ///////////////////////////////////////////////////////////////////////////////////
     28 
     29 #ifndef glm_core_type_gentype1
     30 #define glm_core_type_gentype1
     31 
     32 #include "../fwd.hpp"
     33 #include "type_vec.hpp"
     34 #ifdef GLM_SWIZZLE
     35 #	if GLM_HAS_ANONYMOUS_UNION
     36 #		include "_swizzle.hpp"
     37 #	else
     38 #		include "_swizzle_func.hpp"
     39 #	endif
     40 #endif //GLM_SWIZZLE
     41 #include <cstddef>
     42 
     43 namespace glm{
     44 namespace detail
     45 {
     46 	template <typename T, precision P>
     47 	struct tvec1
     48 	{
     49 		//////////////////////////////////////
     50 		// Implementation detail
     51 
     52 		enum ctor{_null};
     53 
     54 		typedef tvec1<T, P> type;
     55 		typedef tvec1<bool, P> bool_type;
     56 		typedef T value_type;
     57 
     58 		//////////////////////////////////////
     59 		// Helper
     60 
     61 		GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
     62 
     63 		//////////////////////////////////////
     64 		// Data
     65 
     66 		union {T x, r, s;};
     67 
     68 		//////////////////////////////////////
     69 		// Accesses
     70 
     71 		GLM_FUNC_DECL T & operator[](length_t i);
     72 		GLM_FUNC_DECL T const & operator[](length_t i) const;
     73 
     74 		//////////////////////////////////////
     75 		// Implicit basic constructors
     76 
     77 		GLM_FUNC_DECL tvec1();
     78 		GLM_FUNC_DECL tvec1(tvec1<T, P> const & v);
     79 		template <precision Q>
     80 		GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
     81 
     82 		//////////////////////////////////////
     83 		// Explicit basic constructors
     84 
     85 		GLM_FUNC_DECL explicit tvec1(
     86 			ctor);
     87 		GLM_FUNC_DECL tvec1(
     88 			T const & s);
     89 
     90 		//////////////////////////////////////
     91 		// Conversion vector constructors
     92 
     93 		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
     94 		template <typename U, precision Q>
     95 		GLM_FUNC_DECL explicit tvec1(tvec1<U, Q> const & v);
     96 		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
     97 		template <typename U, precision Q>
     98 		GLM_FUNC_DECL explicit tvec1(tvec2<U, Q> const & v);
     99 		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
    100 		template <typename U, precision Q>
    101 		GLM_FUNC_DECL explicit tvec1(tvec3<U, Q> const & v);
    102 		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
    103 		template <typename U, precision Q>
    104 		GLM_FUNC_DECL explicit tvec1(tvec4<U, Q> const & v);
    105 
    106 		//////////////////////////////////////
    107 		// Unary arithmetic operators
    108 
    109 		GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<T, P> const & v);
    110 		template <typename U>
    111 		GLM_FUNC_DECL tvec1<T, P> & operator= (tvec1<U, P> const & v);
    112 
    113 		template <typename U>
    114 		GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & s);
    115 		template <typename U>
    116 		GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
    117 		template <typename U>
    118 		GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
    119 		template <typename U>
    120 		GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
    121 		template <typename U>
    122 		GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
    123 		template <typename U>
    124 		GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
    125 		template <typename U>
    126 		GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
    127 		template <typename U>
    128 		GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
    129 
    130 		//////////////////////////////////////
    131 		// Increment and decrement operators
    132 
    133 		GLM_FUNC_DECL tvec1<T, P> & operator++();
    134 		GLM_FUNC_DECL tvec1<T, P> & operator--();
    135 		GLM_FUNC_DECL tvec1<T, P> operator++(int);
    136 		GLM_FUNC_DECL tvec1<T, P> operator--(int);
    137 
    138 		//////////////////////////////////////
    139 		// Unary bit operators
    140 
    141 		template <typename U>
    142 		GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & s);
    143 		template <typename U>
    144 		GLM_FUNC_DECL tvec1<T, P> & operator%=(tvec1<U, P> const & v);
    145 		template <typename U>
    146 		GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & s);
    147 		template <typename U>
    148 		GLM_FUNC_DECL tvec1<T, P> & operator&=(tvec1<U, P> const & v);
    149 		template <typename U>
    150 		GLM_FUNC_DECL tvec1<T, P> & operator|=(U const & s);
    151 		template <typename U>
    152 		GLM_FUNC_DECL tvec1<T, P> & operator|=(tvec1<U, P> const & v);
    153 		template <typename U>
    154 		GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & s);
    155 		template <typename U>
    156 		GLM_FUNC_DECL tvec1<T, P> & operator^=(tvec1<U, P> const & v);
    157 		template <typename U>
    158 		GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & s);
    159 		template <typename U>
    160 		GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
    161 		template <typename U>
    162 		GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & s);
    163 		template <typename U>
    164 		GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);
    165 	};
    166 
    167 
    168 	template <typename T, precision P>
    169 	GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T const & s);
    170 
    171 	template <typename T, precision P>
    172 	GLM_FUNC_DECL tvec1<T, P> operator+(T const & s, tvec1<T, P> const & v);
    173 
    174 	template <typename T, precision P>
    175 	GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    176 
    177 	template <typename T, precision P>
    178 	GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T const & s);
    179 
    180 	template <typename T, precision P>
    181 	GLM_FUNC_DECL tvec1<T, P> operator-(T const & s, tvec1<T, P> const & v);
    182 
    183 	template <typename T, precision P>
    184 	GLM_FUNC_DECL tvec1<T, P> operator-	(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    185 
    186 	template <typename T, precision P>
    187 	GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T const & s);
    188 
    189 	template <typename T, precision P>
    190 	GLM_FUNC_DECL tvec1<T, P> operator*(T const & s, tvec1<T, P> const & v);
    191 
    192 	template <typename T, precision P>
    193 	GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    194 
    195 	template <typename T, precision P>
    196 	GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T const & s);
    197 
    198 	template <typename T, precision P>
    199 	GLM_FUNC_DECL tvec1<T, P> operator/(T const & s, tvec1<T, P> const & v);
    200 
    201 	template <typename T, precision P>
    202 	GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    203 
    204 	template <typename T, precision P>
    205 	GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
    206 
    207 	template <typename T, precision P>
    208 	GLM_FUNC_DECL bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    209 
    210 	template <typename T, precision P>
    211 	GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    212 
    213 	template <typename T, precision P>
    214 	GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T const & s);
    215 
    216 	template <typename T, precision P>
    217 	GLM_FUNC_DECL tvec1<T, P> operator%(T const & s, tvec1<T, P> const & v);
    218 
    219 	template <typename T, precision P>
    220 	GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    221 
    222 	template <typename T, precision P>
    223 	GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T const & s);
    224 
    225 	template <typename T, precision P>
    226 	GLM_FUNC_DECL tvec1<T, P> operator&(T const & s, tvec1<T, P> const & v);
    227 
    228 	template <typename T, precision P>
    229 	GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    230 
    231 	template <typename T, precision P>
    232 	GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T const & s);
    233 
    234 	template <typename T, precision P>
    235 	GLM_FUNC_DECL tvec1<T, P> operator|(T const & s, tvec1<T, P> const & v);
    236 
    237 	template <typename T, precision P>
    238 	GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    239 
    240 	template <typename T, precision P>
    241 	GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T const & s);
    242 
    243 	template <typename T, precision P>
    244 	GLM_FUNC_DECL tvec1<T, P> operator^(T const & s, tvec1<T, P> const & v);
    245 
    246 	template <typename T, precision P>
    247 	GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    248 
    249 	template <typename T, precision P>
    250 	GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & s);
    251 
    252 	template <typename T, precision P>
    253 	GLM_FUNC_DECL tvec1<T, P> operator<<(T const & s, tvec1<T, P> const & v);
    254 
    255 	template <typename T, precision P>
    256 	GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    257 
    258 	template <typename T, precision P>
    259 	GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & s);
    260 
    261 	template <typename T, precision P>
    262 	GLM_FUNC_DECL tvec1<T, P> operator>>(T const & s, tvec1<T, P> const & v);
    263 
    264 	template <typename T, precision P>
    265 	GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
    266 
    267 	template <typename T, precision P>
    268 	GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
    269 
    270 }//namespace detail
    271 }//namespace glm
    272 
    273 #ifndef GLM_EXTERNAL_TEMPLATE
    274 #include "type_vec1.inl"
    275 #endif//GLM_EXTERNAL_TEMPLATE
    276 
    277 #endif//glm_core_type_gentype1
    278