MeVisLab Toolbox Reference
SoGLShaderObject.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef SO_GLSHADER_OBJECT_H
14#define SO_GLSHADER_OBJECT_H
15
16
18
19#include "SoShaderSystem.h"
22#include <Inventor/SbLinear.h>
23#include <mlGLResources.h>
24
26
29{
30 typedef SoGLShader inherited;
31
32 public:
33
36
39
41 void reset() override;
42
44 SbBool isActive() const {
45 return _isActive;
46 }
47
49 return _shaderType;
50 }
51
52 void setSource(const SbString &source);
53 const SbString &getSource() const {
54 return _source;
55 }
56
58 void detach();
59
61 int version() const { return _version; }
62
63 SbBool isCreated() const {
64 return _shaderRes.isValid();
65 }
66
67 SoINTERNAL public:
68
69 void compile();
70
72 _shouldCompile = TRUE;
73 }
75 return _shouldCompile;
76 }
77
79 _shaderProgram = nullptr;
80 _shouldCompile = TRUE;
81 }
82
84 return _shaderProgram;
85 }
86
87 void setName(const SbString& name) { _name = name; }
88
89 const SbString& getName() const { return _name; }
90
91 void setAlwaysReadErrorLog(bool flag) { _alwaysReadErrorLog = flag; }
92 bool alwaysReadErrorLog() { return _alwaysReadErrorLog; }
93
94 bool hadCompileError() { return _hadError; }
95 const SbString& getErrorLog() { return _errorLog; }
96
98
99protected:
100 std::string adaptSourceString();
101
103
106
108
111
113
115
116 ml::GLSLShader _shaderRes;
117
121};
122
123#endif // _SO_GL_SHADER_OBJECT_
Vertex or fragment shader object class.
const SbString & getName() const
void setSource(const SbString &source)
SbBool isCreated() const
int version() const
Get the used GLSL version (only available after compile()!)
void setName(const SbString &name)
void reset() override
Free all resources (OpenGL too) and reset instance to initial state.
SoGLShaderProgram * getShaderProgram() const
void attach(SoGLShaderProgram *shaderProgram)
void setEmulateLegacyOpenGL(bool flag)
SoShader::ShaderType shaderType() const
SoShader::ShaderType _shaderType
const SbString & getSource() const
void activate(SbBool act)
SoGLShaderProgram * _shaderProgram
void setAlwaysReadErrorLog(bool flag)
SoGLShaderObject(SoShader::ShaderType shaderType)
Constructor.
std::string adaptSourceString()
ml::GLSLShader _shaderRes
const SbString & getErrorLog()
SbBool shouldCompile() const
~SoGLShaderObject() override
Destructor.
SbBool isActive() const
Class managing an OpenGL shader program.
Abstract base class for shader objects.
Definition SoGLShader.h:28
Target mlrange_cast(Source arg)
Generic version of checked ML casts.