VTK  9.3.0
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
19 #ifndef vtkShader_h
20 #define vtkShader_h
21 
22 #include "vtkObject.h"
23 #include "vtkRenderingOpenGL2Module.h" // for export macro
24 
25 #include <string> // For member variables.
26 #include <vector> // For member variables.
27 
35 VTK_ABI_NAMESPACE_BEGIN
36 class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
37 {
38 public:
39  static vtkShader* New();
40  vtkTypeMacro(vtkShader, vtkObject);
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
44  enum Type
45  {
49  Unknown
50  };
51 
53  void SetType(Type type);
54 
56  Type GetType() const { return this->ShaderType; }
57 
60 
62  std::string GetSource() const { return this->Source; }
63 
65  std::string GetError() const { return this->Error; }
66 
68  int GetHandle() const { return this->Handle; }
69 
73  bool Compile();
74 
79  void Cleanup();
80 
82  {
83  public:
87  bool operator<(const ReplacementSpec& v1) const
88  {
89  if (this->OriginalValue != v1.OriginalValue)
90  {
91  return this->OriginalValue < v1.OriginalValue;
92  }
93  if (this->ShaderType != v1.ShaderType)
94  {
95  return this->ShaderType < v1.ShaderType;
96  }
97  return (this->ReplaceFirst < v1.ReplaceFirst);
98  }
99  bool operator>(const ReplacementSpec& v1) const
100  {
101  if (this->OriginalValue != v1.OriginalValue)
102  {
103  return this->OriginalValue > v1.OriginalValue;
104  }
105  if (this->ShaderType != v1.ShaderType)
106  {
107  return this->ShaderType > v1.ShaderType;
108  }
109  return (this->ReplaceFirst > v1.ReplaceFirst);
110  }
111  };
113  {
114  public:
117  };
118 
119 protected:
121  ~vtkShader() override;
122 
124  int Handle;
125  bool Dirty;
126 
129 
130 private:
131  vtkShader(const vtkShader&) = delete;
132  void operator=(const vtkShader&) = delete;
133 };
134 
135 VTK_ABI_NAMESPACE_END
136 #endif
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:99
vtkShader::Type ShaderType
Definition: vtkShader.h:85
std::string OriginalValue
Definition: vtkShader.h:84
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:87
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:37
void Cleanup()
Delete the shader.
Type ShaderType
Definition: vtkShader.h:123
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:128
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:56
static vtkShader * New()
int Handle
Definition: vtkShader.h:124
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:62
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:65
bool Compile()
Compile the shader.
std::string Source
Definition: vtkShader.h:127
~vtkShader() override
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:68
Type
Available shader types.
Definition: vtkShader.h:45
@ Vertex
Vertex shader.
Definition: vtkShader.h:46
@ Geometry
Geometry shader.
Definition: vtkShader.h:48
@ Fragment
Fragment shader.
Definition: vtkShader.h:47
bool Dirty
Definition: vtkShader.h:125
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 *)