VTK  9.2.6
vtkUniforms.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4 
5  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
31 #ifndef vtkUniforms_h
32 #define vtkUniforms_h
33 
34 #include "vtkObject.h"
35 #include "vtkRenderingCoreModule.h" // For export macro
36 #include <string> // member function parameters
37 #include <vector> // member function parameters
38 
39 class vtkMatrix3x3;
40 class vtkMatrix4x4;
41 
42 class VTKRENDERINGCORE_EXPORT vtkUniforms : public vtkObject
43 {
44 public:
45  static vtkUniforms* New();
46  vtkTypeMacro(vtkUniforms, vtkObject);
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
49  virtual vtkMTimeType GetUniformListMTime() = 0;
50 
52 
55  enum TupleType
57  {
58  TupleTypeInvalid = 0,
62  NumberOfTupleTypes
63  };
64 
66  static std::string TupleTypeToString(TupleType tt);
67  static TupleType StringToTupleType(const std::string& s);
68 
70  static std::string ScalarTypeToString(int scalarType);
71  static int StringToScalarType(const std::string& s);
72 
74  virtual void RemoveUniform(const char* name) = 0;
75 
77  virtual void RemoveAllUniforms() = 0;
78 
80 
84  virtual void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
85  const std::vector<int>& value) = 0;
86  virtual void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
87  const std::vector<float>& value) = 0;
88  virtual bool GetUniform(const char* name, std::vector<int>& value) = 0;
89  virtual bool GetUniform(const char* name, std::vector<float>& value) = 0;
91 
93 
94  virtual void SetUniformi(const char* name, int v) = 0;
95  virtual void SetUniformf(const char* name, float v) = 0;
96  virtual void SetUniform2i(const char* name, const int v[2]) = 0;
97  virtual void SetUniform2f(const char* name, const float v[2]) = 0;
98  virtual void SetUniform3f(const char* name, const float v[3]) = 0;
99  virtual void SetUniform4f(const char* name, const float v[4]) = 0;
100  virtual void SetUniformMatrix3x3(const char* name, float* v) = 0;
101  virtual void SetUniformMatrix4x4(const char* name, float* v) = 0;
103 
105 
106  virtual void SetUniform1iv(const char* name, const int count, const int* f) = 0;
107  virtual void SetUniform1fv(const char* name, const int count, const float* f) = 0;
108  virtual void SetUniform2fv(const char* name, const int count, const float (*f)[2]) = 0;
109  virtual void SetUniform3fv(const char* name, const int count, const float (*f)[3]) = 0;
110  virtual void SetUniform4fv(const char* name, const int count, const float (*f)[4]) = 0;
111  virtual void SetUniformMatrix4x4v(const char* name, const int count, float* v) = 0;
113 
115 
119  virtual void SetUniform3f(const char* name, const double v[3]) = 0;
120  virtual void SetUniform3uc(const char* name, const unsigned char v[3]) = 0; // maybe remove
121  virtual void SetUniform4uc(const char* name, const unsigned char v[4]) = 0; // maybe remove
122  virtual void SetUniformMatrix(const char* name, vtkMatrix3x3* v) = 0;
123  virtual void SetUniformMatrix(const char* name, vtkMatrix4x4* v) = 0;
125 
127 
128  virtual bool GetUniformi(const char* name, int& v) = 0;
129  virtual bool GetUniformf(const char* name, float& v) = 0;
130  virtual bool GetUniform2i(const char* name, int v[2]) = 0;
131  virtual bool GetUniform2f(const char* name, float v[2]) = 0;
132  virtual bool GetUniform3f(const char* name, float v[3]) = 0;
133  virtual bool GetUniform4f(const char* name, float v[4]) = 0;
134  virtual bool GetUniformMatrix3x3(const char* name, float* v) = 0;
135  virtual bool GetUniformMatrix4x4(const char* name, float* v) = 0;
137 
139 
143  virtual bool GetUniform3f(const char* name, double v[3]) = 0;
144  virtual bool GetUniform3uc(const char* name, unsigned char v[3]) = 0;
145  virtual bool GetUniform4uc(const char* name, unsigned char v[4]) = 0;
146  virtual bool GetUniformMatrix(const char* name, vtkMatrix3x3* v) = 0;
147  virtual bool GetUniformMatrix(const char* name, vtkMatrix4x4* v) = 0;
149 
151 
152  virtual bool GetUniform1iv(const char* name, std::vector<int>& f) = 0;
153  virtual bool GetUniform1fv(const char* name, std::vector<float>& f) = 0;
154  virtual bool GetUniform2fv(const char* name, std::vector<float>& f) = 0;
155  virtual bool GetUniform3fv(const char* name, std::vector<float>& f) = 0;
156  virtual bool GetUniform4fv(const char* name, std::vector<float>& f) = 0;
157  virtual bool GetUniformMatrix4x4v(const char* name, std::vector<float>& f) = 0;
159 
161  virtual int GetNumberOfUniforms() = 0;
162 
165  virtual const char* GetNthUniformName(vtkIdType uniformIndex) = 0;
166 
168  virtual int GetUniformScalarType(const char* name) = 0;
169 
172  virtual TupleType GetUniformTupleType(const char* name) = 0;
173 
177  virtual int GetUniformNumberOfComponents(const char* name) = 0;
178 
182  virtual int GetUniformNumberOfTuples(const char* name) = 0;
183 
184 protected:
185  vtkUniforms() = default;
186  ~vtkUniforms() override = default;
187 
188 private:
189  vtkUniforms(const vtkUniforms&) = delete;
190  void operator=(const vtkUniforms&) = delete;
191 };
192 
193 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:62
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
int vtkIdType
Definition: vtkType.h:332
TupleType
Types of tuples that can be stored : scalar, vector, matrix.
Definition: vtkUniforms.h:56
a simple class to control print indentation
Definition: vtkIndent.h:39
helper class to set custom uniform variables in GPU shaders.
Definition: vtkUniforms.h:42
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:36