summaryrefslogtreecommitdiff
path: root/src/glm/core/type_vec1.hpp
blob: 3059196c0d6cf9369ee034b6340c92180ec4927f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-08-25
// Updated : 2010-02-04
// Licence : This source is under MIT License
// File    : glm/core/type_vec1.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef glm_core_type_gentype1
#define glm_core_type_gentype1

#include "type_vec.hpp"
#include "type_float.hpp"
#include "type_int.hpp"
#include "type_size.hpp"
#include "_swizzle.hpp"

namespace glm{
namespace detail
{
	template <typename T> struct tref1;
	template <typename T> struct tref2;
	template <typename T> struct tref3;
	template <typename T> struct tref4;
	template <typename T> struct tvec1;
	template <typename T> struct tvec2;
	template <typename T> struct tvec3;
	template <typename T> struct tvec4;

	template <typename T>
	struct tvec1
	{
		enum ctor{null};

		typedef T value_type;
		typedef std::size_t size_type;
		GLM_FUNC_DECL size_type length() const;
		static GLM_FUNC_DECL size_type value_size();

		typedef tvec1<T> type;
		typedef tvec1<bool> bool_type;

		//////////////////////////////////////
		// Data

#		if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
			value_type x;
#		else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
			union {value_type x, r, s;};
#		endif//GLM_COMPONENT

		//////////////////////////////////////
		// Accesses

		GLM_FUNC_DECL value_type & operator[](size_type i);
		GLM_FUNC_DECL value_type const & operator[](size_type i) const;

		//////////////////////////////////////
		// Implicit basic constructors

		GLM_FUNC_DECL tvec1();
		GLM_FUNC_DECL tvec1(tvec1<T> const & v);

		//////////////////////////////////////
		// Explicit basic constructors

		GLM_FUNC_DECL explicit tvec1(
			ctor);
		GLM_FUNC_DECL explicit tvec1(
			value_type const & s);

		//////////////////////////////////////
		// Swizzle constructors

		GLM_FUNC_DECL tvec1(tref1<T> const & r);

		//////////////////////////////////////
		// Convertion scalar constructors

		//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U> 
		GLM_FUNC_DECL explicit tvec1(U const & s);

		//////////////////////////////////////
		// Convertion vector constructors

		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U> 
		GLM_FUNC_DECL explicit tvec1(tvec2<U> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U> 
		GLM_FUNC_DECL explicit tvec1(tvec3<U> const & v);
		//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
		template <typename U> 
		GLM_FUNC_DECL explicit tvec1(tvec4<U> const & v);

		//////////////////////////////////////
		// Unary arithmetic operators

		GLM_FUNC_DECL tvec1<T> & operator= (tvec1<T> const & v);

		GLM_FUNC_DECL tvec1<T> & operator+=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator+=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator-=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator-=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator*=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator*=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator/=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator/=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator++();
		GLM_FUNC_DECL tvec1<T> & operator--();

		//////////////////////////////////////
		// Unary bit operators

		GLM_FUNC_DECL tvec1<T> & operator%=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator%=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator&=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator&=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator|=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator|=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator^=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator^=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator<<=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator<<=(tvec1<T> const & v);
		GLM_FUNC_DECL tvec1<T> & operator>>=(value_type const & s);
		GLM_FUNC_DECL tvec1<T> & operator>>=(tvec1<T> const & v);

		//////////////////////////////////////
		// Swizzle operators

		GLM_FUNC_DECL value_type swizzle(comp X) const;
		GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
		GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
		GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
		GLM_FUNC_DECL tref1<T> swizzle(comp X);
	};

	template <typename T>
	struct tref1
	{
		GLM_FUNC_DECL tref1(T & x);
		GLM_FUNC_DECL tref1(tref1<T> const & r);
		GLM_FUNC_DECL tref1(tvec1<T> const & v);

		GLM_FUNC_DECL tref1<T> & operator= (tref1<T> const & r);
		GLM_FUNC_DECL tref1<T> & operator= (tvec1<T> const & v);

		T& x;
	};

	GLM_DETAIL_IS_VECTOR(tvec1);

	typedef detail::tvec1<core::type::precision::highp_float>		highp_vec1_t;
	typedef detail::tvec1<core::type::precision::mediump_float>		mediump_vec1_t;
	typedef detail::tvec1<core::type::precision::lowp_float>		lowp_vec1_t;
	typedef detail::tvec1<core::type::precision::highp_int>			highp_ivec1_t;
	typedef detail::tvec1<core::type::precision::mediump_int>		mediump_ivec1_t;
	typedef detail::tvec1<core::type::precision::lowp_int>			lowp_ivec1_t;
	typedef detail::tvec1<core::type::precision::highp_uint>		highp_uvec1_t;
	typedef detail::tvec1<core::type::precision::mediump_uint>		mediump_uvec1_t;
	typedef detail::tvec1<core::type::precision::lowp_uint>			lowp_uvec1_t;

}//namespace detail
}//namespace glm

#ifndef GLM_EXTERNAL_TEMPLATE
#include "type_vec1.inl"
#endif//GLM_EXTERNAL_TEMPLATE

#endif//glm_core_type_gentype1