VTK  9.1.0
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=========================================================================*/
30#ifndef vtkShader_h
31#define vtkShader_h
32
33#include "vtkObject.h"
34#include "vtkRenderingOpenGL2Module.h" // for export macro
35
36#include <string> // For member variables.
37#include <vector> // For member variables.
38
46class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
47{
48public:
49 static vtkShader* New();
50 vtkTypeMacro(vtkShader, vtkObject);
51 void PrintSelf(ostream& os, vtkIndent indent) override;
52
54 enum Type
55 {
59 Unknown
60 };
61
64
66 Type GetType() const { return this->ShaderType; }
67
70
72 std::string GetSource() const { return this->Source; }
73
75 std::string GetError() const { return this->Error; }
76
78 int GetHandle() const { return this->Handle; }
79
83 bool Compile();
84
89 void Cleanup();
90
92 {
93 public:
97 bool operator<(const ReplacementSpec& v1) const
98 {
99 if (this->OriginalValue != v1.OriginalValue)
100 {
101 return this->OriginalValue < v1.OriginalValue;
102 }
103 if (this->ShaderType != v1.ShaderType)
104 {
105 return this->ShaderType < v1.ShaderType;
106 }
107 return (this->ReplaceFirst < v1.ReplaceFirst);
108 }
109 bool operator>(const ReplacementSpec& v1) const
110 {
111 if (this->OriginalValue != v1.OriginalValue)
112 {
113 return this->OriginalValue > v1.OriginalValue;
114 }
115 if (this->ShaderType != v1.ShaderType)
116 {
117 return this->ShaderType > v1.ShaderType;
118 }
119 return (this->ReplaceFirst > v1.ReplaceFirst);
120 }
121 };
123 {
124 public:
127 };
128
129protected:
131 ~vtkShader() override;
132
135 bool Dirty;
136
139
140private:
141 vtkShader(const vtkShader&) = delete;
142 void operator=(const vtkShader&) = delete;
143};
144
145#endif
a simple class to control print indentation
Definition: vtkIndent.h:43
abstract base class for most VTK objects
Definition: vtkObject.h:63
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:109
vtkShader::Type ShaderType
Definition: vtkShader.h:95
std::string OriginalValue
Definition: vtkShader.h:94
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:97
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:47
void Cleanup()
Delete the shader.
Type ShaderType
Definition: vtkShader.h:133
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:138
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:66
int Handle
Definition: vtkShader.h:134
static vtkShader * New()
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:72
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:75
bool Compile()
Compile the shader.
std::string Source
Definition: vtkShader.h:137
~vtkShader() override
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:78
Type
Available shader types.
Definition: vtkShader.h:55
@ Vertex
Vertex shader.
Definition: vtkShader.h:56
@ Geometry
Geometry shader.
Definition: vtkShader.h:58
@ Fragment
Fragment shader.
Definition: vtkShader.h:57
bool Dirty
Definition: vtkShader.h:135
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:522
@ string
Definition: vtkX3D.h:496
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)