MeVisLab Resolution Independence API
Toggle main menu visibility
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
"
20
#include "
Inventor/misc/SoShaderTypes.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
27
class
SoGLShaderObject
;
28
30
SoEXTENDER
class
INVENTOR_SHADER_API
SoShaderObject
:
public
SoNode
31
{
32
typedef
SoNode inherited;
33
34
SO_NODE_ABSTRACT_HEADER(
SoShaderObject
);
35
36
public
:
38
enum
SourceType
{
39
GLSL_PROGRAM
,
40
FILENAME
41
};
42
enum
SnippetInsertionLocation
{
43
AT_BEGIN
,
44
AT_END
45
};
46
48
SoSFBool
isActive
;
49
51
SoSFEnum
sourceType
;
52
54
SoSFString
sourceProgram
;
55
57
SoSFBool
emulateLegacyOpenGL
;
58
59
SoEXTENDER public :
60
62
void
GLRender
(SoGLRenderAction* action)
override
;
63
64
SoINTERNAL public :
65
67
static
void
initClass
();
68
70
SoGLShaderObject
*
getGLShaderObject
()
71
{
72
return
_glShaderObject
;
73
}
74
76
virtual
SoShader::ShaderType
shaderType
()
const
= 0;
77
79
SourceType
getSourceType
()
const
80
{
81
return
_sourceType
;
82
}
83
85
const
SbString&
getSourceProgram
()
const
86
{
87
return
_sourceProgram
;
88
}
89
91
void
scheduleRebuild
();
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
108
SnippetInsertionLocation
getSnippetInsertionLocation
()
const
109
{
110
return
_snippetInsertionLocation;
111
}
112
113
const
SbList<SbString>
&
getSnippetUniformList
()
const
114
{
115
return
_snippetUniformList;
116
}
117
118
SbBool
hasSourceModifications
()
const
;
119
120
protected
:
121
void
checkType
();
122
123
void
readSource
();
124
125
SoGLShaderObject
*
_glShaderObject
;
126
127
SourceType
_sourceType
;
128
SbString
_sourceProgram
;
129
131
SoShaderObject
();
132
134
~SoShaderObject
()
override
;
135
136
private
:
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_
SbList.h
SoShaderSystem.h
INVENTOR_SHADER_API
#define INVENTOR_SHADER_API
Define class export specifier.
Definition
SoShaderSystem.h:20
SoShaderTypes.h
SbList
Definition
SbList.h:25
SoGLShaderObject
Vertex or fragment shader object class.
Definition
SoGLShaderObject.h:29
SoShaderObject::isSnippet
SbBool isSnippet() const
Definition
SoShaderObject.h:98
SoShaderObject::isActive
SoSFBool isActive
Enable / disable shader object.
Definition
SoShaderObject.h:48
SoShaderObject::_glShaderObject
SoGLShaderObject * _glShaderObject
Definition
SoShaderObject.h:125
SoShaderObject::scheduleRebuild
void scheduleRebuild()
Schedule rebuild of underlying OpenGL shader (e.g. due to GL context switch).
SoShaderObject::emulateLegacyOpenGL
SoSFBool emulateLegacyOpenGL
If enabled, legacy OpenGL state is emulated for shaders >= version 140.
Definition
SoShaderObject.h:57
SoShaderObject::_sourceType
SourceType _sourceType
Definition
SoShaderObject.h:127
SoShaderObject::checkType
void checkType()
SoShaderObject::readSource
void readSource()
SoShaderObject::shaderType
virtual SoShader::ShaderType shaderType() const =0
Returns type of shader.
SoShaderObject::hasSourceModifications
SbBool hasSourceModifications() const
SoShaderObject::getGLShaderObject
SoGLShaderObject * getGLShaderObject()
Returns shader object.
Definition
SoShaderObject.h:70
SoShaderObject::sourceProgram
SoSFString sourceProgram
Contains the shader object's source or the filename of the source file.
Definition
SoShaderObject.h:54
SoShaderObject::GLRender
void GLRender(SoGLRenderAction *action) override
Add this node to element in state.
SoShaderObject::SoShaderObject
SoShaderObject()
Constructor.
SoShaderObject::~SoShaderObject
~SoShaderObject() override
Destructor.
SoShaderObject::getSourceType
SourceType getSourceType() const
Returns shader object's source type.
Definition
SoShaderObject.h:79
SoShaderObject::getSnippetUniformList
const SbList< SbString > & getSnippetUniformList() const
Definition
SoShaderObject.h:113
SoShaderObject::getSourceProgram
const SbString & getSourceProgram() const
Returns shader object's source program.
Definition
SoShaderObject.h:85
SoShaderObject::_sourceProgram
SbString _sourceProgram
Definition
SoShaderObject.h:128
SoShaderObject::getSnippetInsertionLocation
SnippetInsertionLocation getSnippetInsertionLocation() const
Definition
SoShaderObject.h:108
SoShaderObject::sourceType
SoSFEnum sourceType
Specify shader object's source type.
Definition
SoShaderObject.h:51
SoShaderObject::initClass
static void initClass()
Initialize class with runtime type system.
SoShaderObject::getSnippetFunctionName
SbString getSnippetFunctionName() const
Definition
SoShaderObject.h:103
SoShaderObject::SourceType
SourceType
Shader object's source type.
Definition
SoShaderObject.h:38
SoShaderObject::FILENAME
@ FILENAME
Filename of source file.
Definition
SoShaderObject.h:40
SoShaderObject::GLSL_PROGRAM
@ GLSL_PROGRAM
OpenGL Shading Language program.
Definition
SoShaderObject.h:39
SoShaderObject::containsMainFunction
SbBool containsMainFunction() const
Definition
SoShaderObject.h:93
SoShaderObject::SnippetInsertionLocation
SnippetInsertionLocation
Definition
SoShaderObject.h:42
SoShaderObject::AT_END
@ AT_END
Definition
SoShaderObject.h:44
SoShaderObject::AT_BEGIN
@ AT_BEGIN
Definition
SoShaderObject.h:43
SoShader::ShaderType
ShaderType
Definition
SoShaderTypes.h:24
MeVisLab
Standard
Sources
Inventor
SoShader
Inventor
nodes
SoShaderObject.h
Generated by
1.18.0