VTK
vtkUniformVariables.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkUniformVariables.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
30#ifndef vtkUniformVariables_h
31#define vtkUniformVariables_h
32
33#include "vtkRenderingOpenGLModule.h" // For export macro
34#include "vtkObject.h"
35
36class vtkUniformVariablesMap; // internal
37
38class VTKRENDERINGOPENGL_EXPORT vtkUniformVariables : public vtkObject
39{
40public:
43 void PrintSelf(ostream &os, vtkIndent indent);
44
51 void SetUniformi(const char *name,
52 int numberOfComponents,
53 int *value);
54
55 template<typename T>
56 void SetUniformit(const char *name,
57 int numberOfComponents,
58 T *value);
59
60 template<typename T>
61 void SetUniformit(const char *name, T value)
62 { this->SetUniformit(name, 1, &value); }
63
70 void SetUniformf(const char *name,
71 int numberOfComponents,
72 float *value);
73
74 template<typename T>
75 void SetUniformft(const char *name,
76 int numberOfComponents,
77 T *value);
78
79 template<typename T>
80 void SetUniformft(const char *name, T value)
81 { this->SetUniformft(name, 1, &value); }
82
91 void SetUniformiv(const char *name,
92 int numberOfComponents,
94 int *value);
95
104 void SetUniformfv(const char *name,
105 int numberOfComponents,
107 float *value);
108
116 void SetUniformMatrix(const char *name,
117 int rows,
118 int columns,
119 float *value);
120
124 void RemoveUniform(const char *name);
125
130
134 void Send(const char *name,
135 int uniformIndex);
136
140 void Start();
141
145 bool IsAtEnd();
146
151 const char *GetCurrentName();
152
157 void SendCurrentUniform(int uniformIndex);
158
163 void Next();
164
172
180
181protected:
184
185private:
186 vtkUniformVariables(const vtkUniformVariables&) VTK_DELETE_FUNCTION;
187 void operator=(const vtkUniformVariables&) VTK_DELETE_FUNCTION;
188
189 vtkUniformVariablesMap *Map;
190};
191
192// ----------------------------------------------------------------------------
193template<typename T>
195 int numberOfComponents,
196 T *value)
197{
198 int ivalues[4];
199 for (int i=0; i<numberOfComponents; ++i)
200 {
201 ivalues[i] = static_cast<int>(value[i]);
202 }
203 this->SetUniformi(name, numberOfComponents, ivalues);
204}
205
206// ----------------------------------------------------------------------------
207template<typename T>
209 int numberOfComponents,
210 T *value)
211{
212 float fvalues[4];
213 for (int i=0; i<numberOfComponents; ++i)
214 {
215 fvalues[i] = static_cast<float>(value[i]);
216 }
217 this->SetUniformf(name, numberOfComponents, fvalues);
218}
219
220#endif
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
GLSL uniform variables.
void Merge(vtkUniformVariables *other)
Copy all the variables from ‘other’.
const char * GetCurrentName()
Name of the uniform at the current cursor position.
void Send(const char *name, int uniformIndex)
void SetUniformf(const char *name, int numberOfComponents, float *value)
Set an float uniform variable.
void SetUniformit(const char *name, int numberOfComponents, T *value)
void SetUniformit(const char *name, T value)
void SetUniformiv(const char *name, int numberOfComponents, int numberOfElements, int *value)
Set an array of integer uniform variables.
void DeepCopy(vtkUniformVariables *other)
Copy all the variables from ‘other’.
void SetUniformi(const char *name, int numberOfComponents, int *value)
Set an integer uniform variable.
void RemoveAllUniforms()
Remove all uniforms from the list.
void Start()
Place the internal cursor on the first uniform.
void SetUniformft(const char *name, int numberOfComponents, T *value)
void SetUniformft(const char *name, T value)
virtual ~vtkUniformVariables()
bool IsAtEnd()
Is the iteration done?
void SendCurrentUniform(int uniformIndex)
static vtkUniformVariables * New()
void Next()
Move the cursor to the next uniform.
void RemoveUniform(const char *name)
Remove uniform ‘name’ from the list.
void SetUniformfv(const char *name, int numberOfComponents, int numberOfElements, float *value)
Set an array of float uniform variables.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void SetUniformMatrix(const char *name, int rows, int columns, float *value)
Set a matrix uniform variable.
static const unsigned int numberOfElements
@ value
Definition: vtkX3D.h:220
@ name
Definition: vtkX3D.h:219