VTK  9.5.2
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
12
13#ifndef vtkShader_h
14#define vtkShader_h
15
16#include "vtkObject.h"
17#include "vtkRenderingOpenGL2Module.h" // for export macro
18
19#include <string> // For member variables.
20#include <vector> // For member variables.
21
28
29VTK_ABI_NAMESPACE_BEGIN
30class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
31{
32public:
33 static vtkShader* New();
34 vtkTypeMacro(vtkShader, vtkObject);
35 void PrintSelf(ostream& os, vtkIndent indent) override;
36
48
50 void SetType(Type type);
51
53 Type GetType() const { return this->ShaderType; }
54
56 void SetSource(const std::string& source);
57
59 std::string GetSource() const { return this->Source; }
60
62 std::string GetError() const { return this->Error; }
63
65 int GetHandle() const { return this->Handle; }
66
70 bool Compile();
71
76 void Cleanup();
77
80
83
85 {
86 public:
87 std::string OriginalValue;
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 bool operator>(const ReplacementSpec& v1) const
103 {
104 if (this->OriginalValue != v1.OriginalValue)
105 {
106 return this->OriginalValue > v1.OriginalValue;
107 }
108 if (this->ShaderType != v1.ShaderType)
109 {
110 return this->ShaderType > v1.ShaderType;
111 }
112 return (this->ReplaceFirst > v1.ReplaceFirst);
113 }
114 };
116 {
117 public:
118 std::string Replacement;
120 };
121
122protected:
124 ~vtkShader() override;
125
128 bool Dirty;
129
130 std::string Source;
131 std::string Error;
132
133private:
134 vtkShader(const vtkShader&) = delete;
135 void operator=(const vtkShader&) = delete;
136};
137
138VTK_ABI_NAMESPACE_END
139#endif
a simple class to control print indentation
Definition vtkIndent.h:29
bool operator>(const ReplacementSpec &v1) const
Definition vtkShader.h:102
vtkShader::Type ShaderType
Definition vtkShader.h:88
bool operator<(const ReplacementSpec &v1) const
Definition vtkShader.h:90
void Cleanup()
Delete the shader.
Type ShaderType
Definition vtkShader.h:126
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:131
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition vtkShader.h:53
static vtkShader * New()
static bool IsComputeShaderSupported()
Check if compute shaders are supported.
std::string GetSource() const
Get the source for the shader.
Definition vtkShader.h:59
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition vtkShader.h:62
bool Compile()
Compile the shader.
std::string Source
Definition vtkShader.h:130
~vtkShader() override
int GetHandle() const
Get the handle of the shader.
Definition vtkShader.h:65
Type
Available shader types.
Definition vtkShader.h:39
@ Vertex
Vertex shader.
Definition vtkShader.h:40
@ Unknown
Unknown (default).
Definition vtkShader.h:46
@ TessControl
Tessellation Control.
Definition vtkShader.h:44
@ Geometry
Geometry shader.
Definition vtkShader.h:42
@ Fragment
Fragment shader.
Definition vtkShader.h:41
@ Compute
Compute shader.
Definition vtkShader.h:43
@ TessEvaluation
Tessellation Evaluation.
Definition vtkShader.h:45
bool Dirty
Definition vtkShader.h:128
static bool IsTessellationShaderSupported()
Check if tessellation shaders are supported.
void SetSource(const std::string &source)
Set the shader source to the supplied string.
void SetType(Type type)
Set the shader type.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)