VTK: Rendering/OpenGL2/vtkShader.h Source File

| VTK 9.3.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
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 {
46 Vertex,
47 Fragment,
48 Geometry,
49 Unknown
50 };
51
53 void SetType(Type type);
54
56 Type GetType() const { return this->ShaderType; }
57
59 void SetSource(const std::string& source);
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
81 class ReplacementSpec
82 {
83 public:
84 std::string OriginalValue;
85 vtkShader::Type ShaderType;
86 bool ReplaceFirst;
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 };
112 class ReplacementValue
113 {
114 public:
115 std::string Replacement;
116 bool ReplaceAll;
117 };
118
119 protected:
120 vtkShader();
121 ~vtkShader() override;
122
123 Type ShaderType;
124 int Handle;
125 bool Dirty;
126
127 std::string Source;
128 std::string Error;
129
130 private:
131 vtkShader(const vtkShader&) = delete;
132 void operator=(const vtkShader&) = delete;
133 };
134
135 VTK_ABI_NAMESPACE_END
136 #endif
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkShader::ReplacementSpec
Definition: vtkShader.h:82
vtkShader::ReplacementSpec::operator>
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:99
vtkShader::ReplacementSpec::ShaderType
vtkShader::Type ShaderType
Definition: vtkShader.h:85
vtkShader::ReplacementSpec::OriginalValue
std::string OriginalValue
Definition: vtkShader.h:84
vtkShader::ReplacementSpec::operator<
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:87
vtkShader::ReplacementSpec::ReplaceFirst
bool ReplaceFirst
Definition: vtkShader.h:86
vtkShader::ReplacementValue
Definition: vtkShader.h:113
vtkShader::ReplacementValue::ReplaceAll
bool ReplaceAll
Definition: vtkShader.h:116
vtkShader::ReplacementValue::Replacement
std::string Replacement
Definition: vtkShader.h:115
vtkShader
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:37
vtkShader::Cleanup
void Cleanup()
Delete the shader.
vtkShader::ShaderType
Type ShaderType
Definition: vtkShader.h:123
vtkShader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkShader::Error
std::string Error
Definition: vtkShader.h:128
vtkShader::GetType
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:56
vtkShader::New
static vtkShader * New()
vtkShader::Handle
int Handle
Definition: vtkShader.h:124
vtkShader::GetSource
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:62
vtkShader::GetError
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:65
vtkShader::Compile
bool Compile()
Compile the shader.
vtkShader::Source
std::string Source
Definition: vtkShader.h:127
vtkShader::~vtkShader
~vtkShader() override
vtkShader::GetHandle
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:68
vtkShader::Type
Type
Available shader types.
Definition: vtkShader.h:45
vtkShader::Vertex
@ Vertex
Vertex shader.
Definition: vtkShader.h:46
vtkShader::Geometry
@ Geometry
Geometry shader.
Definition: vtkShader.h:48
vtkShader::Fragment
@ Fragment
Fragment shader.
Definition: vtkShader.h:47
vtkShader::Dirty
bool Dirty
Definition: vtkShader.h:125
vtkShader::SetSource
void SetSource(const std::string &source)
Set the shader source to the supplied string.
vtkShader::vtkShader
vtkShader()
vtkShader::SetType
void SetType(Type type)
Set the shader type.
vtkX3D::type
@ type
Definition: vtkX3D.h:516
vtkX3D::string
@ string
Definition: vtkX3D.h:490
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:964
vtkEventDataDevice::Unknown
@ Unknown
vtkObject.h
vtkParseResult::Error
@ Error