VTK  9.3.20240329
vtkShader.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
102 #ifndef vtkShader_h
103 #define vtkShader_h
104 
105 #include "vtkObject.h"
106 #include "vtkRenderingOpenGL2Module.h" // for export macro
107 
108 #include <string> // For member variables.
109 #include <vector> // For member variables.
110 
118 VTK_ABI_NAMESPACE_BEGIN
119 class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
120 {
121 public:
122  static vtkShader* New();
123  vtkTypeMacro(vtkShader, vtkObject);
124  void PrintSelf(ostream& os, vtkIndent indent) override;
125 
127  enum Type
128  {
133  Unknown
134  };
135 
138 
140  Type GetType() const { return this->ShaderType; }
141 
144 
146  std::string GetSource() const { return this->Source; }
147 
149  std::string GetError() const { return this->Error; }
150 
152  int GetHandle() const { return this->Handle; }
153 
157  bool Compile();
158 
163  void Cleanup();
164 
167 
169  {
170  public:
174  bool operator<(const ReplacementSpec& v1) const
175  {
176  if (this->OriginalValue != v1.OriginalValue)
177  {
178  return this->OriginalValue < v1.OriginalValue;
179  }
180  if (this->ShaderType != v1.ShaderType)
181  {
182  return this->ShaderType < v1.ShaderType;
183  }
184  return (this->ReplaceFirst < v1.ReplaceFirst);
185  }
186  bool operator>(const ReplacementSpec& v1) const
187  {
188  if (this->OriginalValue != v1.OriginalValue)
189  {
190  return this->OriginalValue > v1.OriginalValue;
191  }
192  if (this->ShaderType != v1.ShaderType)
193  {
194  return this->ShaderType > v1.ShaderType;
195  }
196  return (this->ReplaceFirst > v1.ReplaceFirst);
197  }
198  };
200  {
201  public:
204  };
205 
206 protected:
208  ~vtkShader() override;
209 
211  int Handle;
212  bool Dirty;
213 
216 
217 private:
218  vtkShader(const vtkShader&) = delete;
219  void operator=(const vtkShader&) = delete;
220 };
221 
222 VTK_ABI_NAMESPACE_END
223 #endif
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:162
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:186
vtkShader::Type ShaderType
Definition: vtkShader.h:172
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:174
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:120
void Cleanup()
Delete the shader.
Type ShaderType
Definition: vtkShader.h:210
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::string Error
Definition: vtkShader.h:215
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:140
static vtkShader * New()
int Handle
Definition: vtkShader.h:211
static bool IsComputeShaderSupported()
Check if compute shaders are supported.
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:146
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:149
bool Compile()
Compile the shader.
std::string Source
Definition: vtkShader.h:214
~vtkShader() override
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:152
Type
Available shader types.
Definition: vtkShader.h:128
@ Vertex
Vertex shader.
Definition: vtkShader.h:129
@ Geometry
Geometry shader.
Definition: vtkShader.h:131
@ Fragment
Fragment shader.
Definition: vtkShader.h:130
@ Compute
Compute shader.
Definition: vtkShader.h:132
bool Dirty
Definition: vtkShader.h:212
void SetSource(const std::string &source)
Set the shader source to the supplied string.
void SetType(Type type)
Set the shader type.
@ type
Definition: vtkX3D.h:516
@ string
Definition: vtkX3D.h:490
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)