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 =========================================================================*/
27 #ifndef vtkUniformVariables_h
28 #define vtkUniformVariables_h
29 
30 #include "vtkRenderingOpenGLModule.h" // For export macro
31 #include "vtkObject.h"
32 
33 class vtkUniformVariablesMap; // internal
34 
35 class VTKRENDERINGOPENGL_EXPORT vtkUniformVariables : public vtkObject
36 {
37 public:
38  static vtkUniformVariables *New();
40  void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE;
41 
48  void SetUniformi(const char *name,
49  int numberOfComponents,
50  int *value);
51 
52  template<typename T>
53  void SetUniformit(const char *name,
54  int numberOfComponents,
55  T *value);
56 
57  template<typename T>
58  void SetUniformit(const char *name, T value)
59  { this->SetUniformit(name, 1, &value); }
60 
67  void SetUniformf(const char *name,
68  int numberOfComponents,
69  float *value);
70 
71  template<typename T>
72  void SetUniformft(const char *name,
73  int numberOfComponents,
74  T *value);
75 
76  template<typename T>
77  void SetUniformft(const char *name, T value)
78  { this->SetUniformft(name, 1, &value); }
79 
88  void SetUniformiv(const char *name,
89  int numberOfComponents,
90  int numberOfElements,
91  int *value);
92 
101  void SetUniformfv(const char *name,
102  int numberOfComponents,
103  int numberOfElements,
104  float *value);
105 
113  void SetUniformMatrix(const char *name,
114  int rows,
115  int columns,
116  float *value);
117 
121  void RemoveUniform(const char *name);
122 
126  void RemoveAllUniforms();
127 
131  void Send(const char *name,
132  int uniformIndex);
133 
137  void Start();
138 
142  bool IsAtEnd();
143 
148  const char *GetCurrentName();
149 
154  void SendCurrentUniform(int uniformIndex);
155 
160  void Next();
161 
168  void DeepCopy(vtkUniformVariables *other);
169 
176  void Merge(vtkUniformVariables *other);
177 
178 protected:
180  ~vtkUniformVariables() VTK_OVERRIDE;
181 
182 private:
183  vtkUniformVariables(const vtkUniformVariables&) VTK_DELETE_FUNCTION;
184  void operator=(const vtkUniformVariables&) VTK_DELETE_FUNCTION;
185 
186  vtkUniformVariablesMap *Map;
187 };
188 
189 // ----------------------------------------------------------------------------
190 template<typename T>
191 void vtkUniformVariables::SetUniformit(const char *name,
192  int numberOfComponents,
193  T *value)
194 {
195  int ivalues[4];
196  for (int i=0; i<numberOfComponents; ++i)
197  {
198  ivalues[i] = static_cast<int>(value[i]);
199  }
200  this->SetUniformi(name, numberOfComponents, ivalues);
201 }
202 
203 // ----------------------------------------------------------------------------
204 template<typename T>
206  int numberOfComponents,
207  T *value)
208 {
209  float fvalues[4];
210  for (int i=0; i<numberOfComponents; ++i)
211  {
212  fvalues[i] = static_cast<float>(value[i]);
213  }
214  this->SetUniformf(name, numberOfComponents, fvalues);
215 }
216 
217 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
GLSL uniform variables.
void SetUniformft(const char *name, int numberOfComponents, T *value)
void SetUniformft(const char *name, T value)
void SetUniformit(const char *name, T value)
a simple class to control print indentation
Definition: vtkIndent.h:33
static const unsigned int numberOfElements
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...