VTK  9.5.20250711
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
28VTK_ABI_NAMESPACE_BEGIN
29class vtkMatrix3x3;
30class vtkMatrix4x4;
31
32class VTKRENDERINGCORE_EXPORT vtkUniforms : public vtkObject
33{
34public:
35 static vtkUniforms* New();
36 vtkTypeMacro(vtkUniforms, vtkObject);
37 void PrintSelf(ostream& os, vtkIndent indent) override;
38
40
42
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
181protected:
182 vtkUniforms() = default;
183 ~vtkUniforms() override = default;
184
185private:
186 vtkUniforms(const vtkUniforms&) = delete;
187 void operator=(const vtkUniforms&) = delete;
188};
189
190VTK_ABI_NAMESPACE_END
191#endif
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 3x3 transformation matrices
represent and manipulate 4x4 transformation matrices
abstract base class for most VTK objects
Definition vtkObject.h:162
helper class to set custom uniform variables in GPU shaders.
Definition vtkUniforms.h:33
virtual bool GetUniform4f(const char *name, float v[4])
Get the name uniform value.
virtual void SetUniformMatrix4x4(const char *name, float *v)
Set the name uniform value to v.
~vtkUniforms() override=default
virtual void SetUniform2i(const char *name, const int v[2])
Set the name uniform value to v.
virtual bool GetUniformMatrix(const char *name, vtkMatrix4x4 *v)
Get the name uniform to v.
virtual int GetUniformScalarType(const char *name)
Get type of scalars stored in uniform name.
virtual bool GetUniform(const char *name, std::vector< int > &value)
Generic setters and getter.
virtual bool GetUniform4fv(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual void SetUniformf(const char *name, float v)
Set the name uniform value to v.
static std::string TupleTypeToString(TupleType tt)
Convert between TupleType and string.
virtual void SetUniform1iv(const char *name, int count, const int *f)
Set the name uniform array to f with count elements.
virtual void SetUniform2fv(const char *name, int count, const float(*f)[2])
Set the name uniform array to f with count elements.
virtual void SetUniform3fv(const char *name, int count, const float(*f)[3])
Set the name uniform array to f with count elements.
virtual bool GetUniformMatrix3x3(const char *name, float *v)
Get the name uniform value.
virtual TupleType GetUniformTupleType(const char *name)
Get the tuple type stored in uniform name.
static TupleType StringToTupleType(const std::string &s)
Convert between TupleType and string.
virtual void SetUniformMatrix4x4v(const char *name, int count, float *v)
Set the name uniform array to f with count elements.
virtual bool GetUniformMatrix4x4v(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual bool GetUniform(const char *name, std::vector< float > &value)
Generic setters and getter.
virtual vtkMTimeType GetUniformListMTime()
virtual int GetUniformNumberOfComponents(const char *name)
Get the number of components stored in each tuple of uniform name.
virtual int GetNumberOfUniforms()
Get number of all uniforms stored in this class.
virtual void SetUniform4fv(const char *name, int count, const float(*f)[4])
Set the name uniform array to f with count elements.
virtual bool GetUniform1iv(const char *name, std::vector< int > &f)
Get the name uniform vector to f with.
virtual void RemoveAllUniforms()
Remove all uniform variables.
virtual void SetUniform1fv(const char *name, int count, const float *f)
Set the name uniform array to f with count elements.
virtual void SetUniform(const char *name, vtkUniforms::TupleType tt, int nbComponents, const std::vector< int > &value)
Generic setters and getter.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetUniform3f(const char *name, const double v[3])
Set the name uniform to v.
TupleType
Types of tuples that can be stored : scalar, vector, matrix.
Definition vtkUniforms.h:47
virtual bool GetUniform3f(const char *name, float v[3])
Get the name uniform value.
virtual bool GetUniform3fv(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual void SetUniform3uc(const char *name, const unsigned char v[3])
Set the name uniform to v.
virtual bool GetUniformf(const char *name, float &v)
Get the name uniform value.
virtual void SetUniformMatrix3x3(const char *name, float *v)
Set the name uniform value to v.
virtual void SetUniformi(const char *name, int v)
Set the name uniform value to v.
static vtkUniforms * New()
vtkUniforms()=default
static std::string ScalarTypeToString(int scalarType)
Convert between scalar types an string We only support int and float as internal data types for unifo...
virtual int GetUniformNumberOfTuples(const char *name)
Number of tuples of uniform name that contains a variable-size vector.
virtual bool GetUniformMatrix(const char *name, vtkMatrix3x3 *v)
Get the name uniform to v.
virtual void SetUniform3f(const char *name, const float v[3])
Set the name uniform value to v.
virtual void SetUniform2f(const char *name, const float v[2])
Set the name uniform value to v.
virtual bool GetUniform3f(const char *name, double v[3])
Get the name uniform to v.
virtual bool GetUniform2fv(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual bool GetUniform3uc(const char *name, unsigned char v[3])
Get the name uniform to v.
virtual bool GetUniform1fv(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual void SetUniform(const char *name, vtkUniforms::TupleType tt, int nbComponents, const std::vector< float > &value)
Generic setters and getter.
virtual void SetUniform4f(const char *name, const float v[4])
Set the name uniform value to v.
virtual bool GetUniformi(const char *name, int &v)
Get the name uniform value.
virtual void RemoveUniform(const char *name)
Remove uniform variable named name.
virtual bool GetUniformMatrix4x4(const char *name, float *v)
Get the name uniform value.
virtual void SetUniform4uc(const char *name, const unsigned char v[4])
Set the name uniform to v.
virtual void SetUniformMatrix(const char *name, vtkMatrix3x3 *v)
Set the name uniform to v.
static int StringToScalarType(const std::string &s)
Convert between scalar types an string We only support int and float as internal data types for unifo...
virtual void SetUniformMatrix(const char *name, vtkMatrix4x4 *v)
Set the name uniform to v.
virtual const char * GetNthUniformName(vtkIdType uniformIndex)
Get number of all uniforms stored in this class.
virtual bool GetUniform4uc(const char *name, unsigned char v[4])
Get the name uniform to v.
virtual bool GetUniform2f(const char *name, float v[2])
Get the name uniform value.
virtual bool GetUniform2i(const char *name, int v[2])
Get the name uniform value.
int vtkIdType
Definition vtkType.h:332
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287