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 
36 class vtkUniformVariablesMap; // internal
37 
38 class VTKRENDERINGOPENGL_EXPORT vtkUniformVariables : public vtkObject
39 {
40 public:
41  static vtkUniformVariables *New();
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,
93  int numberOfElements,
94  int *value);
95 
104  void SetUniformfv(const char *name,
105  int numberOfComponents,
106  int numberOfElements,
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 
129  void RemoveAllUniforms();
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 
171  void DeepCopy(vtkUniformVariables *other);
172 
179  void Merge(vtkUniformVariables *other);
180 
181 protected:
183  virtual ~vtkUniformVariables();
184 
185 private:
186  vtkUniformVariables(const vtkUniformVariables&) VTK_DELETE_FUNCTION;
187  void operator=(const vtkUniformVariables&) VTK_DELETE_FUNCTION;
188 
189  vtkUniformVariablesMap *Map;
190 };
191 
192 // ----------------------------------------------------------------------------
193 template<typename T>
194 void vtkUniformVariables::SetUniformit(const char *name,
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 // ----------------------------------------------------------------------------
207 template<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
abstract base class for most VTK objects
Definition: vtkObject.h:59
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 DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
void SetUniformft(const char *name, T value)
void SetUniformit(const char *name, T value)
a simple class to control print indentation
Definition: vtkIndent.h:39
static const unsigned int numberOfElements
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...