OpenWalnut
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
src
core
graphicsEngine
shaders
WGEShaderPreprocessor.h
1
//---------------------------------------------------------------------------
2
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
7
//
8
// This file is part of OpenWalnut.
9
//
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22
//
23
//---------------------------------------------------------------------------
24
25
#ifndef WGESHADERPREPROCESSOR_H
26
#define WGESHADERPREPROCESSOR_H
27
28
#include <string>
29
30
#include <boost/shared_ptr.hpp>
31
32
#include "../../common/WCondition.h"
33
34
35
36
/**
37
* Base class for each preprocessing possible to shader code. This is useful to derive your own preprocessor which might be able to implement
38
* some tricky "metaprogramming" for GLSL or similar. Another possibility are defines. In addition, it implements an update notification
39
* mechanism which forces associated WGEShader to reload. This is useful for preprocessors that can be modified dynamically.
40
*/
41
class
WGEShaderPreprocessor
// NOLINT
42
{
43
public
:
44
/**
45
* Shared pointer for this class.
46
*/
47
typedef
boost::shared_ptr< WGEShaderPreprocessor >
SPtr
;
48
49
/**
50
* A const shared pointer for this class.
51
*/
52
typedef
boost::shared_ptr< const WGEShaderPreprocessor >
ConstSPtr
;
53
54
/**
55
* Default constructor.
56
*/
57
WGEShaderPreprocessor
();
58
59
/**
60
* Destructor.
61
*/
62
virtual
~WGEShaderPreprocessor
();
63
64
/**
65
* Returns the condition denoting a change in this preprocessor filter. WGEShader subscribes this and rebuilds all related shaders if needed.
66
*
67
* \return the condition firing whenever the preprocessor updates.
68
*/
69
virtual
WCondition::SPtr
getChangeCondition
()
const
;
70
71
/**
72
* Process the whole code. It is not allowed to modify some internal state in this function because it might be called by several shaders.
73
*
74
* \param code the code to process
75
* \param file the filename of the shader currently processed. Should be used for debugging output.
76
*
77
* \return the resulting new code
78
*/
79
virtual
std::string
process
(
const
std::string& file,
const
std::string& code )
const
= 0;
80
81
/**
82
* (De-)activates the preprocessor. An inactive preprocessor does not modify the shader code.
83
*
84
* \param active true if preprocessor should be active
85
*/
86
void
setActive
(
bool
active =
true
);
87
88
/**
89
* If the preprocessor is active, this returns true.
90
*
91
* \return if active: true
92
*/
93
bool
getActive
()
const
;
94
95
protected
:
96
/**
97
* Fires m_updateCondition which should denote an update in the preprocessor filter.
98
*/
99
virtual
void
updated
();
100
101
private
:
102
/**
103
* The condition fires on every call of updated().
104
*/
105
WCondition::SPtr
m_updateCondition
;
106
107
/**
108
* If true the preprocessor is active.
109
*/
110
bool
m_active
;
111
};
112
113
#endif // WGESHADERPREPROCESSOR_H
114
Generated by
1.8.3.1