MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
SoShaderObject.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_SHADER_OBJECT_H
14#define SO_SHADER_OBJECT_H
15
16
18
19#include "SoShaderSystem.h"
21#include <Inventor/nodes/SoSubNode.h>
22#include <Inventor/fields/SoSFBool.h>
23#include <Inventor/fields/SoSFEnum.h>
24#include <Inventor/fields/SoSFString.h>
25#include <Inventor/SbList.h>
26
28
30SoEXTENDER class INVENTOR_SHADER_API SoShaderObject : public SoNode
31{
32 typedef SoNode inherited;
33
34 SO_NODE_ABSTRACT_HEADER(SoShaderObject);
35
36public:
46
48 SoSFBool isActive;
49
51 SoSFEnum sourceType;
52
54 SoSFString sourceProgram;
55
58
59SoEXTENDER public :
60
62 void GLRender(SoGLRenderAction* action) override;
63
64SoINTERNAL public :
65
67 static void initClass();
68
74
76 virtual SoShader::ShaderType shaderType() const = 0;
77
80 {
81 return _sourceType;
82 }
83
85 const SbString& getSourceProgram() const
86 {
87 return _sourceProgram;
88 }
89
92
93 SbBool containsMainFunction() const
94 {
95 return _containsMainFunction;
96 }
97
98 SbBool isSnippet() const
99 {
100 return _isSnippet;
101 }
102
103 SbString getSnippetFunctionName() const
104 {
105 return _snippetFunctionName;
106 }
107
109 {
110 return _snippetInsertionLocation;
111 }
112
114 {
115 return _snippetUniformList;
116 }
117
119
120protected:
121 void checkType();
122
124
126
129
132
134 ~SoShaderObject() override;
135
136private:
137 void isActiveSensorCB(SoField* field);
138 void emulateLegacySensorCB(SoField* field);
139 void sourceSensorCB(SoField* field);
140
141 void parseSource(const SbString& srcCode);
142
143 // TRUE, if shader contains main function
144 SbBool _containsMainFunction;
145 // TRUE, if shader contains activated and valid snippet function
146 SbBool _isSnippet;
147 SbString _snippetFunctionName;
148 SnippetInsertionLocation _snippetInsertionLocation;
149 SbList<SbString> _snippetUniformList;
150};
151
152#endif // _SO_SHADER_OBJECT_
#define INVENTOR_SHADER_API
Define class export specifier.
Vertex or fragment shader object class.
SbBool isSnippet() const
SoSFBool isActive
Enable / disable shader object.
SoGLShaderObject * _glShaderObject
void scheduleRebuild()
Schedule rebuild of underlying OpenGL shader (e.g. due to GL context switch).
SoSFBool emulateLegacyOpenGL
If enabled, legacy OpenGL state is emulated for shaders >= version 140.
SourceType _sourceType
virtual SoShader::ShaderType shaderType() const =0
Returns type of shader.
SbBool hasSourceModifications() const
SoGLShaderObject * getGLShaderObject()
Returns shader object.
SoSFString sourceProgram
Contains the shader object's source or the filename of the source file.
void GLRender(SoGLRenderAction *action) override
Add this node to element in state.
SoShaderObject()
Constructor.
~SoShaderObject() override
Destructor.
SourceType getSourceType() const
Returns shader object's source type.
const SbList< SbString > & getSnippetUniformList() const
const SbString & getSourceProgram() const
Returns shader object's source program.
SbString _sourceProgram
SnippetInsertionLocation getSnippetInsertionLocation() const
SoSFEnum sourceType
Specify shader object's source type.
static void initClass()
Initialize class with runtime type system.
SbString getSnippetFunctionName() const
SourceType
Shader object's source type.
@ FILENAME
Filename of source file.
@ GLSL_PROGRAM
OpenGL Shading Language program.
SbBool containsMainFunction() const