MeVisLab Resolution Independence API
Toggle main menu visibility
Loading...
Searching...
No Matches
SoShaderBuilder.h
Go to the documentation of this file.
1
/*************************************************************************************
2
**
3
** Copyright 2011, 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_BUILDER_H
14
#define SO_SHADER_BUILDER_H
15
16
#include "
SoShaderSystem.h
"
17
18
#include <string>
19
#include <map>
20
#include <sstream>
21
#include <set>
22
23
typedef
std::vector<std::string>
StringVector
;
24
25
class
INVENTOR_SHADER_API
SoShaderRepository
26
{
27
public
:
28
struct
SourceInfo
29
{
30
31
bool
isValid
()
const
32
{
33
return
code
.size() > 0;
34
}
35
36
std::string
version
;
37
std::string
code
;
38
StringVector
includes
;
39
};
40
41
const
SourceInfo
&
lookup
(
const
std::string name)
const
;
42
43
void
insert
(
const
std::string name,
const
SourceInfo
& info);
44
45
void
addSource
(
const
char
* data);
46
47
private
:
48
typedef
std::map<std::string, SourceInfo> SourceInfoMap;
49
50
SourceInfoMap _repository;
51
SourceInfo
_emptyInfo;
52
};
53
54
class
SoGLCompleteShader
;
55
56
class
INVENTOR_SHADER_API
SoShaderBuilder
57
{
58
public
:
59
enum
ShaderType
{
60
FRAGMENT_SHADER
= 1,
61
VERTEX_SHADER
= 2,
62
GEOMETRY_SHADER
= 4
63
};
64
65
SoShaderBuilder
();
66
68
void
addSource
(
const
char
* data);
69
71
void
addRepository
(
SoShaderRepository
* repository);
72
74
std::string
createShader
(
const
std::string name,
75
const
std::vector<std::string>& directives = std::vector<std::string>(),
76
SoShaderRepository
* repository =
nullptr
);
77
80
SoGLCompleteShader
*
createCompleteShader
(
const
std::string name,
81
const
std::vector<std::string>& directives = std::vector<std::string>(),
82
SoShaderRepository
* repository =
nullptr
,
83
int
directivesFlag =
FRAGMENT_SHADER
|
GEOMETRY_SHADER
|
VERTEX_SHADER
);
84
85
private
:
86
struct
ShaderString
87
{
88
89
std::ostringstream directives;
90
std::ostringstream header;
91
std::ostringstream body;
92
93
void
addDirectived(
const
std::vector<std::string>& directives);
94
95
std::string toString();
96
97
std::set<std::string> usedIncludes;
98
};
99
100
const
SoShaderRepository::SourceInfo
& lookup(
const
std::string name)
const
;
101
102
void
addCode(
const
SoShaderRepository::SourceInfo
& code, ShaderString& result);
103
104
std::vector<SoShaderRepository*> _repositories;
105
SoShaderRepository
_defaultRepository;
106
107
SoShaderRepository::SourceInfo
_emptySource;
108
};
109
110
#endif
StringVector
std::vector< std::string > StringVector
Definition
SoShaderBuilder.h:23
SoShaderSystem.h
INVENTOR_SHADER_API
#define INVENTOR_SHADER_API
Define class export specifier.
Definition
SoShaderSystem.h:20
SoGLCompleteShader
Shader class which directly takes src for vertex, geometry and/or fragment shader,...
Definition
SoGLCompleteShader.h:30
SoShaderBuilder::createCompleteShader
SoGLCompleteShader * createCompleteShader(const std::string name, const std::vector< std::string > &directives=std::vector< std::string >(), SoShaderRepository *repository=nullptr, int directivesFlag=FRAGMENT_SHADER|GEOMETRY_SHADER|VERTEX_SHADER)
SoShaderBuilder::createShader
std::string createShader(const std::string name, const std::vector< std::string > &directives=std::vector< std::string >(), SoShaderRepository *repository=nullptr)
Creates the shader source for the given shader.
SoShaderBuilder::addRepository
void addRepository(SoShaderRepository *repository)
Adds the given repository, ownership stays with the caller.
SoShaderBuilder::ShaderType
ShaderType
Definition
SoShaderBuilder.h:59
SoShaderBuilder::GEOMETRY_SHADER
@ GEOMETRY_SHADER
Definition
SoShaderBuilder.h:62
SoShaderBuilder::VERTEX_SHADER
@ VERTEX_SHADER
Definition
SoShaderBuilder.h:61
SoShaderBuilder::FRAGMENT_SHADER
@ FRAGMENT_SHADER
Definition
SoShaderBuilder.h:60
SoShaderBuilder::SoShaderBuilder
SoShaderBuilder()
SoShaderBuilder::addSource
void addSource(const char *data)
adds the given source to the default repository
SoShaderRepository
Definition
SoShaderBuilder.h:26
SoShaderRepository::addSource
void addSource(const char *data)
SoShaderRepository::lookup
const SourceInfo & lookup(const std::string name) const
SoShaderRepository::insert
void insert(const std::string name, const SourceInfo &info)
SoShaderRepository::SourceInfo
Definition
SoShaderBuilder.h:29
SoShaderRepository::SourceInfo::isValid
bool isValid() const
Definition
SoShaderBuilder.h:31
SoShaderRepository::SourceInfo::version
std::string version
Definition
SoShaderBuilder.h:36
SoShaderRepository::SourceInfo::includes
StringVector includes
Definition
SoShaderBuilder.h:38
SoShaderRepository::SourceInfo::code
std::string code
Definition
SoShaderBuilder.h:37
MeVisLab
Standard
Sources
Inventor
SoShader
Inventor
misc
SoShaderBuilder.h
Generated by
1.18.0