VTK  9.2.6
vtkOpenGLUniforms.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 =========================================================================*/
34 #ifndef vtkOpenGLUniforms_h
35 #define vtkOpenGLUniforms_h
36 
37 #include "vtkRenderingOpenGL2Module.h" // For export macro
38 #include "vtkUniforms.h"
39 #include <string> // For member functions
40 
41 class vtkUniformInternals;
42 class vtkShaderProgram;
43 
44 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLUniforms : public vtkUniforms
45 {
46 public:
47  static vtkOpenGLUniforms* New();
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
54  std::string GetDeclarations();
55 
59  bool SetUniforms(vtkShaderProgram* p);
60 
67 
69  void RemoveUniform(const char* name) override;
70 
72  void RemoveAllUniforms() override;
73 
75 
79  void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
80  const std::vector<int>& value) override;
81  void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
82  const std::vector<float>& value) override;
83  bool GetUniform(const char* name, std::vector<int>& value) override;
84  bool GetUniform(const char* name, std::vector<float>& value) override;
86 
88 
89  void SetUniformi(const char* name, int v) override;
90  void SetUniformf(const char* name, float v) override;
91  void SetUniform2i(const char* name, const int v[2]) override;
92  void SetUniform2f(const char* name, const float v[2]) override;
93  void SetUniform3f(const char* name, const float v[3]) override;
94  void SetUniform4f(const char* name, const float v[4]) override;
95  void SetUniformMatrix3x3(const char* name, float* v) override;
96  void SetUniformMatrix4x4(const char* name, float* v) override;
98 
100 
101  void SetUniform1iv(const char* name, const int count, const int* f) override;
102  void SetUniform1fv(const char* name, const int count, const float* f) override;
103  void SetUniform2fv(const char* name, const int count, const float (*f)[2]) override;
104  void SetUniform3fv(const char* name, const int count, const float (*f)[3]) override;
105  void SetUniform4fv(const char* name, const int count, const float (*f)[4]) override;
106  void SetUniformMatrix4x4v(const char* name, const int count, float* v) override;
108 
110 
114  void SetUniform3f(const char* name, const double v[3]) override;
115  void SetUniform3uc(const char* name, const unsigned char v[3]) override; // maybe remove
116  void SetUniform4uc(const char* name, const unsigned char v[4]) override; // maybe remove
117  void SetUniformMatrix(const char* name, vtkMatrix3x3* v) override;
118  void SetUniformMatrix(const char* name, vtkMatrix4x4* v) override;
120 
122 
123  bool GetUniformi(const char* name, int& v) override;
124  bool GetUniformf(const char* name, float& v) override;
125  bool GetUniform2i(const char* name, int v[2]) override;
126  bool GetUniform2f(const char* name, float v[2]) override;
127  bool GetUniform3f(const char* name, float v[3]) override;
128  bool GetUniform4f(const char* name, float v[4]) override;
129  bool GetUniformMatrix3x3(const char* name, float* v) override;
130  bool GetUniformMatrix4x4(const char* name, float* v) override;
132 
134 
138  bool GetUniform3f(const char* name, double v[3]) override;
139  bool GetUniform3uc(const char* name, unsigned char v[3]) override;
140  bool GetUniform4uc(const char* name, unsigned char v[4]) override;
141  bool GetUniformMatrix(const char* name, vtkMatrix3x3* v) override;
142  bool GetUniformMatrix(const char* name, vtkMatrix4x4* v) override;
144 
146 
147  bool GetUniform1iv(const char* name, std::vector<int>& f) override;
148  bool GetUniform1fv(const char* name, std::vector<float>& f) override;
149  bool GetUniform2fv(const char* name, std::vector<float>& f) override;
150  bool GetUniform3fv(const char* name, std::vector<float>& f) override;
151  bool GetUniform4fv(const char* name, std::vector<float>& f) override;
152  bool GetUniformMatrix4x4v(const char* name, std::vector<float>& f) override;
154 
156  int GetNumberOfUniforms() override;
157 
160  const char* GetNthUniformName(vtkIdType uniformIndex) override;
161 
163  int GetUniformScalarType(const char* name) override;
164 
167  TupleType GetUniformTupleType(const char* name) override;
168 
172  int GetUniformNumberOfComponents(const char* name) override;
173 
176  int GetUniformNumberOfTuples(const char* name) override;
177 
178 protected:
180  ~vtkOpenGLUniforms() override;
181 
182 private:
183  vtkOpenGLUniforms(const vtkOpenGLUniforms&) = delete;
184  void operator=(const vtkOpenGLUniforms&) = delete;
185 
186  vtkUniformInternals* Internals;
187 };
188 
189 #endif
helper class to set custom uniform variables in GLSL shaders.
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 SetUniform4uc(const char *name, const unsigned char v[4])=0
Set the name uniform to v.
virtual void SetUniform2i(const char *name, const int v[2])=0
Set the name uniform value to v.
virtual const char * GetNthUniformName(vtkIdType uniformIndex)=0
Get number of all uniforms stored in this class.
virtual void SetUniform4f(const char *name, const float v[4])=0
Set the name uniform value to v.
virtual TupleType GetUniformTupleType(const char *name)=0
Get the tuple type stored in uniform name.
virtual void SetUniformMatrix4x4(const char *name, float *v)=0
Set the name uniform value to v.
virtual int GetUniformNumberOfTuples(const char *name)=0
Number of tuples of uniform name that contains a variable-size vector.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
virtual bool GetUniform2fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual bool GetUniformMatrix(const char *name, vtkMatrix3x3 *v)=0
Get the name uniform to v.
virtual void SetUniform2f(const char *name, const float v[2])=0
Set the name uniform value to v.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
virtual bool GetUniform1fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual bool GetUniformMatrix4x4v(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
static vtkUniforms * New()
virtual bool GetUniform3fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual vtkMTimeType GetUniformListMTime()=0
virtual int GetUniformNumberOfComponents(const char *name)=0
Get the number of components stored in each tuple of uniform name.
virtual void SetUniformMatrix(const char *name, vtkMatrix3x3 *v)=0
Set the name uniform to v.
virtual bool GetUniform2i(const char *name, int v[2])=0
Get the name uniform value.
virtual bool GetUniform4uc(const char *name, unsigned char v[4])=0
Get the name uniform to v.
virtual void SetUniformi(const char *name, int v)=0
Set the name uniform value to v.
virtual bool GetUniformMatrix3x3(const char *name, float *v)=0
Get the name uniform value.
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.
int vtkIdType
Definition: vtkType.h:332
virtual bool GetUniformf(const char *name, float &v)=0
Get the name uniform value.
virtual bool GetUniformi(const char *name, int &v)=0
Get the name uniform value.
virtual bool GetUniform4fv(const char *name, std::vector< float > &f)=0
Get the name uniform vector to f with.
virtual bool GetUniform3f(const char *name, float v[3])=0
Get the name uniform value.
virtual bool GetUniformMatrix4x4(const char *name, float *v)=0
Get the name uniform value.
TupleType
Types of tuples that can be stored : scalar, vector, matrix.
Definition: vtkUniforms.h:56
virtual void SetUniformf(const char *name, float v)=0
Set the name uniform value to v.
virtual int GetNumberOfUniforms()=0
Get number of all uniforms stored in this class.
a simple class to control print indentation
Definition: vtkIndent.h:39
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 GetUniform2f(const char *name, float v[2])=0
Get the name uniform value.
virtual void RemoveAllUniforms()=0
Remove all uniform variables.
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 RemoveUniform(const char *name)=0
Remove uniform variable named name.
virtual void SetUniform3uc(const char *name, const unsigned char v[3])=0
Set the name uniform to v.
virtual bool GetUniform3uc(const char *name, unsigned char v[3])=0
Get the name uniform 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 bool GetUniform(const char *name, std::vector< int > &value)=0
Generic setters and getter.
helper class to set custom uniform variables in GPU shaders.
Definition: vtkUniforms.h:42
virtual void SetUniformMatrix4x4v(const char *name, const int count, float *v)=0
Set the name uniform array to f with count elements.
virtual void SetUniform1iv(const char *name, const int count, const int *f)=0
Set the name uniform array to f with count elements.
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:36
virtual void SetUniform(const char *name, vtkUniforms::TupleType tt, int nbComponents, const std::vector< int > &value)=0
Generic setters and getter.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int GetUniformScalarType(const char *name)=0
Get type of scalars stored in uniform name.
The ShaderProgram uses one or more Shader objects.