VTK  9.3.0
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 
40 
42 
46  enum TupleType
47  {
48  TupleTypeInvalid = 0,
52  NumberOfTupleTypes
53  };
54 
58 
60  static std::string ScalarTypeToString(int scalarType);
61  static int StringToScalarType(const std::string& s);
62 
64  virtual void RemoveUniform(const char* name) = 0;
65 
67  virtual void RemoveAllUniforms() = 0;
68 
70 
74  virtual void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
75  const std::vector<int>& value) = 0;
76  virtual void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
77  const std::vector<float>& value) = 0;
78  virtual bool GetUniform(const char* name, std::vector<int>& value) = 0;
79  virtual bool GetUniform(const char* name, std::vector<float>& value) = 0;
81 
83 
84  virtual void SetUniformi(const char* name, int v) = 0;
85  virtual void SetUniformf(const char* name, float v) = 0;
86  virtual void SetUniform2i(const char* name, const int v[2]) = 0;
87  virtual void SetUniform2f(const char* name, const float v[2]) = 0;
88  virtual void SetUniform3f(const char* name, const float v[3]) = 0;
89  virtual void SetUniform4f(const char* name, const float v[4]) = 0;
90  virtual void SetUniformMatrix3x3(const char* name, float* v) = 0;
91  virtual void SetUniformMatrix4x4(const char* name, float* v) = 0;
93 
95 
96  virtual void SetUniform1iv(const char* name, int count, const int* f) = 0;
97  virtual void SetUniform1fv(const char* name, int count, const float* f) = 0;
98  virtual void SetUniform2fv(const char* name, int count, const float (*f)[2]) = 0;
99  virtual void SetUniform3fv(const char* name, int count, const float (*f)[3]) = 0;
100  virtual void SetUniform4fv(const char* name, int count, const float (*f)[4]) = 0;
101  virtual void SetUniformMatrix4x4v(const char* name, int count, float* v) = 0;
103 
105 
109  virtual void SetUniform3f(const char* name, const double v[3]) = 0;
110  virtual void SetUniform3uc(const char* name, const unsigned char v[3]) = 0; // maybe remove
111  virtual void SetUniform4uc(const char* name, const unsigned char v[4]) = 0; // maybe remove
112  virtual void SetUniformMatrix(const char* name, vtkMatrix3x3* v) = 0;
113  virtual void SetUniformMatrix(const char* name, vtkMatrix4x4* v) = 0;
115 
117 
118  virtual bool GetUniformi(const char* name, int& v) = 0;
119  virtual bool GetUniformf(const char* name, float& v) = 0;
120  virtual bool GetUniform2i(const char* name, int v[2]) = 0;
121  virtual bool GetUniform2f(const char* name, float v[2]) = 0;
122  virtual bool GetUniform3f(const char* name, float v[3]) = 0;
123  virtual bool GetUniform4f(const char* name, float v[4]) = 0;
124  virtual bool GetUniformMatrix3x3(const char* name, float* v) = 0;
125  virtual bool GetUniformMatrix4x4(const char* name, float* v) = 0;
127 
129 
133  virtual bool GetUniform3f(const char* name, double v[3]) = 0;
134  virtual bool GetUniform3uc(const char* name, unsigned char v[3]) = 0;
135  virtual bool GetUniform4uc(const char* name, unsigned char v[4]) = 0;
136  virtual bool GetUniformMatrix(const char* name, vtkMatrix3x3* v) = 0;
137  virtual bool GetUniformMatrix(const char* name, vtkMatrix4x4* v) = 0;
139 
141 
142  virtual bool GetUniform1iv(const char* name, std::vector<int>& f) = 0;
143  virtual bool GetUniform1fv(const char* name, std::vector<float>& f) = 0;
144  virtual bool GetUniform2fv(const char* name, std::vector<float>& f) = 0;
145  virtual bool GetUniform3fv(const char* name, std::vector<float>& f) = 0;
146  virtual bool GetUniform4fv(const char* name, std::vector<float>& f) = 0;
147  virtual bool GetUniformMatrix4x4v(const char* name, std::vector<float>& f) = 0;
149 
151  virtual int GetNumberOfUniforms() = 0;
152 
155  virtual const char* GetNthUniformName(vtkIdType uniformIndex) = 0;
156 
158  virtual int GetUniformScalarType(const char* name) = 0;
159 
162  virtual TupleType GetUniformTupleType(const char* name) = 0;
163 
167  virtual int GetUniformNumberOfComponents(const char* name) = 0;
168 
172  virtual int GetUniformNumberOfTuples(const char* name) = 0;
173 
174 protected:
175  vtkUniforms() = default;
176  ~vtkUniforms() override = default;
177 
178 private:
179  vtkUniforms(const vtkUniforms&) = delete;
180  void operator=(const vtkUniforms&) = delete;
181 };
182 
183 VTK_ABI_NAMESPACE_END
184 #endif
a simple class to control print indentation
Definition: vtkIndent.h:38
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:35
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:61
helper class to set custom uniform variables in GPU shaders.
Definition: vtkUniforms.h:33
virtual bool GetUniform3uc(const char *name, unsigned char v[3])=0
Get the name uniform to v.
virtual void SetUniform3f(const char *name, const double v[3])=0
Set the name uniform to v.
virtual bool GetUniformi(const char *name, int &v)=0
Get the name uniform value.
~vtkUniforms() override=default
virtual bool GetUniform(const char *name, std::vector< float > &value)=0
Generic setters and getter.
virtual void SetUniform4uc(const char *name, const unsigned char v[4])=0
Set the name uniform to v.
virtual void SetUniform1fv(const char *name, int count, const float *f)=0
Set the name uniform array to f with count elements.
virtual void SetUniform3uc(const char *name, const unsigned char v[3])=0
Set the name uniform to v.
virtual void SetUniform4f(const char *name, const float v[4])=0
Set the name uniform value to v.
virtual void SetUniform2f(const char *name, const float v[2])=0
Set the name uniform value to v.
virtual void SetUniformMatrix(const char *name, vtkMatrix4x4 *v)=0
Set the name uniform to v.
static std::string TupleTypeToString(TupleType tt)
Convert between TupleType and string.
virtual bool GetUniform1fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual int GetUniformNumberOfComponents(const char *name)=0
Get the number of components stored in each tuple of uniform name.
virtual bool GetUniform4fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
static TupleType StringToTupleType(const std::string &s)
virtual void SetUniformMatrix4x4(const char *name, float *v)=0
Set the name uniform value to v.
virtual bool GetUniform3fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual void SetUniformi(const char *name, int v)=0
Set the name uniform value to v.
virtual bool GetUniformMatrix4x4(const char *name, float *v)=0
Get the name uniform value.
virtual bool GetUniformMatrix(const char *name, vtkMatrix4x4 *v)=0
Get the name uniform to v.
virtual void SetUniform3fv(const char *name, int count, const float(*f)[3])=0
Set the name uniform array to f with count elements.
virtual void SetUniformMatrix3x3(const char *name, float *v)=0
Set the name uniform value to v.
virtual void SetUniform4fv(const char *name, int count, const float(*f)[4])=0
Set the name uniform array to f with count elements.
virtual bool GetUniform4f(const char *name, float v[4])=0
Get the name uniform value.
virtual bool GetUniformMatrix4x4v(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual bool GetUniformMatrix3x3(const char *name, float *v)=0
Get the name uniform value.
virtual int GetNumberOfUniforms()=0
Get number of all uniforms stored in this class.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool GetUniform4uc(const char *name, unsigned char v[4])=0
Get the name uniform to v.
virtual void SetUniform2i(const char *name, const int v[2])=0
Set the name uniform value to v.
virtual void RemoveAllUniforms()=0
Remove all uniform variables.
virtual const char * GetNthUniformName(vtkIdType uniformIndex)=0
Get number of all uniforms stored in this class.
virtual bool GetUniform2fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual bool GetUniform3f(const char *name, double v[3])=0
Get the name uniform to v.
TupleType
Types of tuples that can be stored : scalar, vector, matrix.
Definition: vtkUniforms.h:47
virtual int GetUniformScalarType(const char *name)=0
Get type of scalars stored in uniform name.
virtual void SetUniformMatrix4x4v(const char *name, int count, float *v)=0
Set the name uniform array to f with count elements.
virtual bool GetUniform2f(const char *name, float v[2])=0
Get the name uniform value.
vtkUniforms()=default
virtual bool GetUniform2i(const char *name, int v[2])=0
Get the name uniform value.
static std::string ScalarTypeToString(int scalarType)
Convert between scalar types an string.
virtual void RemoveUniform(const char *name)=0
Remove uniform variable named name.
virtual int GetUniformNumberOfTuples(const char *name)=0
Number of tuples of uniform name that contains a variable-size vector.
virtual void SetUniform2fv(const char *name, int count, const float(*f)[2])=0
Set the name uniform array to f with count elements.
virtual void SetUniformMatrix(const char *name, vtkMatrix3x3 *v)=0
Set the name uniform to v.
virtual void SetUniform(const char *name, vtkUniforms::TupleType tt, int nbComponents, const std::vector< int > &value)=0
Generic setters and getter.
virtual bool GetUniform3f(const char *name, float v[3])=0
Get the name uniform value.
virtual bool GetUniformMatrix(const char *name, vtkMatrix3x3 *v)=0
Get the name uniform to v.
virtual bool GetUniform(const char *name, std::vector< int > &value)=0
Generic setters and getter.
virtual void SetUniform1iv(const char *name, int count, const int *f)=0
Set the name uniform array to f with count elements.
static vtkUniforms * New()
virtual bool GetUniformf(const char *name, float &v)=0
Get the name uniform value.
virtual TupleType GetUniformTupleType(const char *name)=0
Get the tuple type stored in uniform name.
virtual void SetUniform(const char *name, vtkUniforms::TupleType tt, int nbComponents, const std::vector< float > &value)=0
Generic setters and getter.
virtual vtkMTimeType GetUniformListMTime()=0
static int StringToScalarType(const std::string &s)
virtual void SetUniformf(const char *name, float v)=0
Set the name uniform value to v.
virtual void SetUniform3f(const char *name, const float v[3])=0
Set the name uniform value to v.
virtual bool GetUniform1iv(const char *name, std::vector< int > &f)=0
Get the name uniform vector to f with.
@ value
Definition: vtkX3D.h:220
@ name
Definition: vtkX3D.h:219
@ string
Definition: vtkX3D.h:490
int vtkIdType
Definition: vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270