VTK  9.0.20201128
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 =========================================================================*/
31 #ifndef vtkOpenGLUniforms_h
32 #define vtkOpenGLUniforms_h
33 
34 #include "vtkRenderingOpenGL2Module.h" // For export macro
35 #include "vtkUniforms.h"
36 #include <string> // For member functions
37 
38 class vtkUniformInternals;
39 class vtkShaderProgram;
40 
41 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLUniforms : public vtkUniforms
42 {
43 public:
44  static vtkOpenGLUniforms* New();
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
51  std::string GetDeclarations();
52 
56  bool SetUniforms(vtkShaderProgram* p);
57 
64 
66  void RemoveUniform(const char* name) override;
67 
69  void RemoveAllUniforms() override;
70 
72 
76  void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
77  const std::vector<int>& value) override;
78  void SetUniform(const char* name, vtkUniforms::TupleType tt, int nbComponents,
79  const std::vector<float>& value) override;
80  bool GetUniform(const char* name, std::vector<int>& value) override;
81  bool GetUniform(const char* name, std::vector<float>& value) override;
83 
85 
86  void SetUniformi(const char* name, int v) override;
87  void SetUniformf(const char* name, float v) override;
88  void SetUniform2i(const char* name, const int v[2]) override;
89  void SetUniform2f(const char* name, const float v[2]) override;
90  void SetUniform3f(const char* name, const float v[3]) override;
91  void SetUniform4f(const char* name, const float v[4]) override;
92  void SetUniformMatrix3x3(const char* name, float* v) override;
93  void SetUniformMatrix4x4(const char* name, float* v) override;
95 
97 
98  void SetUniform1iv(const char* name, const int count, const int* f) override;
99  void SetUniform1fv(const char* name, const int count, const float* f) override;
100  void SetUniform2fv(const char* name, const int count, const float (*f)[2]) override;
101  void SetUniform3fv(const char* name, const int count, const float (*f)[3]) override;
102  void SetUniform4fv(const char* name, const int count, const float (*f)[4]) override;
103  void SetUniformMatrix4x4v(const char* name, const int count, float* v) override;
105 
107 
111  void SetUniform3f(const char* name, const double v[3]) override;
112  void SetUniform3uc(const char* name, const unsigned char v[3]) override; // maybe remove
113  void SetUniform4uc(const char* name, const unsigned char v[4]) override; // maybe remove
114  void SetUniformMatrix(const char* name, vtkMatrix3x3* v) override;
115  void SetUniformMatrix(const char* name, vtkMatrix4x4* v) override;
117 
119 
120  bool GetUniformi(const char* name, int& v) override;
121  bool GetUniformf(const char* name, float& v) override;
122  bool GetUniform2i(const char* name, int v[2]) override;
123  bool GetUniform2f(const char* name, float v[2]) override;
124  bool GetUniform3f(const char* name, float v[3]) override;
125  bool GetUniform4f(const char* name, float v[4]) override;
126  bool GetUniformMatrix3x3(const char* name, float* v) override;
127  bool GetUniformMatrix4x4(const char* name, float* v) override;
129 
131 
135  bool GetUniform3f(const char* name, double v[3]) override;
136  bool GetUniform3uc(const char* name, unsigned char v[3]) override;
137  bool GetUniform4uc(const char* name, unsigned char v[4]) override;
138  bool GetUniformMatrix(const char* name, vtkMatrix3x3* v) override;
139  bool GetUniformMatrix(const char* name, vtkMatrix4x4* v) override;
141 
143 
144  bool GetUniform1iv(const char* name, std::vector<int>& f) override;
145  bool GetUniform1fv(const char* name, std::vector<float>& f) override;
146  bool GetUniform2fv(const char* name, std::vector<float>& f) override;
147  bool GetUniform3fv(const char* name, std::vector<float>& f) override;
148  bool GetUniform4fv(const char* name, std::vector<float>& f) override;
149  bool GetUniformMatrix4x4v(const char* name, std::vector<float>& f) override;
151 
153  int GetNumberOfUniforms() override;
154 
157  const char* GetNthUniformName(vtkIdType uniformIndex) override;
158 
160  int GetUniformScalarType(const char* name) override;
161 
164  TupleType GetUniformTupleType(const char* name) override;
165 
169  int GetUniformNumberOfComponents(const char* name) override;
170 
173  int GetUniformNumberOfTuples(const char* name) override;
174 
175 protected:
177  ~vtkOpenGLUniforms() override;
178 
179 private:
180  vtkOpenGLUniforms(const vtkOpenGLUniforms&) = delete;
181  void operator=(const vtkOpenGLUniforms&) = delete;
182 
183  vtkUniformInternals* Internals;
184 };
185 
186 #endif
vtkUniforms::SetUniform1iv
virtual void SetUniform1iv(const char *name, const int count, const int *f)=0
Set the name uniform array to f with count elements.
vtkUniforms::SetUniformMatrix4x4
virtual void SetUniformMatrix4x4(const char *name, float *v)=0
vtkUniforms::SetUniform4f
virtual void SetUniform4f(const char *name, const float v[4])=0
vtkUniforms::GetUniform3fv
virtual bool GetUniform3fv(const char *name, std::vector< float > &f)=0
vtkUniforms::GetUniformMatrix4x4v
virtual bool GetUniformMatrix4x4v(const char *name, std::vector< float > &f)=0
vtkUniforms::GetUniformListMTime
virtual vtkMTimeType GetUniformListMTime()=0
vtkUniforms::GetUniform2fv
virtual bool GetUniform2fv(const char *name, std::vector< float > &f)=0
vtkUniforms::GetUniformMatrix
virtual bool GetUniformMatrix(const char *name, vtkMatrix3x3 *v)=0
vtkUniforms::SetUniform
virtual void SetUniform(const char *name, vtkUniforms::TupleType tt, int nbComponents, const std::vector< int > &value)=0
Generic setters and getter.
vtkOpenGLUniforms
helper class to set custom uniform variables in GLSL shaders.
Definition: vtkOpenGLUniforms.h:41
vtkX3D::value
Definition: vtkX3D.h:226
vtkUniforms::GetUniformMatrix3x3
virtual bool GetUniformMatrix3x3(const char *name, float *v)=0
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkUniforms::SetUniform4uc
virtual void SetUniform4uc(const char *name, const unsigned char v[4])=0
vtkUniforms::SetUniform2f
virtual void SetUniform2f(const char *name, const float v[2])=0
vtkUniforms::New
static vtkUniforms * New()
vtkUniforms::GetUniformNumberOfComponents
virtual int GetUniformNumberOfComponents(const char *name)=0
Get the number of components stored in each tuple of uniform name.
vtkUniforms::SetUniformi
virtual void SetUniformi(const char *name, int v)=0
Set the name uniform value to v.
vtkUniforms::GetUniformi
virtual bool GetUniformi(const char *name, int &v)=0
Get the name uniform value.
vtkUniforms::SetUniform3f
virtual void SetUniform3f(const char *name, const float v[3])=0
vtkMatrix3x3
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:33
vtkUniforms::GetUniform1iv
virtual bool GetUniform1iv(const char *name, std::vector< int > &f)=0
Get the name uniform vector to f with.
vtkUniforms::SetUniform2fv
virtual void SetUniform2fv(const char *name, const int count, const float(*f)[2])=0
vtkUniforms::GetUniform4fv
virtual bool GetUniform4fv(const char *name, std::vector< float > &f)=0
vtkUniforms::GetUniformf
virtual bool GetUniformf(const char *name, float &v)=0
vtkUniforms::GetUniform4uc
virtual bool GetUniform4uc(const char *name, unsigned char v[4])=0
vtkUniforms::SetUniformMatrix
virtual void SetUniformMatrix(const char *name, vtkMatrix3x3 *v)=0
vtkUniforms::GetUniform2i
virtual bool GetUniform2i(const char *name, int v[2])=0
vtkUniforms::SetUniformf
virtual void SetUniformf(const char *name, float v)=0
vtkUniforms
helper class to set custom uniform variables in GPU shaders.
Definition: vtkUniforms.h:42
vtkUniforms::RemoveUniform
virtual void RemoveUniform(const char *name)=0
Remove uniform variable named name.
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:44
vtkUniforms::RemoveAllUniforms
virtual void RemoveAllUniforms()=0
Remove all uniform variables.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkUniforms::GetUniformMatrix4x4
virtual bool GetUniformMatrix4x4(const char *name, float *v)=0
vtkUniforms::GetUniform
virtual bool GetUniform(const char *name, std::vector< int > &value)=0
vtkUniforms::SetUniformMatrix3x3
virtual void SetUniformMatrix3x3(const char *name, float *v)=0
vtkUniforms::GetUniform3f
virtual bool GetUniform3f(const char *name, float v[3])=0
vtkUniforms::TupleType
TupleType
Types of tuples that can be stored : scalar, vector, matrix.
Definition: vtkUniforms.h:56
vtkUniforms::GetUniform2f
virtual bool GetUniform2f(const char *name, float v[2])=0
vtkUniforms::GetUniform4f
virtual bool GetUniform4f(const char *name, float v[4])=0
vtkUniforms::SetUniform1fv
virtual void SetUniform1fv(const char *name, const int count, const float *f)=0
vtkX3D::name
Definition: vtkX3D.h:225
vtkUniforms::GetNumberOfUniforms
virtual int GetNumberOfUniforms()=0
Get number of all uniforms stored in this class.
vtkX3D::string
Definition: vtkX3D.h:496
vtkUniforms::GetUniform3uc
virtual bool GetUniform3uc(const char *name, unsigned char v[3])=0
vtkUniforms::SetUniform4fv
virtual void SetUniform4fv(const char *name, const int count, const float(*f)[4])=0
vtkUniforms::SetUniform3uc
virtual void SetUniform3uc(const char *name, const unsigned char v[3])=0
vtkUniforms::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUniforms::SetUniform3fv
virtual void SetUniform3fv(const char *name, const int count, const float(*f)[3])=0
vtkUniforms::SetUniformMatrix4x4v
virtual void SetUniformMatrix4x4v(const char *name, const int count, float *v)=0
vtkUniforms.h
vtkUniforms::GetNthUniformName
virtual const char * GetNthUniformName(vtkIdType uniformIndex)=0
Get number of all uniforms stored in this class.
vtkUniforms::GetUniformTupleType
virtual TupleType GetUniformTupleType(const char *name)=0
Get the tuple type stored in uniform name.
vtkUniforms::GetUniformNumberOfTuples
virtual int GetUniformNumberOfTuples(const char *name)=0
Number of tuples of uniform name that contains a variable-size vector.
vtkUniforms::GetUniformScalarType
virtual int GetUniformScalarType(const char *name)=0
Get type of scalars stored in uniform name.
vtkUniforms::SetUniform2i
virtual void SetUniform2i(const char *name, const int v[2])=0
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285
vtkUniforms::GetUniform1fv
virtual bool GetUniform1fv(const char *name, std::vector< float > &f)=0