Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Uniform.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Uniform_INCLUDE_ONCE
33 #define Uniform_INCLUDE_ONCE
34 
35 #include <vlCore/vlnamespace.hpp>
36 #include <vlCore/Object.hpp>
37 #include <vlCore/Vector4.hpp>
38 #include <vlCore/Matrix4.hpp>
39 #include <vlGraphics/OpenGL.hpp>
40 #include <cstring>
41 #include <map>
42 #include <vector>
43 #include <algorithm>
44 
45 namespace vl
46 {
47  //------------------------------------------------------------------------------
48  // Uniform
49  //------------------------------------------------------------------------------
59  class Uniform: public Object
60  {
62 
63  friend class GLSLProgram;
64 
65  public:
66 
68  {
69  VL_DEBUG_SET_OBJECT_NAME()
70  }
71 
72  Uniform(const char* name): mType(UT_NONE)
73  {
74  VL_DEBUG_SET_OBJECT_NAME()
75  mName = name;
76  }
77 
79  {
80  ref<Uniform> uniform = new Uniform;
81  *uniform = *this;
82  return uniform;
83  }
84 
86  const std::string& name() const { return mName; }
87 
89  std::string& name() { return mName; }
90 
92  void setName(const char* name) { mName = name; }
93 
95  void setName(const std::string& name) { mName = name; }
96 
97  // generic array setters
98 
99  void setUniform1i(int count, const int* value) { initData(count*1); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_INT; }
100  void setUniform2i(int count, const int* value) { initData(count*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_INT_VEC2; }
101  void setUniform3i(int count, const int* value) { initData(count*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_INT_VEC3; }
102  void setUniform4i(int count, const int* value) { initData(count*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_INT_VEC4; }
103 
104  void setUniform1ui(int count, const unsigned int* value) { initData(count*1); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_UNSIGNED_INT; }
105  void setUniform2ui(int count, const unsigned int* value) { initData(count*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_UNSIGNED_INT_VEC2; }
106  void setUniform3ui(int count, const unsigned int* value) { initData(count*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_UNSIGNED_INT_VEC3; }
107  void setUniform4ui(int count, const unsigned int* value) { initData(count*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_UNSIGNED_INT_VEC4; }
108 
109  void setUniform1f(int count, const float* value) { initData(count*1); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT; }
110  void setUniform2f(int count, const float* value) { initData(count*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_VEC2; }
111  void setUniform3f(int count, const float* value) { initData(count*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_VEC3; }
112  void setUniform4f(int count, const float* value) { initData(count*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_VEC4; }
113 
114  void setUniform1d(int count, const double* value) { initDouble(count*1); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE; }
115  void setUniform2d(int count, const double* value) { initDouble(count*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_VEC2; }
116  void setUniform3d(int count, const double* value) { initDouble(count*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_VEC3; }
117  void setUniform4d(int count, const double* value) { initDouble(count*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_VEC4; }
118 
119  // generic matrix array setters
120 
121  void setUniformMatrix2f(int count, const float* value) { initData(count*2*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT2; }
122  void setUniformMatrix3f(int count, const float* value) { initData(count*3*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT3; }
123  void setUniformMatrix4f(int count, const float* value) { initData(count*4*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT4; }
124 
125  void setUniformMatrix2x3f(int count, const float* value) { initData(count*2*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT2x3; }
126  void setUniformMatrix3x2f(int count, const float* value) { initData(count*3*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT3x2; }
127  void setUniformMatrix2x4f(int count, const float* value) { initData(count*2*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT2x4; }
128  void setUniformMatrix4x2f(int count, const float* value) { initData(count*4*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT4x2; }
129  void setUniformMatrix3x4f(int count, const float* value) { initData(count*3*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT3x4; }
130  void setUniformMatrix4x3f(int count, const float* value) { initData(count*4*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_FLOAT_MAT4x3; }
131 
132  void setUniformMatrix2d(int count, const double* value) { initDouble(count*2*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT2; }
133  void setUniformMatrix3d(int count, const double* value) { initDouble(count*3*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT3; }
134  void setUniformMatrix4d(int count, const double* value) { initDouble(count*4*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT4; }
135 
136  void setUniformMatrix2x3d(int count, const double* value) { initDouble(count*2*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT2x3; }
137  void setUniformMatrix3x2d(int count, const double* value) { initDouble(count*3*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT3x2; }
138  void setUniformMatrix2x4d(int count, const double* value) { initDouble(count*2*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT2x4; }
139  void setUniformMatrix4x2d(int count, const double* value) { initDouble(count*4*2); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT4x2; }
140  void setUniformMatrix3x4d(int count, const double* value) { initDouble(count*3*4); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT3x4; }
141  void setUniformMatrix4x3d(int count, const double* value) { initDouble(count*4*3); memcpy(&mData[0], value, sizeof(mData[0]) * mData.size()); mType = UT_DOUBLE_MAT4x3; }
142 
143  // vector/matrix array setters
144 
145  void setUniform(int count, const int* value) { setUniform1i(count, value); }
146  void setUniform(int count, const ivec2* value) { setUniform2i(count, value->ptr()); }
147  void setUniform(int count, const ivec3* value) { setUniform3i(count, value->ptr()); }
148  void setUniform(int count, const ivec4* value) { setUniform4i(count, value->ptr()); }
149 
150  void setUniform(int count, const unsigned int* value) { setUniform1ui(count, value); }
151  void setUniform(int count, const uvec2* value) { setUniform2ui(count, value->ptr()); }
152  void setUniform(int count, const uvec3* value) { setUniform3ui(count, value->ptr()); }
153  void setUniform(int count, const uvec4* value) { setUniform4ui(count, value->ptr()); }
154 
155  void setUniform(int count, const float* value) { setUniform1f(count, value); }
156  void setUniform(int count, const fvec2* value) { setUniform2f(count, value->ptr()); }
157  void setUniform(int count, const fvec3* value) { setUniform3f(count, value->ptr()); }
158  void setUniform(int count, const fvec4* value) { setUniform4f(count, value->ptr()); }
159 
160  void setUniform(int count, const fmat2* value) { setUniformMatrix2f(count, value->ptr()); }
161  void setUniform(int count, const fmat3* value) { setUniformMatrix3f(count, value->ptr()); }
162  void setUniform(int count, const fmat4* value) { setUniformMatrix4f(count, value->ptr()); }
163 
164  void setUniform(int count, const double* value) { setUniform1d(count, value); }
165  void setUniform(int count, const dvec2* value) { setUniform2d(count, value->ptr()); }
166  void setUniform(int count, const dvec3* value) { setUniform3d(count, value->ptr()); }
167  void setUniform(int count, const dvec4* value) { setUniform4d(count, value->ptr()); }
168 
169  void setUniform(int count, const dmat2* value) { setUniformMatrix2d(count, value->ptr()); }
170  void setUniform(int count, const dmat3* value) { setUniformMatrix3d(count, value->ptr()); }
171  void setUniform(int count, const dmat4* value) { setUniformMatrix4d(count, value->ptr()); }
172 
173  // single value setters
174 
175  void setUniform(int value) { setUniform1i(1, &value); }
176  void setUniformI(const int& value) { setUniform1i(1, &value); }
177  void setUniform(const ivec2& value) { setUniform2i(1, value.ptr()); }
178  void setUniform(const ivec3& value) { setUniform3i(1, value.ptr()); }
179  void setUniform(const ivec4& value) { setUniform4i(1, value.ptr()); }
180 
181  void setUniform(unsigned int value) { setUniform1ui(1, &value); }
182  void setUniformU(const unsigned int& value) { setUniform1ui(1, &value); }
183  void setUniform(const uvec2& value) { setUniform2ui(1, value.ptr()); }
184  void setUniform(const uvec3& value) { setUniform3ui(1, value.ptr()); }
185  void setUniform(const uvec4& value) { setUniform4ui(1, value.ptr()); }
186 
187  void setUniform(float value) { setUniform1f(1, &value); }
188  void setUniformF(const float& value) { setUniform1f(1, &value); }
189  void setUniform(const fvec2& value) { setUniform2f(1, value.ptr()); }
190  void setUniform(const fvec3& value) { setUniform3f(1, value.ptr()); }
191  void setUniform(const fvec4& value) { setUniform4f(1, value.ptr()); }
192 
193  void setUniform(const fmat2& value) { setUniformMatrix2f(1, value.ptr()); }
194  void setUniform(const fmat3& value) { setUniformMatrix3f(1, value.ptr()); }
195  void setUniform(const fmat4& value) { setUniformMatrix4f(1, value.ptr()); }
196 
197  void setUniform(double value) { setUniform1d(1, &value); }
198  void setUniformD(const double& value) { setUniform1d(1, &value); }
199  void setUniform(const dvec2& value) { setUniform2d(1, value.ptr()); }
200  void setUniform(const dvec3& value) { setUniform3d(1, value.ptr()); }
201  void setUniform(const dvec4& value) { setUniform4d(1, value.ptr()); }
202 
203  void setUniform(const dmat2& value) { setUniformMatrix2d(1, value.ptr()); }
204  void setUniform(const dmat3& value) { setUniformMatrix3d(1, value.ptr()); }
205  void setUniform(const dmat4& value) { setUniformMatrix4d(1, value.ptr()); }
206 
207  // getters
208 
209  float getUniformF() const { VL_CHECK( type() != UT_NONE ); VL_CHECK( mData.size() == 1 ); float val; getUniform(&val); return val; }
210  double getUniformD() const { VL_CHECK( type() != UT_NONE ); VL_CHECK( mData.size() == 1 ); double val; getUniform(&val); return val; }
211  int getUniformI() const { VL_CHECK( type() != UT_NONE ); VL_CHECK( mData.size() == 1 ); int val; getUniform(&val); return val; }
212  unsigned int getUniformU() const { VL_CHECK( type() != UT_NONE ); VL_CHECK( mData.size() == 1 ); unsigned int val; getUniform(&val); return val; }
213 
214  ivec2 getUniform2I() const { ivec2 v; getUniform( v.ptr() ); return v; }
215  ivec3 getUniform3I() const { ivec3 v; getUniform( v.ptr() ); return v; }
216  ivec4 getUniform4I() const { ivec4 v; getUniform( v.ptr() ); return v; }
217 
218  uvec2 getUniform2U() const { uvec2 v; getUniform( v.ptr() ); return v; }
219  uvec3 getUniform3U() const { uvec3 v; getUniform( v.ptr() ); return v; }
220  uvec4 getUniform4U() const { uvec4 v; getUniform( v.ptr() ); return v; }
221 
222  fvec2 getUniform2F() const { fvec2 v; getUniform( v.ptr() ); return v; }
223  fvec3 getUniform3F() const { fvec3 v; getUniform( v.ptr() ); return v; }
224  fvec4 getUniform4F() const { fvec4 v; getUniform( v.ptr() ); return v; }
225 
226  dvec2 getUniform2D() const { dvec2 v; getUniform( v.ptr() ); return v; }
227  dvec3 getUniform3D() const { dvec3 v; getUniform( v.ptr() ); return v; }
228  dvec4 getUniform4D() const { dvec4 v; getUniform( v.ptr() ); return v; }
229 
230  void getUniform(double* value) const { VL_CHECK(type() != UT_NONE); VL_CHECK(mData.size()); memcpy( value, &mData[0], sizeof(mData[0]) * mData.size()); }
231  void getUniform(float* value) const { VL_CHECK(type() != UT_NONE); VL_CHECK(mData.size()); memcpy( value, &mData[0], sizeof(mData[0]) * mData.size()); }
232  void getUniform(int* value) const { VL_CHECK(type() != UT_NONE); VL_CHECK(mData.size()); memcpy( value, &mData[0], sizeof(mData[0]) * mData.size()); }
233  void getUniform(unsigned int* value) const { VL_CHECK(type() != UT_NONE); VL_CHECK(mData.size()); memcpy( value, &mData[0], sizeof(mData[0]) * mData.size()); }
234 
235  void getUniform(ivec2* value) const { getUniform(value->ptr()); }
236  void getUniform(ivec3* value) const { getUniform(value->ptr()); }
237  void getUniform(ivec4* value) const { getUniform(value->ptr()); }
238 
239  void getUniform(uvec2* value) const { getUniform(value->ptr()); }
240  void getUniform(uvec3* value) const { getUniform(value->ptr()); }
241  void getUniform(uvec4* value) const { getUniform(value->ptr()); }
242 
243  void getUniform(fvec2* value) const { getUniform(value->ptr()); }
244  void getUniform(fvec3* value) const { getUniform(value->ptr()); }
245  void getUniform(fvec4* value) const { getUniform(value->ptr()); }
246 
247  void getUniform(fmat2* value) const { getUniform(value->ptr()); }
248  void getUniform(fmat3* value) const { getUniform(value->ptr()); }
249  void getUniform(fmat4* value) const { getUniform(value->ptr()); }
250 
251  void getUniform(dvec2* value) const { getUniform(value->ptr()); }
252  void getUniform(dvec3* value) const { getUniform(value->ptr()); }
253  void getUniform(dvec4* value) const { getUniform(value->ptr()); }
254 
255  void getUniform(dmat2* value) const { getUniform(value->ptr()); }
256  void getUniform(dmat3* value) const { getUniform(value->ptr()); }
257  void getUniform(dmat4* value) const { getUniform(value->ptr()); }
258 
259  EUniformType type() const { return mType; }
260 
261  int count() const
262  {
263  if (mData.empty())
264  return 0;
265 
266  switch(mType)
267  {
268  case UT_INT: return singleCount();
269  case UT_INT_VEC2: return singleCount() / 2;
270  case UT_INT_VEC3: return singleCount() / 3;
271  case UT_INT_VEC4: return singleCount() / 4;
272 
273  case UT_UNSIGNED_INT: return singleCount();
274  case UT_UNSIGNED_INT_VEC2: return singleCount() / 2;
275  case UT_UNSIGNED_INT_VEC3: return singleCount() / 3;
276  case UT_UNSIGNED_INT_VEC4: return singleCount() / 4;
277 
278  case UT_FLOAT: return singleCount();
279  case UT_FLOAT_VEC2: return singleCount() / 2;
280  case UT_FLOAT_VEC3: return singleCount() / 3;
281  case UT_FLOAT_VEC4: return singleCount() / 4;
282 
283  case UT_FLOAT_MAT2: return singleCount() / (2*2);
284  case UT_FLOAT_MAT3: return singleCount() / (3*3);
285  case UT_FLOAT_MAT4: return singleCount() / (4*4);
286 
287  case UT_FLOAT_MAT2x3: return singleCount() / (2*3);
288  case UT_FLOAT_MAT3x2: return singleCount() / (3*2);
289  case UT_FLOAT_MAT2x4: return singleCount() / (2*4);
290  case UT_FLOAT_MAT4x2: return singleCount() / (4*2);
291  case UT_FLOAT_MAT3x4: return singleCount() / (3*4);
292  case UT_FLOAT_MAT4x3: return singleCount() / (4*3);
293 
294  case UT_DOUBLE: return doubleCount();
295  case UT_DOUBLE_VEC2: return doubleCount() / 2;
296  case UT_DOUBLE_VEC3: return doubleCount() / 3;
297  case UT_DOUBLE_VEC4: return doubleCount() / 4;
298 
299  case UT_DOUBLE_MAT2: return doubleCount() / (2*2);
300  case UT_DOUBLE_MAT3: return doubleCount() / (3*3);
301  case UT_DOUBLE_MAT4: return doubleCount() / (4*4);
302 
303  case UT_DOUBLE_MAT2x3: return doubleCount() / (2*3);
304  case UT_DOUBLE_MAT3x2: return doubleCount() / (3*2);
305  case UT_DOUBLE_MAT2x4: return doubleCount() / (2*4);
306  case UT_DOUBLE_MAT4x2: return doubleCount() / (4*2);
307  case UT_DOUBLE_MAT3x4: return doubleCount() / (3*4);
308  case UT_DOUBLE_MAT4x3: return doubleCount() / (4*3);
309 
310  default:
311  VL_TRAP()
312  return -1;
313  }
314  }
315 
316  void* rawData() { if (mData.empty()) return NULL; else return &mData[0]; }
317 
318  const void* rawData() const { if (mData.empty()) return NULL; else return &mData[0]; }
319 
320  protected:
321  VL_COMPILE_TIME_CHECK( sizeof(int) == sizeof(float) )
322  void initData(int count) { mData.resize(count); }
323  void initDouble(int count) { mData.resize(count*2); }
324  int singleCount() const { return (int)mData.size(); }
325  int doubleCount() const { VL_CHECK((mData.size() & 0x1) == 0 ); return (int)(mData.size() >> 1); }
326  const double* doubleData() const { VL_CHECK(!mData.empty()); VL_CHECK((mData.size() & 0x1) == 0 ); return (double*)&mData[0]; }
327  const float* floatData() const { VL_CHECK(!mData.empty()); return (float*)&mData[0]; }
328  const int* intData() const { VL_CHECK(!mData.empty()); return (int*)&mData[0]; }
329  const unsigned int* uintData() const { VL_CHECK(!mData.empty()); return (unsigned int*)&mData[0]; }
330 
332  std::vector<int> mData;
333  std::string mName;
334  };
335 }
336 
337 #endif
void setUniformMatrix3d(int count, const double *value)
Definition: Uniform.hpp:133
void setUniformMatrix4x2d(int count, const double *value)
Definition: Uniform.hpp:139
const float * floatData() const
Definition: Uniform.hpp:327
void getUniform(fmat2 *value) const
Definition: Uniform.hpp:247
Wraps an OpenGL Shading Language uniform to be associated to a GLSLProgram (see vl::GLSLProgram docum...
Definition: Uniform.hpp:59
void setUniform(int count, const fmat2 *value)
Definition: Uniform.hpp:160
void setUniform1i(int count, const int *value)
Definition: Uniform.hpp:99
void setUniform(const uvec2 &value)
Definition: Uniform.hpp:183
void getUniform(uvec2 *value) const
Definition: Uniform.hpp:239
void setUniform(int count, const uvec3 *value)
Definition: Uniform.hpp:152
void getUniform(dmat3 *value) const
Definition: Uniform.hpp:256
void setUniform3f(int count, const float *value)
Definition: Uniform.hpp:111
void setUniformMatrix2f(int count, const float *value)
Definition: Uniform.hpp:121
void setUniform(int count, const fvec2 *value)
Definition: Uniform.hpp:156
std::vector< int > mData
Definition: Uniform.hpp:332
void setUniform(int count, const fvec4 *value)
Definition: Uniform.hpp:158
void getUniform(fvec3 *value) const
Definition: Uniform.hpp:244
void setUniform(int count, const dmat3 *value)
Definition: Uniform.hpp:170
void setUniformMatrix3x4d(int count, const double *value)
Definition: Uniform.hpp:140
void setUniform(const dmat4 &value)
Definition: Uniform.hpp:205
std::string mName
Definition: Uniform.hpp:333
void setUniform(const fmat3 &value)
Definition: Uniform.hpp:194
void setUniform(int count, const unsigned int *value)
Definition: Uniform.hpp:150
void getUniform(uvec3 *value) const
Definition: Uniform.hpp:240
T_Scalar * ptr()
Definition: Matrix2.hpp:238
void getUniform(unsigned int *value) const
Definition: Uniform.hpp:233
void getUniform(fmat3 *value) const
Definition: Uniform.hpp:248
fvec4 getUniform4F() const
Definition: Uniform.hpp:224
void setUniform(const dvec3 &value)
Definition: Uniform.hpp:200
uvec2 getUniform2U() const
Definition: Uniform.hpp:218
std::string & name()
Returns the name of the uniform variable.
Definition: Uniform.hpp:89
void setUniform(int count, const fmat3 *value)
Definition: Uniform.hpp:161
fvec3 getUniform3F() const
Definition: Uniform.hpp:223
void getUniform(uvec4 *value) const
Definition: Uniform.hpp:241
void getUniform(fvec4 *value) const
Definition: Uniform.hpp:245
The Matrix2 class is a template class that implements a generic 2x2 matrix, see also vl::dmat2...
Definition: Matrix2.hpp:49
void setUniform(const uvec4 &value)
Definition: Uniform.hpp:185
void setUniform(int count, const uvec4 *value)
Definition: Uniform.hpp:153
void initDouble(int count)
Definition: Uniform.hpp:323
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. ...
Definition: GLSL.hpp:233
void setUniform(const dvec4 &value)
Definition: Uniform.hpp:201
const void * rawData() const
Definition: Uniform.hpp:318
void getUniform(ivec3 *value) const
Definition: Uniform.hpp:236
void setUniform(const dmat3 &value)
Definition: Uniform.hpp:204
void setUniformMatrix3f(int count, const float *value)
Definition: Uniform.hpp:122
EUniformType type() const
Definition: Uniform.hpp:259
fvec2 getUniform2F() const
Definition: Uniform.hpp:222
void setUniform(int count, const float *value)
Definition: Uniform.hpp:155
void setUniform(const fvec2 &value)
Definition: Uniform.hpp:189
void setUniformU(const unsigned int &value)
Definition: Uniform.hpp:182
const double * doubleData() const
Definition: Uniform.hpp:326
void getUniform(dvec3 *value) const
Definition: Uniform.hpp:252
void setUniform(int count, const dvec3 *value)
Definition: Uniform.hpp:166
void setUniform(int count, const ivec3 *value)
Definition: Uniform.hpp:147
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
VL_COMPILE_TIME_CHECK(sizeof(int)==sizeof(float)) void initData(int count)
Definition: Uniform.hpp:321
uvec4 getUniform4U() const
Definition: Uniform.hpp:220
dvec3 getUniform3D() const
Definition: Uniform.hpp:227
void setUniform(const uvec3 &value)
Definition: Uniform.hpp:184
void getUniform(double *value) const
Definition: Uniform.hpp:230
void getUniform(int *value) const
Definition: Uniform.hpp:232
void setUniform(const dvec2 &value)
Definition: Uniform.hpp:199
EUniformType
Uniform types, see also vl::UniformInfo, vl::GLSLProgram, vl::Uniform, http://www.opengl.org/sdk/docs/man4/xhtml/glGetActiveUniform.xml.
void setUniform(int count, const dvec4 *value)
Definition: Uniform.hpp:167
Visualization Library main namespace.
void setUniformD(const double &value)
Definition: Uniform.hpp:198
void setUniform4i(int count, const int *value)
Definition: Uniform.hpp:102
void setUniformMatrix2x4f(int count, const float *value)
Definition: Uniform.hpp:127
const unsigned int * uintData() const
Definition: Uniform.hpp:329
EUniformType mType
Definition: Uniform.hpp:331
int count() const
Definition: Uniform.hpp:261
T_Scalar * ptr()
Definition: Vector2.hpp:129
void * rawData()
Definition: Uniform.hpp:316
Uniform(const char *name)
Definition: Uniform.hpp:72
The Matrix3 class is a template class that implements a generic 3x3 matrix, see also vl::dmat3...
Definition: Matrix3.hpp:48
void setUniform(const dmat2 &value)
Definition: Uniform.hpp:203
void setUniformMatrix4x3d(int count, const double *value)
Definition: Uniform.hpp:141
void setUniform(int count, const uvec2 *value)
Definition: Uniform.hpp:151
dvec4 getUniform4D() const
Definition: Uniform.hpp:228
void getUniform(fmat4 *value) const
Definition: Uniform.hpp:249
void setUniform(int count, const dmat4 *value)
Definition: Uniform.hpp:171
#define VL_TRAP()
Definition: checks.hpp:70
void setUniform(unsigned int value)
Definition: Uniform.hpp:181
T_Scalar * ptr()
Definition: Matrix3.hpp:301
const std::string & name() const
Returns the name of the uniform variable.
Definition: Uniform.hpp:86
void setUniformF(const float &value)
Definition: Uniform.hpp:188
The base class for all the reference counted objects.
Definition: Object.hpp:158
unsigned int getUniformU() const
Definition: Uniform.hpp:212
void setUniform(int count, const dvec2 *value)
Definition: Uniform.hpp:165
void getUniform(fvec2 *value) const
Definition: Uniform.hpp:243
void getUniform(dmat2 *value) const
Definition: Uniform.hpp:255
const int * intData() const
Definition: Uniform.hpp:328
void setUniform(int count, const double *value)
Definition: Uniform.hpp:164
int getUniformI() const
Definition: Uniform.hpp:211
void setUniformMatrix2d(int count, const double *value)
Definition: Uniform.hpp:132
void setUniform3ui(int count, const unsigned int *value)
Definition: Uniform.hpp:106
void setUniform(const fmat2 &value)
Definition: Uniform.hpp:193
void setUniformMatrix4x3f(int count, const float *value)
Definition: Uniform.hpp:130
void setUniformMatrix3x2f(int count, const float *value)
Definition: Uniform.hpp:126
int doubleCount() const
Definition: Uniform.hpp:325
void setUniform2ui(int count, const unsigned int *value)
Definition: Uniform.hpp:105
void setUniformMatrix4f(int count, const float *value)
Definition: Uniform.hpp:123
void setUniform(int count, const ivec2 *value)
Definition: Uniform.hpp:146
void setUniform(int count, const dmat2 *value)
Definition: Uniform.hpp:169
#define NULL
Definition: OpenGLDefs.hpp:81
ref< Uniform > clone() const
Definition: Uniform.hpp:78
void setUniformI(const int &value)
Definition: Uniform.hpp:176
T_Scalar * ptr()
Definition: Vector3.hpp:86
void setUniform(const fvec3 &value)
Definition: Uniform.hpp:190
void getUniform(ivec2 *value) const
Definition: Uniform.hpp:235
void setUniform(const fvec4 &value)
Definition: Uniform.hpp:191
void setUniform(int value)
Definition: Uniform.hpp:175
void setUniformMatrix2x3f(int count, const float *value)
Definition: Uniform.hpp:125
ivec4 getUniform4I() const
Definition: Uniform.hpp:216
void setUniform4ui(int count, const unsigned int *value)
Definition: Uniform.hpp:107
double getUniformD() const
Definition: Uniform.hpp:210
void setUniform2f(int count, const float *value)
Definition: Uniform.hpp:110
void setUniform(int count, const fvec3 *value)
Definition: Uniform.hpp:157
T_Scalar * ptr()
Definition: Vector4.hpp:98
int singleCount() const
Definition: Uniform.hpp:324
void setName(const std::string &name)
Sets the name of the uniform variable.
Definition: Uniform.hpp:95
dvec2 getUniform2D() const
Definition: Uniform.hpp:226
void setName(const char *name)
Sets the name of the uniform variable.
Definition: Uniform.hpp:92
void setUniformMatrix2x4d(int count, const double *value)
Definition: Uniform.hpp:138
T_Scalar * ptr()
Definition: Matrix4.hpp:340
void setUniform(float value)
Definition: Uniform.hpp:187
void setUniform(const ivec3 &value)
Definition: Uniform.hpp:178
void setUniform(const ivec4 &value)
Definition: Uniform.hpp:179
void getUniform(dvec4 *value) const
Definition: Uniform.hpp:253
void setUniform(int count, const int *value)
Definition: Uniform.hpp:145
void setUniform(const ivec2 &value)
Definition: Uniform.hpp:177
void setUniform1f(int count, const float *value)
Definition: Uniform.hpp:109
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
ivec3 getUniform3I() const
Definition: Uniform.hpp:215
void setUniform(int count, const ivec4 *value)
Definition: Uniform.hpp:148
void setUniform(const fmat4 &value)
Definition: Uniform.hpp:195
void getUniform(ivec4 *value) const
Definition: Uniform.hpp:237
void setUniform3d(int count, const double *value)
Definition: Uniform.hpp:116
uvec3 getUniform3U() const
Definition: Uniform.hpp:219
void setUniform2i(int count, const int *value)
Definition: Uniform.hpp:100
void getUniform(dmat4 *value) const
Definition: Uniform.hpp:257
void setUniformMatrix4x2f(int count, const float *value)
Definition: Uniform.hpp:128
void setUniform(double value)
Definition: Uniform.hpp:197
void setUniform(int count, const fmat4 *value)
Definition: Uniform.hpp:162
void setUniform1ui(int count, const unsigned int *value)
Definition: Uniform.hpp:104
void setUniformMatrix3x4f(int count, const float *value)
Definition: Uniform.hpp:129
void setUniform4f(int count, const float *value)
Definition: Uniform.hpp:112
void setUniform4d(int count, const double *value)
Definition: Uniform.hpp:117
#define VL_CHECK(expr)
Definition: checks.hpp:73
Visualization Library&#39;s enums in the &#39;vl&#39; namespace.
void setUniformMatrix3x2d(int count, const double *value)
Definition: Uniform.hpp:137
void setUniform1d(int count, const double *value)
Definition: Uniform.hpp:114
float getUniformF() const
Definition: Uniform.hpp:209
void getUniform(dvec2 *value) const
Definition: Uniform.hpp:251
void getUniform(float *value) const
Definition: Uniform.hpp:231
ivec2 getUniform2I() const
Definition: Uniform.hpp:214
void setUniform2d(int count, const double *value)
Definition: Uniform.hpp:115
void setUniformMatrix2x3d(int count, const double *value)
Definition: Uniform.hpp:136
void setUniform3i(int count, const int *value)
Definition: Uniform.hpp:101
void setUniformMatrix4d(int count, const double *value)
Definition: Uniform.hpp:134