globjects  2.0.0.630135941c42
Strict OpenGL objects wrapper.
Loading...
Searching...
No Matches
AbstractUniform.h
Go to the documentation of this file.
1
2#pragma once
3
4
5#include <string>
6#include <set>
7#include <vector>
8#include <array>
9#include <unordered_map>
10
11#include <glm/fwd.hpp>
12
13#include <globjects/globjects_api.h>
14
16
17#ifdef GLOBJECTS_USE_EIGEN
18#include <Eigen/Dense>
19#include <Eigen/StdVector>
20#endif
21
22namespace globjects
23{
24
25
26class TextureHandle;
27class Program;
28template<typename T> class Uniform;
29enum class UniformType : unsigned char;
30
31
39class GLOBJECTS_API AbstractUniform
40{
41 friend class Program;
42
43
44public:
46 {
48 SeparateShaderObjectsARB
49 };
50
52
53#ifdef GLOBJECTS_USE_EIGEN
54 // Need to use Eigen aware vector
55 template <typename T>
56 using EigenStdVector = std::vector<T,Eigen::aligned_allocator<T> >;
57#endif
58
59
60public:
61 AbstractUniform(const Program * program, gl::GLint location, UniformType type);
62 AbstractUniform(const Program * program, const std::string & name, UniformType type);
64
65 const std::string & name() const;
66 gl::GLint location() const;
67
68 const LocationIdentity & identity() const;
69
70 UniformType type() const;
71
72
73protected:
77 void changed();
78
81 void update(bool invalidateLocation) const;
82
85 virtual void updateAt(gl::GLint location) const = 0;
86
87
88protected:
89 void setValue(gl::GLint location, const float & value) const;
90 void setValue(gl::GLint location, const int & value) const;
91 void setValue(gl::GLint location, const unsigned int & value) const;
92 void setValue(gl::GLint location, const bool & value) const;
93
94 void setValue(gl::GLint location, const std::vector<float> & value) const;
95 void setValue(gl::GLint location, const std::vector<int> & value) const;
96 void setValue(gl::GLint location, const std::vector<unsigned int> & value) const;
97 void setValue(gl::GLint location, const std::vector<bool> & value) const;
98
99 void setValue(gl::GLint location, const gl::GLuint64 & value) const;
100 void setValue(gl::GLint location, const TextureHandle & value) const;
101
102 void setValue(gl::GLint location, const std::vector<gl::GLuint64> & value) const;
103 void setValue(gl::GLint location, const std::vector<TextureHandle> & value) const;
104
105 template <typename T, std::size_t Count>
106 void setValue(gl::GLint location, const std::array<T, Count> & value) const;
107
108 // glm-specific setters
109 void setValue(gl::GLint location, const glm::vec2 & value) const;
110 void setValue(gl::GLint location, const glm::vec3 & value) const;
111 void setValue(gl::GLint location, const glm::vec4 & value) const;
112
113 void setValue(gl::GLint location, const glm::ivec2 & value) const;
114 void setValue(gl::GLint location, const glm::ivec3 & value) const;
115 void setValue(gl::GLint location, const glm::ivec4 & value) const;
116
117 void setValue(gl::GLint location, const glm::uvec2 & value) const;
118 void setValue(gl::GLint location, const glm::uvec3 & value) const;
119 void setValue(gl::GLint location, const glm::uvec4 & value) const;
120
121 void setValue(gl::GLint location, const glm::mat2 & value) const;
122 void setValue(gl::GLint location, const glm::mat3 & value) const;
123 void setValue(gl::GLint location, const glm::mat4 & value) const;
124
125 void setValue(gl::GLint location, const glm::mat2x3 & value) const;
126 void setValue(gl::GLint location, const glm::mat3x2 & value) const;
127 void setValue(gl::GLint location, const glm::mat2x4 & value) const;
128 void setValue(gl::GLint location, const glm::mat4x2 & value) const;
129 void setValue(gl::GLint location, const glm::mat3x4 & value) const;
130 void setValue(gl::GLint location, const glm::mat4x3 & value) const;
131
132 void setValue(gl::GLint location, const std::vector<glm::vec2> & value) const;
133 void setValue(gl::GLint location, const std::vector<glm::vec3> & value) const;
134 void setValue(gl::GLint location, const std::vector<glm::vec4> & value) const;
135
136 void setValue(gl::GLint location, const std::vector<glm::ivec2> & value) const;
137 void setValue(gl::GLint location, const std::vector<glm::ivec3> & value) const;
138 void setValue(gl::GLint location, const std::vector<glm::ivec4> & value) const;
139
140 void setValue(gl::GLint location, const std::vector<glm::uvec2> & value) const;
141 void setValue(gl::GLint location, const std::vector<glm::uvec3> & value) const;
142 void setValue(gl::GLint location, const std::vector<glm::uvec4> & value) const;
143
144 void setValue(gl::GLint location, const std::vector<glm::mat2> & value) const;
145 void setValue(gl::GLint location, const std::vector<glm::mat3> & value) const;
146 void setValue(gl::GLint location, const std::vector<glm::mat4> & value) const;
147
148 void setValue(gl::GLint location, const std::vector<glm::mat2x3> & value) const;
149 void setValue(gl::GLint location, const std::vector<glm::mat3x2> & value) const;
150 void setValue(gl::GLint location, const std::vector<glm::mat2x4> & value) const;
151 void setValue(gl::GLint location, const std::vector<glm::mat4x2> & value) const;
152 void setValue(gl::GLint location, const std::vector<glm::mat3x4> & value) const;
153 void setValue(gl::GLint location, const std::vector<glm::mat4x3> & value) const;
154
155 // Eigen-specific setters
156
157#ifdef GLOBJECTS_USE_EIGEN
158
159 void setValue(gl::GLint location, const Eigen::Vector2f & value) const;
160 void setValue(gl::GLint location, const Eigen::Vector3f & value) const;
161 void setValue(gl::GLint location, const Eigen::Vector4f & value) const;
162
163 void setValue(gl::GLint location, const Eigen::Vector2i &value) const;
164 void setValue(gl::GLint location, const Eigen::Vector3i & value) const;
165 void setValue(gl::GLint location, const Eigen::Vector4i & value) const;
166
168 void setValue(gl::GLint location, const Eigen::Matrix<unsigned int, 2, 1> &value) const;
169 void setValue(gl::GLint location, const Eigen::Matrix<unsigned int, 3, 1> &value) const;
170 void setValue(gl::GLint location, const Eigen::Matrix<unsigned int, 4, 1> &value) const;
171
172 void setValue(gl::GLint location, const Eigen::Matrix2f & value) const;
173 void setValue(gl::GLint location, const Eigen::Matrix3f & value) const;
174 void setValue(gl::GLint location, const Eigen::Matrix4f & value) const;
175
176 void setValue(gl::GLint location, const Eigen::Matrix<float, 2, 3> & value) const;
177 void setValue(gl::GLint location, const Eigen::Matrix<float, 3, 2> & value) const;
178 void setValue(gl::GLint location, const Eigen::Matrix<float, 2, 4> & value) const;
179 void setValue(gl::GLint location, const Eigen::Matrix<float, 4, 2> & value) const;
180 void setValue(gl::GLint location, const Eigen::Matrix<float, 3, 4> & value) const;
181 void setValue(gl::GLint location, const Eigen::Matrix<float, 4, 3> & value) const;
182
183 // Not implemented yet
184
185 /*
186 void setValue(gl::GLint location, const EigenStdVector<Eigen::Vector2f> & value) const;
187 void setValue(gl::GLint location, const EigenStdVector<Eigen::Vector3f> & value) const;
188 void setValue(gl::GLint location, const EigenStdVector<Eigen::Vector4f> & value) const;
189
190 void setValue(gl::GLint location, const EigenStdVector<Eigen::Vector2i> & value) const;
191 void setValue(gl::GLint location, const EigenStdVector<Eigen::Vector3i> & value) const;
192 void setValue(gl::GLint location, const EigenStdVector<Eigen::Vector4i> & value) const;
193
194 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<unsigned int, 2, 1>> & value) const;
195 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<unsigned int, 3, 1>> & value) const;
196 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<unsigned int, 4, 1>> & value) const;
197
198 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix2f> & value) const;
199 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix3f> & value) const;
200 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix4f> & value) const;
201
202 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<float, 2, 3>> & value) const;
203 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<float, 3, 2>> & value) const;
204 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<float, 2, 4>> & value) const;
205 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<float, 4, 2>> & value) const;
206 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<float, 3, 4>> & value) const;
207 void setValue(gl::GLint location, const EigenStdVector<Eigen::Matrix<float, 4, 3>> & value) const;
208 */
209
210#endif
211
212protected:
215 const UniformType m_type;
216 mutable gl::GLint m_location;
217};
218
219
220} // namespace globjects
221
222
223#include <globjects/AbstractUniform.inl>
Abstract base class for templated Uniforms.
Definition AbstractUniform.h:40
void setValue(gl::GLint location, const std::vector< glm::uvec4 > &value) const
void setValue(gl::GLint location, const glm::ivec2 &value) const
gl::GLint m_location
Definition AbstractUniform.h:216
void setValue(gl::GLint location, const bool &value) const
void setValue(gl::GLint location, const int &value) const
void setValue(gl::GLint location, const std::vector< glm::ivec4 > &value) const
gl::GLint location() const
void setValue(gl::GLint location, const glm::mat2 &value) const
void setValue(gl::GLint location, const std::vector< glm::mat2 > &value) const
void setValue(gl::GLint location, const TextureHandle &value) const
void setValue(gl::GLint location, const std::vector< glm::vec4 > &value) const
void setValue(gl::GLint location, const glm::uvec4 &value) const
void setValue(gl::GLint location, const glm::mat4x3 &value) const
void setValue(gl::GLint location, const std::vector< glm::mat3 > &value) const
void setValue(gl::GLint location, const glm::mat2x3 &value) const
void setValue(gl::GLint location, const std::vector< glm::mat3x4 > &value) const
void setValue(gl::GLint location, const glm::vec2 &value) const
BindlessImplementation
Definition AbstractUniform.h:46
@ Legacy
Definition AbstractUniform.h:47
const UniformType m_type
Definition AbstractUniform.h:215
void setValue(gl::GLint location, const std::vector< glm::ivec2 > &value) const
void setValue(gl::GLint location, const glm::ivec4 &value) const
void update(bool invalidateLocation) const
void setValue(gl::GLint location, const std::vector< glm::mat3x2 > &value) const
void setValue(gl::GLint location, const glm::uvec2 &value) const
void setValue(gl::GLint location, const glm::uvec3 &value) const
void setValue(gl::GLint location, const std::array< T, Count > &value) const
AbstractUniform(const Program *program, gl::GLint location, UniformType type)
void setValue(gl::GLint location, const float &value) const
void setValue(gl::GLint location, const glm::mat4x2 &value) const
void setValue(gl::GLint location, const unsigned int &value) const
void setValue(gl::GLint location, const glm::mat3 &value) const
void setValue(gl::GLint location, const std::vector< glm::mat2x3 > &value) const
void setValue(gl::GLint location, const glm::mat3x4 &value) const
virtual void updateAt(gl::GLint location) const =0
const std::string & name() const
void setValue(gl::GLint location, const std::vector< float > &value) const
LocationIdentity m_identity
Definition AbstractUniform.h:213
void setValue(gl::GLint location, const std::vector< glm::mat4x3 > &value) const
void setValue(gl::GLint location, const std::vector< TextureHandle > &value) const
void setValue(gl::GLint location, const gl::GLuint64 &value) const
void setValue(gl::GLint location, const std::vector< glm::uvec2 > &value) const
void setValue(gl::GLint location, const std::vector< glm::vec2 > &value) const
void setValue(gl::GLint location, const glm::ivec3 &value) const
void setValue(gl::GLint location, const std::vector< glm::uvec3 > &value) const
void setValue(gl::GLint location, const std::vector< glm::mat2x4 > &value) const
AbstractUniform(const Program *program, const std::string &name, UniformType type)
void setValue(gl::GLint location, const std::vector< glm::ivec3 > &value) const
void setValue(gl::GLint location, const std::vector< unsigned int > &value) const
UniformType type() const
static void hintBindlessImplementation(const BindlessImplementation impl)
void setValue(gl::GLint location, const glm::mat4 &value) const
void setValue(gl::GLint location, const glm::vec3 &value) const
void setValue(gl::GLint location, const glm::mat2x4 &value) const
void setValue(gl::GLint location, const glm::vec4 &value) const
void setValue(gl::GLint location, const std::vector< bool > &value) const
void setValue(gl::GLint location, const std::vector< gl::GLuint64 > &value) const
void setValue(gl::GLint location, const std::vector< glm::mat4x2 > &value) const
const LocationIdentity & identity() const
void setValue(gl::GLint location, const std::vector< glm::vec3 > &value) const
const Program * m_program
Definition AbstractUniform.h:214
void setValue(gl::GLint location, const std::vector< glm::mat4 > &value) const
void setValue(gl::GLint location, const std::vector< int > &value) const
void setValue(gl::GLint location, const glm::mat3x2 &value) const
Definition LocationIdentity.h:18
Wraps an OpenGL program.
Definition Program.h:82
Definition TextureHandle.h:21
Contains all the classes that wrap OpenGL functionality.