VTK  9.7.1
vtkOpenGLUniforms.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
23 #ifndef vtkOpenGLUniforms_h
24 #define vtkOpenGLUniforms_h
25 
26 #include "vtkRenderingOpenGL2Module.h" // For export macro
27 #include "vtkUniforms.h"
28 #include <string> // For member functions
29 
30 VTK_ABI_NAMESPACE_BEGIN
31 class vtkUniformInternals;
32 class vtkShaderProgram;
34 
35 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLUniforms : public vtkUniforms
36 {
37 public:
38  static vtkOpenGLUniforms* New();
40  static vtkOverrideAttribute* CreateOverrideAttributes();
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
47  std::string GetDeclarations();
48 
52  bool SetUniforms(vtkShaderProgram* p);
53 
60 
62  void RemoveUniform(const char* name) override;
63 
65  void RemoveAllUniforms() override;
66 
68 
72  void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
73  const std::vector<int>& value) override;
74  void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
75  const std::vector<float>& value) override;
76  bool GetUniform(const char* name, std::vector<int>& value) override;
77  bool GetUniform(const char* name, std::vector<float>& value) override;
79 
81 
82  void SetUniformi(const char* name, int v) override;
83  void SetUniformf(const char* name, float v) override;
84  void SetUniform2i(const char* name, const int v[2]) override;
85  void SetUniform2f(const char* name, const float v[2]) override;
86  void SetUniform3f(const char* name, const float v[3]) override;
87  void SetUniform4f(const char* name, const float v[4]) override;
88  void SetUniformMatrix3x3(const char* name, float* v) override;
89  void SetUniformMatrix4x4(const char* name, float* v) override;
91 
93 
94  void SetUniform1iv(const char* name, int count, const int* f) override;
95  void SetUniform1fv(const char* name, int count, const float* f) override;
96  void SetUniform2fv(const char* name, int count, const float (*f)[2]) override;
97  void SetUniform3fv(const char* name, int count, const float (*f)[3]) override;
98  void SetUniform4fv(const char* name, int count, const float (*f)[4]) override;
99  void SetUniformMatrix4x4v(const char* name, int count, float* v) override;
101 
103 
107  void SetUniform3f(const char* name, const double v[3]) override;
108  void SetUniform3uc(const char* name, const unsigned char v[3]) override; // maybe remove
109  void SetUniform4uc(const char* name, const unsigned char v[4]) override; // maybe remove
110  void SetUniformMatrix(const char* name, vtkMatrix3x3* v) override;
111  void SetUniformMatrix(const char* name, vtkMatrix4x4* v) override;
113 
115 
116  bool GetUniformi(const char* name, int& v) override;
117  bool GetUniformf(const char* name, float& v) override;
118  bool GetUniform2i(const char* name, int v[2]) override;
119  bool GetUniform2f(const char* name, float v[2]) override;
120  bool GetUniform3f(const char* name, float v[3]) override;
121  bool GetUniform4f(const char* name, float v[4]) override;
122  bool GetUniformMatrix3x3(const char* name, float* v) override;
123  bool GetUniformMatrix4x4(const char* name, float* v) override;
125 
127 
131  bool GetUniform3f(const char* name, double v[3]) override;
132  bool GetUniform3uc(const char* name, unsigned char v[3]) override;
133  bool GetUniform4uc(const char* name, unsigned char v[4]) override;
134  bool GetUniformMatrix(const char* name, vtkMatrix3x3* v) override;
135  bool GetUniformMatrix(const char* name, vtkMatrix4x4* v) override;
137 
139 
140  bool GetUniform1iv(const char* name, std::vector<int>& f) override;
141  bool GetUniform1fv(const char* name, std::vector<float>& f) override;
142  bool GetUniform2fv(const char* name, std::vector<float>& f) override;
143  bool GetUniform3fv(const char* name, std::vector<float>& f) override;
144  bool GetUniform4fv(const char* name, std::vector<float>& f) override;
145  bool GetUniformMatrix4x4v(const char* name, std::vector<float>& f) override;
147 
149  int GetNumberOfUniforms() override;
150 
153  const char* GetNthUniformName(vtkIdType uniformIndex) override;
154 
156  int GetUniformScalarType(const char* name) override;
157 
160  TupleType GetUniformTupleType(const char* name) override;
161 
165  int GetUniformNumberOfComponents(const char* name) override;
166 
169  int GetUniformNumberOfTuples(const char* name) override;
170 
171 protected:
173  ~vtkOpenGLUniforms() override;
174 
175 private:
176  vtkOpenGLUniforms(const vtkOpenGLUniforms&) = delete;
177  void operator=(const vtkOpenGLUniforms&) = delete;
178 
179  vtkUniformInternals* Internals;
180 };
181 
182 #define vtkOpenGLUniforms_OVERRIDE_ATTRIBUTES vtkOpenGLUniforms::CreateOverrideAttributes()
183 VTK_ABI_NAMESPACE_END
184 #endif
helper class to set custom uniform variables in GLSL shaders.
virtual TupleType GetUniformTupleType(const char *name)
Get the tuple type stored in uniform name.
virtual bool GetUniform(const char *name, std::vector< int > &value)
Generic setters and getter.
Attribute for vtkObjectFactory overrides.
virtual void SetUniformMatrix4x4v(const char *name, int count, float *v)
Set the name uniform array to f with count elements.
virtual void SetUniform4fv(const char *name, int count, const float(*f)[4])
Set the name uniform array to f with count elements.
virtual void SetUniform2f(const char *name, const float v[2])
Set the name uniform value to v.
virtual bool GetUniform3f(const char *name, float v[3])
Get the name uniform value.
virtual bool GetUniform4uc(const char *name, unsigned char v[4])
Get the name uniform to v.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
virtual int GetUniformNumberOfTuples(const char *name)
Number of tuples of uniform name that contains a variable-size vector.
virtual void SetUniform(const char *name, vtkUniforms::TupleType tt, int nbComponents, const std::vector< int > &value)
Generic setters and getter.
virtual int GetNumberOfUniforms()
Get number of all uniforms stored in this class.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
static vtkUniforms * New()
virtual void SetUniformi(const char *name, int v)
Set the name uniform value to v.
virtual bool GetUniformMatrix3x3(const char *name, float *v)
Get the name uniform value.
virtual const char * GetNthUniformName(vtkIdType uniformIndex)
Get number of all uniforms stored in this class.
int vtkIdType
Definition: vtkType.h:363
virtual bool GetUniformi(const char *name, int &v)
Get the name uniform value.
virtual void SetUniform2fv(const char *name, int count, const float(*f)[2])
Set the name uniform array to f with count elements.
virtual void SetUniform1fv(const char *name, int count, const float *f)
Set the name uniform array to f with count elements.
virtual bool GetUniform2fv(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual void SetUniformMatrix(const char *name, vtkMatrix3x3 *v)
Set the name uniform to v.
virtual bool GetUniform4fv(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual bool GetUniform3fv(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.
virtual int GetUniformNumberOfComponents(const char *name)
Get the number of components stored in each tuple of uniform name.
TupleType
Types of tuples that can be stored : scalar, vector, matrix.
Definition: vtkUniforms.h:46
virtual void SetUniform3uc(const char *name, const unsigned char v[3])
Set the name uniform to v.
virtual bool GetUniformMatrix4x4(const char *name, float *v)
Get the name uniform value.
virtual void RemoveUniform(const char *name)
Remove uniform variable named name.
virtual void SetUniformMatrix3x3(const char *name, float *v)
Set the name uniform value to v.
virtual int GetUniformScalarType(const char *name)
Get type of scalars stored in uniform name.
virtual bool GetUniformMatrix(const char *name, vtkMatrix3x3 *v)
Get the name uniform to v.
virtual bool GetUniform2f(const char *name, float v[2])
Get the name uniform value.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void RemoveAllUniforms()
Remove all uniform variables.
virtual void SetUniform4f(const char *name, const float v[4])
Set the name uniform value to v.
virtual bool GetUniformMatrix4x4v(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual void SetUniform3f(const char *name, const float v[3])
Set the name uniform value to v.
virtual void SetUniform3fv(const char *name, int count, const float(*f)[3])
Set the name uniform array to f with count elements.
virtual void SetUniform4uc(const char *name, const unsigned char v[4])
Set the name uniform to v.
#define VTK_NEWINSTANCE
virtual vtkMTimeType GetUniformListMTime()
virtual bool GetUniform1fv(const char *name, std::vector< float > &f)
Get the name uniform vector to f with.
virtual bool GetUniform4f(const char *name, float v[4])
Get the name uniform value.
helper class to set custom uniform variables in GPU shaders.
Definition: vtkUniforms.h:32
virtual void SetUniform1iv(const char *name, int count, const int *f)
Set the name uniform array to f with count elements.
virtual void SetUniform2i(const char *name, const int v[2])
Set the name uniform value to v.
virtual bool GetUniformf(const char *name, float &v)
Get the name uniform value.
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:26
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetUniformMatrix4x4(const char *name, float *v)
Set the name uniform value to v.
virtual bool GetUniform1iv(const char *name, std::vector< int > &f)
Get the name uniform vector to f with.
virtual bool GetUniform2i(const char *name, int v[2])
Get the name uniform value.
The ShaderProgram uses one or more Shader objects.
virtual bool GetUniform3uc(const char *name, unsigned char v[3])
Get the name uniform to v.