| 0.9.9 API documenation

- Main Page
- Modules
- Files

- File List

ext/vec1.hpp
Go to the documentation of this file.
1
13 #pragma once
14
15 #include "../fwd.hpp"
16 #include "../detail/type_vec.hpp"
17 #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
18 # if GLM_HAS_UNRESTRICTED_UNIONS
19 # include "../detail/_swizzle.hpp"
20 # else
21 # include "../detail/_swizzle_func.hpp"
22 # endif
23 #endif //GLM_SWIZZLE
24 #include <cstddef>
25
26 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
27 # pragma message("GLM: GLM_EXT_vec1 extension included")
28 #endif
29
30 namespace glm
31 {
34
35 template<typename T, qualifier Q>
36 struct vec<1, T, Q>
37 {
38 // -- Implementation detail --
39
40 typedef T value_type;
41 typedef vec type;
42 typedef vec<1, bool, Q> bool_type;
43
44 // -- Data --
45
46 # if GLM_HAS_ONLY_XYZW
47 T x;
48
49 # elif GLM_HAS_ALIGNED_TYPE
50 # if GLM_COMPILER & GLM_COMPILER_GCC
51 # pragma GCC diagnostic push
52 # pragma GCC diagnostic ignored "-Wpedantic"
53 # endif
54 # if GLM_COMPILER & GLM_COMPILER_CLANG
55 # pragma clang diagnostic push
56 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
57 # pragma clang diagnostic ignored "-Wnested-anon-types"
58 # endif
59
60 union
61 {
62 T x;
63 T r;
64 T s;
65 /*
66 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
67 _GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, x)
68 _GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, r)
69 _GLM_SWIZZLE1_2_MEMBERS(T, Q, tvec2, s)
70 _GLM_SWIZZLE1_3_MEMBERS(T, Q, tvec3, x)
71 _GLM_SWIZZLE1_3_MEMBERS(T, Q, tvec3, r)
72 _GLM_SWIZZLE1_3_MEMBERS(T, Q, tvec3, s)
73 _GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, x)
74 _GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, r)
75 _GLM_SWIZZLE1_4_MEMBERS(T, Q, tvec4, s)
76 # endif//GLM_SWIZZLE*/
77 };
78
79 # if GLM_COMPILER & GLM_COMPILER_CLANG
80 # pragma clang diagnostic pop
81 # endif
82 # if GLM_COMPILER & GLM_COMPILER_GCC
83 # pragma GCC diagnostic pop
84 # endif
85 # else
86 union {T x, r, s;};
87 /*
88 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
89 GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, P, tvec2, tvec2, tvec3, tvec4)
90 # endif//GLM_SWIZZLE*/
91 # endif
92
93 // -- Component accesses --
94
96 typedef length_t length_type;
97 GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 1;}
98
99 GLM_FUNC_DECL T & operator[](length_type i);
100 GLM_FUNC_DECL T const& operator[](length_type i) const;
101
102 // -- Implicit basic constructors --
103
104 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT_CTOR;
105 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec const& v) GLM_DEFAULT;
106 template<qualifier P>
107 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, T, P> const& v);
108
109 // -- Explicit basic constructors --
110
111 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit vec(T scalar);
112
113 // -- Conversion vector constructors --
114
116 template<typename U, qualifier P>
117 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<2, U, P> const& v);
119 template<typename U, qualifier P>
120 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<3, U, P> const& v);
122 template<typename U, qualifier P>
123 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<4, U, P> const& v);
124
126 template<typename U, qualifier P>
127 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<1, U, P> const& v);
128
129 // -- Swizzle constructors --
130 /*
131 # if(GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED))
132 template<int E0>
133 GLM_FUNC_DECL tvec(detail::_swizzle<1, T, Q, tvec1, E0, -1,-2,-3> const& that)
134 {
135 *this = that();
136 }
137 # endif//(GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED))
138 */
139 // -- Unary arithmetic operators --
140
141 GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec & operator=(vec const& v) GLM_DEFAULT;
142
143 template<typename U>
144 GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec & operator=(vec<1, U, Q> const& v);
145 template<typename U>
146 GLM_FUNC_DECL vec & operator+=(U scalar);
147 template<typename U>
148 GLM_FUNC_DECL vec & operator+=(vec<1, U, Q> const& v);
149 template<typename U>
150 GLM_FUNC_DECL vec & operator-=(U scalar);
151 template<typename U>
152 GLM_FUNC_DECL vec & operator-=(vec<1, U, Q> const& v);
153 template<typename U>
154 GLM_FUNC_DECL vec & operator*=(U scalar);
155 template<typename U>
156 GLM_FUNC_DECL vec & operator*=(vec<1, U, Q> const& v);
157 template<typename U>
158 GLM_FUNC_DECL vec & operator/=(U scalar);
159 template<typename U>
160 GLM_FUNC_DECL vec & operator/=(vec<1, U, Q> const& v);
161
162 // -- Increment and decrement operators --
163
164 GLM_FUNC_DECL vec & operator++();
165 GLM_FUNC_DECL vec & operator--();
166 GLM_FUNC_DECL vec operator++(int);
167 GLM_FUNC_DECL vec operator--(int);
168
169 // -- Unary bit operators --
170
171 template<typename U>
172 GLM_FUNC_DECL vec & operator%=(U scalar);
173 template<typename U>
174 GLM_FUNC_DECL vec & operator%=(vec<1, U, Q> const& v);
175 template<typename U>
176 GLM_FUNC_DECL vec & operator&=(U scalar);
177 template<typename U>
178 GLM_FUNC_DECL vec & operator&=(vec<1, U, Q> const& v);
179 template<typename U>
180 GLM_FUNC_DECL vec & operator|=(U scalar);
181 template<typename U>
182 GLM_FUNC_DECL vec & operator|=(vec<1, U, Q> const& v);
183 template<typename U>
184 GLM_FUNC_DECL vec & operator^=(U scalar);
185 template<typename U>
186 GLM_FUNC_DECL vec & operator^=(vec<1, U, Q> const& v);
187 template<typename U>
188 GLM_FUNC_DECL vec & operator<<=(U scalar);
189 template<typename U>
190 GLM_FUNC_DECL vec & operator<<=(vec<1, U, Q> const& v);
191 template<typename U>
192 GLM_FUNC_DECL vec & operator>>=(U scalar);
193 template<typename U>
194 GLM_FUNC_DECL vec & operator>>=(vec<1, U, Q> const& v);
195 };
196
197 // -- Unary operators --
198
199 template<typename T, qualifier Q>
200 GLM_FUNC_DECL vec<1, T, Q> operator+(vec<1, T, Q> const& v);
201
202 template<typename T, qualifier Q>
203 GLM_FUNC_DECL vec<1, T, Q> operator-(vec<1, T, Q> const& v);
204
205 // -- Binary operators --
206
207 template<typename T, qualifier Q>
208 GLM_FUNC_DECL vec<1, T, Q> operator+(vec<1, T, Q> const& v, T scalar);
209
210 template<typename T, qualifier Q>
211 GLM_FUNC_DECL vec<1, T, Q> operator+(T scalar, vec<1, T, Q> const& v);
212
213 template<typename T, qualifier Q>
214 GLM_FUNC_DECL vec<1, T, Q> operator+(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
215
216 template<typename T, qualifier Q>
217 GLM_FUNC_DECL vec<1, T, Q> operator-(vec<1, T, Q> const& v, T scalar);
218
219 template<typename T, qualifier Q>
220 GLM_FUNC_DECL vec<1, T, Q> operator-(T scalar, vec<1, T, Q> const& v);
221
222 template<typename T, qualifier Q>
223 GLM_FUNC_DECL vec<1, T, Q> operator-(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
224
225 template<typename T, qualifier Q>
226 GLM_FUNC_DECL vec<1, T, Q> operator*(vec<1, T, Q> const& v, T scalar);
227
228 template<typename T, qualifier Q>
229 GLM_FUNC_DECL vec<1, T, Q> operator*(T scalar, vec<1, T, Q> const& v);
230
231 template<typename T, qualifier Q>
232 GLM_FUNC_DECL vec<1, T, Q> operator*(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
233
234 template<typename T, qualifier Q>
235 GLM_FUNC_DECL vec<1, T, Q> operator/(vec<1, T, Q> const& v, T scalar);
236
237 template<typename T, qualifier Q>
238 GLM_FUNC_DECL vec<1, T, Q> operator/(T scalar, vec<1, T, Q> const& v);
239
240 template<typename T, qualifier Q>
241 GLM_FUNC_DECL vec<1, T, Q> operator/(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
242
243 template<typename T, qualifier Q>
244 GLM_FUNC_DECL vec<1, T, Q> operator%(vec<1, T, Q> const& v, T scalar);
245
246 template<typename T, qualifier Q>
247 GLM_FUNC_DECL vec<1, T, Q> operator%(T scalar, vec<1, T, Q> const& v);
248
249 template<typename T, qualifier Q>
250 GLM_FUNC_DECL vec<1, T, Q> operator%(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
251
252 template<typename T, qualifier Q>
253 GLM_FUNC_DECL vec<1, T, Q> operator&(vec<1, T, Q> const& v, T scalar);
254
255 template<typename T, qualifier Q>
256 GLM_FUNC_DECL vec<1, T, Q> operator&(T scalar, vec<1, T, Q> const& v);
257
258 template<typename T, qualifier Q>
259 GLM_FUNC_DECL vec<1, T, Q> operator&(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
260
261 template<typename T, qualifier Q>
262 GLM_FUNC_DECL vec<1, T, Q> operator|(vec<1, T, Q> const& v, T scalar);
263
264 template<typename T, qualifier Q>
265 GLM_FUNC_DECL vec<1, T, Q> operator|(T scalar, vec<1, T, Q> const& v);
266
267 template<typename T, qualifier Q>
268 GLM_FUNC_DECL vec<1, T, Q> operator|(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
269
270 template<typename T, qualifier Q>
271 GLM_FUNC_DECL vec<1, T, Q> operator^(vec<1, T, Q> const& v, T scalar);
272
273 template<typename T, qualifier Q>
274 GLM_FUNC_DECL vec<1, T, Q> operator^(T scalar, vec<1, T, Q> const& v);
275
276 template<typename T, qualifier Q>
277 GLM_FUNC_DECL vec<1, T, Q> operator^(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
278
279 template<typename T, qualifier Q>
280 GLM_FUNC_DECL vec<1, T, Q> operator<<(vec<1, T, Q> const& v, T scalar);
281
282 template<typename T, qualifier Q>
283 GLM_FUNC_DECL vec<1, T, Q> operator<<(T scalar, vec<1, T, Q> const& v);
284
285 template<typename T, qualifier Q>
286 GLM_FUNC_DECL vec<1, T, Q> operator<<(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
287
288 template<typename T, qualifier Q>
289 GLM_FUNC_DECL vec<1, T, Q> operator>>(vec<1, T, Q> const& v, T scalar);
290
291 template<typename T, qualifier Q>
292 GLM_FUNC_DECL vec<1, T, Q> operator>>(T scalar, vec<1, T, Q> const& v);
293
294 template<typename T, qualifier Q>
295 GLM_FUNC_DECL vec<1, T, Q> operator>>(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
296
297 template<typename T, qualifier Q>
298 GLM_FUNC_DECL vec<1, T, Q> operator~(vec<1, T, Q> const& v);
299
300 // -- Boolean operators --
301
302 template<typename T, qualifier Q>
303 GLM_FUNC_DECL bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
304
305 template<typename T, qualifier Q>
306 GLM_FUNC_DECL bool operator!=(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2);
307
308 template<qualifier Q>
309 GLM_FUNC_DECL vec<1, bool, Q> operator&&(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2);
310
311 template<qualifier Q>
312 GLM_FUNC_DECL vec<1, bool, Q> operator||(vec<1, bool, Q> const& v1, vec<1, bool, Q> const& v2);
313
317 typedef vec<1, float, highp> highp_vec1;
318
322 typedef vec<1, float, mediump> mediump_vec1;
323
327 typedef vec<1, float, lowp> lowp_vec1;
328
332 typedef vec<1, double, highp> highp_dvec1;
333
337 typedef vec<1, double, mediump> mediump_dvec1;
338
342 typedef vec<1, double, lowp> lowp_dvec1;
343
347 typedef vec<1, int, highp> highp_ivec1;
348
352 typedef vec<1, int, mediump> mediump_ivec1;
353
357 typedef vec<1, int, lowp> lowp_ivec1;
358
362 typedef vec<1, uint, highp> highp_uvec1;
363
367 typedef vec<1, uint, mediump> mediump_uvec1;
368
372 typedef vec<1, uint, lowp> lowp_uvec1;
373
377 typedef vec<1, bool, highp> highp_bvec1;
378
382 typedef vec<1, bool, mediump> mediump_bvec1;
383
387 typedef vec<1, bool, lowp> lowp_bvec1;
388
389 #if GLM_HAS_TEMPLATE_ALIASES
390 template <typename T, qualifier Q = defaultp> using tvec1 = vec<1, T, Q>;
391 #endif//GLM_HAS_TEMPLATE_ALIASES
392
394 // vec1 definition
395
396 #if(defined(GLM_PRECISION_HIGHP_BOOL))
397 typedef highp_bvec1 bvec1;
398 #elif(defined(GLM_PRECISION_MEDIUMP_BOOL))
399 typedef mediump_bvec1 bvec1;
400 #elif(defined(GLM_PRECISION_LOWP_BOOL))
401 typedef lowp_bvec1 bvec1;
402 #else
403 typedef highp_bvec1 bvec1;
406 #endif//GLM_PRECISION
407
408 #if(defined(GLM_PRECISION_HIGHP_FLOAT))
409 typedef highp_vec1 vec1;
410 #elif(defined(GLM_PRECISION_MEDIUMP_FLOAT))
411 typedef mediump_vec1 vec1;
412 #elif(defined(GLM_PRECISION_LOWP_FLOAT))
413 typedef lowp_vec1 vec1;
414 #else
415 typedef highp_vec1 vec1;
418 #endif//GLM_PRECISION
419
420 #if(defined(GLM_PRECISION_HIGHP_DOUBLE))
421 typedef highp_dvec1 dvec1;
422 #elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE))
423 typedef mediump_dvec1 dvec1;
424 #elif(defined(GLM_PRECISION_LOWP_DOUBLE))
425 typedef lowp_dvec1 dvec1;
426 #else
427 typedef highp_dvec1 dvec1;
430 #endif//GLM_PRECISION
431
432 #if(defined(GLM_PRECISION_HIGHP_INT))
433 typedef highp_ivec1 ivec1;
434 #elif(defined(GLM_PRECISION_MEDIUMP_INT))
435 typedef mediump_ivec1 ivec1;
436 #elif(defined(GLM_PRECISION_LOWP_INT))
437 typedef lowp_ivec1 ivec1;
438 #else
439 typedef highp_ivec1 ivec1;
442 #endif//GLM_PRECISION
443
444 #if(defined(GLM_PRECISION_HIGHP_UINT))
445 typedef highp_uvec1 uvec1;
446 #elif(defined(GLM_PRECISION_MEDIUMP_UINT))
447 typedef mediump_uvec1 uvec1;
448 #elif(defined(GLM_PRECISION_LOWP_UINT))
449 typedef lowp_uvec1 uvec1;
450 #else
451 typedef highp_uvec1 uvec1;
454 #endif//GLM_PRECISION
455
457 }//namespace glm
458
459 #ifndef GLM_EXTERNAL_TEMPLATE
460 #include "../detail/type_vec1.inl"
461 #endif//GLM_EXTERNAL_TEMPLATE
glm::mediump_dvec1
vec< 1, double, mediump > mediump_dvec1
1 component vector of double-precision floating-point numbers using medium precision arithmetic in te...
Definition: ext/vec1.hpp:337
glm::lowp_uvec1
vec< 1, uint, lowp > lowp_uvec1
1 component vector of unsigned integer numbers.
Definition: ext/vec1.hpp:372
glm::highp_ivec1
vec< 1, int, highp > highp_ivec1
1 component vector of signed integer numbers.
Definition: ext/vec1.hpp:347
glm::mediump_ivec1
vec< 1, int, mediump > mediump_ivec1
1 component vector of signed integer numbers.
Definition: ext/vec1.hpp:352
glm::lowp_bvec1
vec< 1, bool, lowp > lowp_bvec1
1 component vector of bool values.
Definition: ext/vec1.hpp:387
glm::uvec1
highp_uvec1 uvec1
1 component vector of unsigned integer numbers.
Definition: ext/vec1.hpp:453
glm::lowp_ivec1
vec< 1, int, lowp > lowp_ivec1
1 component vector of signed integer numbers.
Definition: ext/vec1.hpp:357
glm::mediump_bvec1
vec< 1, bool, mediump > mediump_bvec1
1 component vector of bool values.
Definition: ext/vec1.hpp:382
glm::highp_uvec1
vec< 1, uint, highp > highp_uvec1
1 component vector of unsigned integer numbers.
Definition: ext/vec1.hpp:362
glm
Definition: common.hpp:20
glm::dvec1
highp_dvec1 dvec1
1 component vector of floating-point numbers.
Definition: ext/vec1.hpp:429
glm::lowp_dvec1
vec< 1, double, lowp > lowp_dvec1
1 component vector of double-precision floating-point numbers using low precision arithmetic in term ...
Definition: ext/vec1.hpp:342
glm::highp_dvec1
vec< 1, double, highp > highp_dvec1
1 component vector of double-precision floating-point numbers using high precision arithmetic in term...
Definition: ext/vec1.hpp:332
glm::mediump_vec1
vec< 1, float, mediump > mediump_vec1
1 component vector of single-precision floating-point numbers using medium precision arithmetic in te...
Definition: ext/vec1.hpp:322
glm::ivec1
highp_ivec1 ivec1
1 component vector of signed integer numbers.
Definition: ext/vec1.hpp:441
glm::bvec1
highp_bvec1 bvec1
1 component vector of boolean.
Definition: ext/vec1.hpp:405
glm::highp_bvec1
vec< 1, bool, highp > highp_bvec1
1 component vector of bool values.
Definition: ext/vec1.hpp:377
glm::length
GLM_FUNC_DECL T length(vec< L, T, Q > const &x)
Returns the length of x, i.e., sqrt(x * x).
glm::uint
unsigned int uint
Unsigned integer type.
Definition: type_int.hpp:288
glm::vec1
highp_vec1 vec1
1 component vector of floating-point numbers.
Definition: ext/vec1.hpp:417
glm::mediump_uvec1
vec< 1, uint, mediump > mediump_uvec1
1 component vector of unsigned integer numbers.
Definition: ext/vec1.hpp:367
glm::lowp_vec1
vec< 1, float, lowp > lowp_vec1
1 component vector of single-precision floating-point numbers using low precision arithmetic in term ...
Definition: ext/vec1.hpp:327
glm::highp_vec1
vec< 1, float, highp > highp_vec1
1 component vector of single-precision floating-point numbers using high precision arithmetic in term...
Definition: ext/vec1.hpp:317