VTK  9.7.1
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
13 #ifndef vtkShader_h
14 #define vtkShader_h
15 
16 #include "vtkObject.h"
17 #include "vtkRenderingOpenGL2Module.h" // for export macro
18 
19 #include <string> // For member variables.
20 #include <vector> // For member variables.
21 
29 VTK_ABI_NAMESPACE_BEGIN
30 class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
31 {
32 public:
33  static vtkShader* New();
34  vtkTypeMacro(vtkShader, vtkObject);
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
38  enum Type
39  {
47  };
48 
50  void SetType(Type type);
51 
53  Type GetType() const { return this->ShaderType; }
54 
56  void SetSource(const std::string& source);
57 
59  std::string GetSource() const { return this->Source; }
60 
62  std::string GetError() const { return this->Error; }
63 
65  int GetHandle() const { return this->Handle; }
66 
70  bool Compile();
71 
76  void Cleanup();
77 
79  static bool IsComputeShaderSupported();
80 
82  static bool IsTessellationShaderSupported();
83 
85  {
86  public:
90  bool operator<(const ReplacementSpec& v1) const
91  {
92  if (this->OriginalValue != v1.OriginalValue)
93  {
94  return this->OriginalValue < v1.OriginalValue;
95  }
96  if (this->ShaderType != v1.ShaderType)
97  {
98  return this->ShaderType < v1.ShaderType;
99  }
100  return (this->ReplaceFirst < v1.ReplaceFirst);
101  }
102  bool operator>(const ReplacementSpec& v1) const
103  {
104  if (this->OriginalValue != v1.OriginalValue)
105  {
106  return this->OriginalValue > v1.OriginalValue;
107  }
108  if (this->ShaderType != v1.ShaderType)
109  {
110  return this->ShaderType > v1.ShaderType;
111  }
112  return (this->ReplaceFirst > v1.ReplaceFirst);
113  }
114  };
116  {
117  public:
120  };
121 
122 protected:
123  vtkShader();
124  ~vtkShader() override;
125 
127  int Handle;
128  bool Dirty;
129 
132 
133 private:
134  vtkShader(const vtkShader&) = delete;
135  void operator=(const vtkShader&) = delete;
136 };
137 
138 VTK_ABI_NAMESPACE_END
139 #endif
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:53
std::string OriginalValue
Definition: vtkShader.h:87
abstract base class for most VTK objects
Definition: vtkObject.h:52
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Geometry shader.
Definition: vtkShader.h:42
Type
Available shader types.
Definition: vtkShader.h:38
std::string Error
Definition: vtkShader.h:131
Fragment shader.
Definition: vtkShader.h:41
bool Dirty
Definition: vtkShader.h:128
a simple class to control print indentation
Definition: vtkIndent.h:28
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:65
std::string Source
Definition: vtkShader.h:130
Tessellation Control.
Definition: vtkShader.h:44
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:62
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:90
int Handle
Definition: vtkShader.h:127
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:102
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Type ShaderType
Definition: vtkShader.h:126
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:30
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:59
vtkShader::Type ShaderType
Definition: vtkShader.h:88
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Tessellation Evaluation.
Definition: vtkShader.h:45
Vertex shader.
Definition: vtkShader.h:40
Compute shader.
Definition: vtkShader.h:43