MeVisLab Resolution Independence API
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
36 public:
37
41 FILENAME
42 };
47
49 SoSFBool isActive;
50
52 SoSFEnum sourceType;
53
55 SoSFString sourceProgram;
56
59
60 SoEXTENDER public:
61
63 void GLRender(SoGLRenderAction *action) override;
64
65 SoINTERNAL public:
66
68 static void initClass();
69
72 return _glShaderObject;
73 }
74
76 virtual SoShader::ShaderType shaderType() const = 0;
77
80 return _sourceType;
81 }
82
84 const SbString &getSourceProgram() const {
85 return _sourceProgram;
86 }
87
90
91 SbBool containsMainFunction() const {
92 return _containsMainFunction;
93 }
94
95 SbBool isSnippet() const {
96 return _isSnippet;
97 }
98
99 SbString getSnippetFunctionName() const {
100 return _snippetFunctionName;
101 }
102
104 return _snippetInsertionLocation;
105 }
106
108 return _snippetUniformList;
109 }
110
112
113 protected:
114
115 void checkType();
116
118
120
123
126
128 ~SoShaderObject() override;
129
130 private:
131
132 void isActiveSensorCB(SoField* field);
133 void emulateLegacySensorCB(SoField* field);
134 void sourceSensorCB(SoField* field);
135
136 void parseSource(const SbString &srcCode);
137
138 // TRUE, if shader contains main function
139 SbBool _containsMainFunction;
140 // TRUE, if shader contains activated and valid snippet function
141 SbBool _isSnippet;
142 SbString _snippetFunctionName;
143 SnippetInsertionLocation _snippetInsertionLocation;
144 SbList<SbString> _snippetUniformList;
145};
146
147#endif // _SO_SHADER_OBJECT_
#define INVENTOR_SHADER_API
Define class export specifier.
This contains the definition of the SbList generic pointer list class; an SbList is a list of (void *...
Definition SbList.h:26
Vertex or fragment shader object class.
Abstract Open Inventor node for vertex or fragment shader nodes.
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.
@ GLSL_PROGRAM
OpenGL Shading Language program.
SbBool containsMainFunction() const