VTK  9.1.0
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
39class vtkMatrix3x3;
40class vtkMatrix4x4;
41
42class VTKRENDERINGCORE_EXPORT vtkUniforms : public vtkObject
43{
44public:
45 static vtkUniforms* New();
46 vtkTypeMacro(vtkUniforms, vtkObject);
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
50
52
57 {
58 TupleTypeInvalid = 0,
62 NumberOfTupleTypes
63 };
64
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
184protected:
185 vtkUniforms() = default;
186 ~vtkUniforms() override = default;
187
188private:
189 vtkUniforms(const vtkUniforms&) = delete;
190 void operator=(const vtkUniforms&) = delete;
191};
192
193#endif
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:63
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
abstract base class for most VTK objects
Definition: vtkObject.h:73
helper class to set custom uniform variables in GPU shaders.
Definition: vtkUniforms.h:43
virtual bool GetUniform3uc(const char *name, unsigned char v[3])=0
Get the name uniform to v.
virtual void SetUniform4fv(const char *name, const int count, const float(*f)[4])=0
Set the name uniform array to f with count elements.
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 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 SetUniformMatrix3x3(const char *name, float *v)=0
Set the name uniform value to v.
virtual void SetUniform2fv(const char *name, const int count, const float(*f)[2])=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 void SetUniform1iv(const char *name, const int count, const int *f)=0
Set the name uniform array to f with count elements.
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:57
virtual int GetUniformScalarType(const char *name)=0
Get type of scalars stored in uniform name.
static vtkUniforms * New()
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 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 const char * GetNthUniformName(vtkIdType uniformIndex)=0
Get number of all uniforms stored in this class.
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 SetUniform1fv(const char *name, const int count, const float *f)=0
Set the name uniform array to f with count elements.
virtual void SetUniform3fv(const char *name, const int count, const float(*f)[3])=0
Set the name uniform array to f with count elements.
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.
virtual void SetUniformMatrix4x4v(const char *name, const int count, float *v)=0
Set the name uniform array to f with count elements.
@ value
Definition: vtkX3D.h:226
@ name
Definition: vtkX3D.h:225
@ string
Definition: vtkX3D.h:496
int vtkIdType
Definition: vtkType.h:332
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287