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=========================================================================*/
21#ifndef vtkShader_h
22#define vtkShader_h
23
24#include "vtkObject.h"
25#include "vtkRenderingOpenGL2Module.h" // for export macro
26
27#include <string> // For member variables.
28#include <vector> // For member variables.
29
37class VTKRENDERINGOPENGL2_EXPORT vtkShader : public vtkObject
38{
39public:
40 static vtkShader* New();
41 vtkTypeMacro(vtkShader, vtkObject);
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43
45 enum Type
46 {
50 Unknown
51 };
52
55
57 Type GetType() const { return this->ShaderType; }
58
61
63 std::string GetSource() const { return this->Source; }
64
66 std::string GetError() const { return this->Error; }
67
69 int GetHandle() const { return this->Handle; }
70
74 bool Compile();
75
80 void Cleanup();
81
83 {
84 public:
88 bool operator<(const ReplacementSpec& v1) const
89 {
90 if (this->OriginalValue != v1.OriginalValue)
91 {
92 return this->OriginalValue < v1.OriginalValue;
93 }
94 if (this->ShaderType != v1.ShaderType)
95 {
96 return this->ShaderType < v1.ShaderType;
97 }
98 return (this->ReplaceFirst < v1.ReplaceFirst);
99 }
100 bool operator>(const ReplacementSpec& v1) const
101 {
102 if (this->OriginalValue != v1.OriginalValue)
103 {
104 return this->OriginalValue > v1.OriginalValue;
105 }
106 if (this->ShaderType != v1.ShaderType)
107 {
108 return this->ShaderType > v1.ShaderType;
109 }
110 return (this->ReplaceFirst > v1.ReplaceFirst);
111 }
112 };
114 {
115 public:
118 };
119
120protected:
122 ~vtkShader() override;
123
126 bool Dirty;
127
130
131private:
132 vtkShader(const vtkShader&) = delete;
133 void operator=(const vtkShader&) = delete;
134};
135
136#endif
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
bool operator>(const ReplacementSpec &v1) const
Definition: vtkShader.h:100
vtkShader::Type ShaderType
Definition: vtkShader.h:86
std::string OriginalValue
Definition: vtkShader.h:85
bool operator<(const ReplacementSpec &v1) const
Definition: vtkShader.h:88
Vertex or Fragment shader, combined into a ShaderProgram.
Definition: vtkShader.h:38
void Cleanup()
Delete the shader.
Type ShaderType
Definition: vtkShader.h:124
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:129
Type GetType() const
Get the shader type, typically Vertex or Fragment.
Definition: vtkShader.h:57
int Handle
Definition: vtkShader.h:125
static vtkShader * New()
std::string GetSource() const
Get the source for the shader.
Definition: vtkShader.h:63
std::string GetError() const
Get the error message (empty if none) for the shader.
Definition: vtkShader.h:66
bool Compile()
Compile the shader.
std::string Source
Definition: vtkShader.h:128
~vtkShader() override
int GetHandle() const
Get the handle of the shader.
Definition: vtkShader.h:69
Type
Available shader types.
Definition: vtkShader.h:46
@ Vertex
Vertex shader.
Definition: vtkShader.h:47
@ Geometry
Geometry shader.
Definition: vtkShader.h:49
@ Fragment
Fragment shader.
Definition: vtkShader.h:48
bool Dirty
Definition: vtkShader.h:126
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 *)