VTK  9.7.1
vtkUniforms.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkUniforms_h
21 #define vtkUniforms_h
22 
23 #include "vtkObject.h"
24 #include "vtkRenderingCoreModule.h" // For export macro
25 #include <string> // member function parameters
26 #include <vector> // member function parameters
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkMatrix3x3;
30 class vtkMatrix4x4;
31 
32 class VTKRENDERINGCORE_EXPORT vtkUniforms : public vtkObject
33 {
34 public:
35  static vtkUniforms* New();
36  vtkTypeMacro(vtkUniforms, vtkObject);
37  void PrintSelf(ostream& os, vtkIndent indent) override;
38 
39  virtual vtkMTimeType GetUniformListMTime();
40 
42 
45  enum TupleType
47  {
48  TupleTypeInvalid = 0,
52  NumberOfTupleTypes
53  };
54 
56 
57  static std::string TupleTypeToString(TupleType tt);
58  static TupleType StringToTupleType(const std::string& s);
60 
62 
66  static std::string ScalarTypeToString(int scalarType);
67  static int StringToScalarType(const std::string& s);
69 
71  virtual void RemoveUniform(const char* name);
72 
74  virtual void RemoveAllUniforms();
75 
77 
81  virtual void SetUniform(
82  const char* name, vtkUniforms::TupleType tt, int nbComponents, const std::vector<int>& value);
83  virtual void SetUniform(
84  const char* name, vtkUniforms::TupleType tt, int nbComponents, const std::vector<float>& value);
85  virtual bool GetUniform(const char* name, std::vector<int>& value);
86  virtual bool GetUniform(const char* name, std::vector<float>& value);
88 
90 
91  virtual void SetUniformi(const char* name, int v);
92  virtual void SetUniformf(const char* name, float v);
93  virtual void SetUniform2i(const char* name, const int v[2]);
94  virtual void SetUniform2f(const char* name, const float v[2]);
95  virtual void SetUniform3f(const char* name, const float v[3]);
96  virtual void SetUniform4f(const char* name, const float v[4]);
97  virtual void SetUniformMatrix3x3(const char* name, float* v);
98  virtual void SetUniformMatrix4x4(const char* name, float* v);
100 
102 
103  virtual void SetUniform1iv(const char* name, int count, const int* f);
104  virtual void SetUniform1fv(const char* name, int count, const float* f);
105  virtual void SetUniform2fv(const char* name, int count, const float (*f)[2]);
106  virtual void SetUniform3fv(const char* name, int count, const float (*f)[3]);
107  virtual void SetUniform4fv(const char* name, int count, const float (*f)[4]);
108  virtual void SetUniformMatrix4x4v(const char* name, int count, float* v);
110 
112 
116  virtual void SetUniform3f(const char* name, const double v[3]);
117  virtual void SetUniform3uc(const char* name, const unsigned char v[3]); // maybe remove
118  virtual void SetUniform4uc(const char* name, const unsigned char v[4]); // maybe remove
119  virtual void SetUniformMatrix(const char* name, vtkMatrix3x3* v);
120  virtual void SetUniformMatrix(const char* name, vtkMatrix4x4* v);
122 
124 
125  virtual bool GetUniformi(const char* name, int& v);
126  virtual bool GetUniformf(const char* name, float& v);
127  virtual bool GetUniform2i(const char* name, int v[2]);
128  virtual bool GetUniform2f(const char* name, float v[2]);
129  virtual bool GetUniform3f(const char* name, float v[3]);
130  virtual bool GetUniform4f(const char* name, float v[4]);
131  virtual bool GetUniformMatrix3x3(const char* name, float* v);
132  virtual bool GetUniformMatrix4x4(const char* name, float* v);
134 
136 
140  virtual bool GetUniform3f(const char* name, double v[3]);
141  virtual bool GetUniform3uc(const char* name, unsigned char v[3]);
142  virtual bool GetUniform4uc(const char* name, unsigned char v[4]);
143  virtual bool GetUniformMatrix(const char* name, vtkMatrix3x3* v);
144  virtual bool GetUniformMatrix(const char* name, vtkMatrix4x4* v);
146 
148 
149  virtual bool GetUniform1iv(const char* name, std::vector<int>& f);
150  virtual bool GetUniform1fv(const char* name, std::vector<float>& f);
151  virtual bool GetUniform2fv(const char* name, std::vector<float>& f);
152  virtual bool GetUniform3fv(const char* name, std::vector<float>& f);
153  virtual bool GetUniform4fv(const char* name, std::vector<float>& f);
154  virtual bool GetUniformMatrix4x4v(const char* name, std::vector<float>& f);
156 
158  virtual int GetNumberOfUniforms();
159 
162  virtual const char* GetNthUniformName(vtkIdType uniformIndex);
163 
165  virtual int GetUniformScalarType(const char* name);
166 
169  virtual TupleType GetUniformTupleType(const char* name);
170 
174  virtual int GetUniformNumberOfComponents(const char* name);
175 
179  virtual int GetUniformNumberOfTuples(const char* name);
180 
181 protected:
182  vtkUniforms() = default;
183  ~vtkUniforms() override = default;
184 
185 private:
186  vtkUniforms(const vtkUniforms&) = delete;
187  void operator=(const vtkUniforms&) = delete;
188 };
189 
190 VTK_ABI_NAMESPACE_END
191 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:52
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
int vtkIdType
Definition: vtkType.h:363
TupleType
Types of tuples that can be stored : scalar, vector, matrix.
Definition: vtkUniforms.h:46
a simple class to control print indentation
Definition: vtkIndent.h:28
helper class to set custom uniform variables in GPU shaders.
Definition: vtkUniforms.h:32
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:26