VTK
vtkShader.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 =========================================================================*/
24 #ifndef vtkShader_h
25 #define vtkShader_h
26 
27 #include "vtkObject.h"
28 #include "vtkRenderingOpenGL2Module.h" // for export macro
29 
30 #include <string> // For member variables.
31 #include <vector> // For member variables.
32 
40 class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
41 {
42 public:
43  static vtkShader* New();
44  vtkTypeMacro(vtkShader, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
48  enum Type
49  {
54  };
55 
57  void SetType(Type type);
58 
60  Type GetType() const { return this->ShaderType; }
61 
63  void SetSource(const std::string& source);
64 
66  std::string GetSource() const { return this->Source; }
67 
69  std::string GetError() const { return this->Error; }
70 
72  int GetHandle() const { return this->Handle; }
73 
77  bool Compile();
78 
83  void Cleanup();
84 
86  {
87  public:
91  bool operator<(const ReplacementSpec& v1) const
92  {
93  if (this->OriginalValue != v1.OriginalValue)
94  {
95  return this->OriginalValue < v1.OriginalValue;
96  }
97  if (this->ShaderType != v1.ShaderType)
98  {
99  return this->ShaderType < v1.ShaderType;
100  }
101  return (this->ReplaceFirst < v1.ReplaceFirst);
102  }
103  bool operator>(const ReplacementSpec& v1) const
104  {
105  if (this->OriginalValue != v1.OriginalValue)
106  {
107  return this->OriginalValue > v1.OriginalValue;
108  }
109  if (this->ShaderType != v1.ShaderType)
110  {
111  return this->ShaderType > v1.ShaderType;
112  }
113  return (this->ReplaceFirst > v1.ReplaceFirst);
114  }
115  };
117  {
118  public:
121  };
122 
123 protected:
124  vtkShader();
125  ~vtkShader() override;
126 
128  int Handle;
129  bool Dirty;
130 
133 
134 private:
135  vtkShader(const vtkShader&) = delete;
136  void operator=(const vtkShader&) = delete;
137 };
138 
139 #endif
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:60
std::string OriginalValue
Definition: vtkShader.h:88
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Geometry shader.
Definition: vtkShader.h:52
Type
Available shader types.
Definition: vtkShader.h:48
std::string Error
Definition: vtkShader.h:132
Fragment shader.
Definition: vtkShader.h:51
bool Dirty
Definition: vtkShader.h:129
a simple class to control print indentation
Definition: vtkIndent.h:39
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:72
std::string Source
Definition: vtkShader.h:131
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:69
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:91
int Handle
Definition: vtkShader.h:128
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:103
Type ShaderType
Definition: vtkShader.h:127
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:40
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:66
vtkShader::Type ShaderType
Definition: vtkShader.h:89
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Vertex shader.
Definition: vtkShader.h:50