/
OpenGLShader.h
116 lines (81 loc) · 2.85 KB
/
OpenGLShader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma once
#include "OpenGLShaderPass.h"
#include "irender.h"
#include "ishaders.h"
#include "string/string.h"
#include <list>
namespace render
{
class OpenGLRenderSystem;
/**
* Implementation of the Shader class.
*/
class OpenGLShader :
public Shader
{
// The state manager we will be inserting/removing OpenGL states from
OpenGLRenderSystem& _renderSystem;
// List of shader passes for this shader
typedef std::list<OpenGLShaderPassPtr> Passes;
Passes _shaderPasses;
// The Material corresponding to this OpenGLShader
MaterialPtr _material;
// Visibility flag
bool _isVisible;
std::size_t _useCount;
sigc::signal<void> _sigRealised;
sigc::signal<void> _sigUnrealised;
private:
// Start point for constructing shader passes from the shader name
void construct(const std::string& name);
// Construct shader passes from a regular shader (as opposed to a special
// built-in shader)
void constructNormalShader(const std::string& name);
// Shader pass construction helpers
void appendBlendLayer(const ShaderLayerPtr& layer);
struct DBSTriplet;
void appendInteractionLayer(const DBSTriplet& triplet);
void constructLightingPassesFromMaterial();
void determineBlendModeForEditorPass(OpenGLState& pass);
void constructEditorPreviewPassFromMaterial();
void applyAlphaTestToPass(OpenGLState& pass, float alphaTest);
void setGLTexturesFromTriplet(OpenGLState&, const DBSTriplet&);
// Destroy internal data
void destroy();
// Add a shader pass to the end of the list, and return its state object
OpenGLState& appendDefaultPass();
// Test if we can render using lighting mode
bool canUseLightingMode() const;
void insertPasses();
void removePasses();
public:
/// Construct and initialise
OpenGLShader(OpenGLRenderSystem& renderSystem);
// Returns the owning render system
OpenGLRenderSystem& getRenderSystem();
// Shader implementation
void addRenderable(const OpenGLRenderable& renderable,
const Matrix4& modelview,
const LightList* lights) override;
void addRenderable(const OpenGLRenderable& renderable,
const Matrix4& modelview,
const IRenderEntity& entity,
const LightList* lights) override;
void setVisible(bool visible) override;
bool isVisible() const override;
void incrementUsed() override;
void decrementUsed() override;
sigc::signal<void>& signal_Realised() override;
sigc::signal<void>& signal_Unrealised() override;
bool isRealised() override;
/**
* Realise this shader, setting the name in the process.
*/
void realise(const std::string& name);
void unrealise();
// Return the Material used by this shader
const MaterialPtr& getMaterial() const override;
unsigned int getFlags() const override;
};
typedef std::shared_ptr<OpenGLShader> OpenGLShaderPtr;
} // namespace