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
10 #ifndef vtkShader_h
11 #define vtkShader_h
12 
13 #include "vtkObject.h"
14 #include "vtkRenderingOpenGL2Module.h" // for export macro
15 
16 #include <string> // For member variables.
17 #include <vector> // For member variables.
18 
26 VTK_ABI_NAMESPACE_BEGIN
27 class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
28 {
29 public:
30  static vtkShader* New();
31  vtkTypeMacro(vtkShader, vtkObject);
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
35  enum Type
36  {
40  Unknown
41  };
42 
44  void SetType(Type type);
45 
47  Type GetType() const { return this->ShaderType; }
48 
51 
53  std::string GetSource() const { return this->Source; }
54 
56  std::string GetError() const { return this->Error; }
57 
59  int GetHandle() const { return this->Handle; }
60 
64  bool Compile();
65 
70  void Cleanup();
71 
73  {
74  public:
78  bool operator<(const ReplacementSpec& v1) const
79  {
80  if (this->OriginalValue != v1.OriginalValue)
81  {
82  return this->OriginalValue < v1.OriginalValue;
83  }
84  if (this->ShaderType != v1.ShaderType)
85  {
86  return this->ShaderType < v1.ShaderType;
87  }
88  return (this->ReplaceFirst < v1.ReplaceFirst);
89  }
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  };
104  {
105  public:
108  };
109 
110 protected:
112  ~vtkShader() override;
113 
115  int Handle;
116  bool Dirty;
117 
120 
121 private:
122  vtkShader(const vtkShader&) = delete;
123  void operator=(const vtkShader&) = delete;
124 };
125 
126 VTK_ABI_NAMESPACE_END
127 #endif
a simple class to control print indentation
Definition: vtkIndent.h:29
abstract base class for most VTK objects
Definition: vtkObject.h:52
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:90
vtkShader::Type ShaderType
Definition: vtkShader.h:76
std::string OriginalValue
Definition: vtkShader.h:75
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:78
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:28
void Cleanup()
Delete the shader.
Type ShaderType
Definition: vtkShader.h:114
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:119
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:47
static vtkShader * New()
int Handle
Definition: vtkShader.h:115
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:53
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:56
bool Compile()
Compile the shader.
std::string Source
Definition: vtkShader.h:118
~vtkShader() override
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:59
Type
Available shader types.
Definition: vtkShader.h:36
@ Vertex
Vertex shader.
Definition: vtkShader.h:37
@ Geometry
Geometry shader.
Definition: vtkShader.h:39
@ Fragment
Fragment shader.
Definition: vtkShader.h:38
bool Dirty
Definition: vtkShader.h:116
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 *)