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 
25 class SoGLShaderProgram;
26 
28 class INVENTOR_SHADER_API SoGLShaderObject : public SoGLShader
29 {
30  typedef SoGLShader inherited;
31 
32  public:
33 
36 
38  ~SoGLShaderObject() override;
39 
41  void reset() override;
42 
43  void activate(SbBool act);
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 
57  void attach(SoGLShaderProgram *shaderProgram);
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 
71  void scheduleCompile() {
72  _shouldCompile = TRUE;
73  }
74  SbBool shouldCompile() const {
75  return _shouldCompile;
76  }
77 
78  void scheduleRebuild() {
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 
97  void setEmulateLegacyOpenGL(bool flag);
98 
99 protected:
100  std::string adaptSourceString();
101 
103 
105  SbBool _isActive;
106 
107  int _version;
108 
109  SbString _source;
111 
112  SbString _name;
113 
115 
116  ml::GLSLShader _shaderRes;
117 
119  bool _hadError;
120  SbString _errorLog;
121 };
122 
123 #endif // _SO_GL_SHADER_OBJECT_
Vertex or fragment shader object class.
const SbString & getSource() 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.
const SbString & getName() const
SoGLShaderProgram * getShaderProgram() const
void attach(SoGLShaderProgram *shaderProgram)
void setEmulateLegacyOpenGL(bool flag)
SoShader::ShaderType shaderType() const
SoShader::ShaderType _shaderType
void activate(SbBool act)
SoGLShaderProgram * _shaderProgram
void setAlwaysReadErrorLog(bool flag)
SoGLShaderObject(SoShader::ShaderType shaderType)
Constructor.
std::string adaptSourceString()
const SbString & getErrorLog()
ml::GLSLShader _shaderRes
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
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.