-
Notifications
You must be signed in to change notification settings - Fork 47
/
OpenGLRenderSystem.h
109 lines (81 loc) · 2.93 KB
/
OpenGLRenderSystem.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
#pragma once
#include "irender.h"
#include <sigc++/connection.h>
#include <map>
#include "imodule.h"
#include "backend/OpenGLStateManager.h"
#include "backend/OpenGLShader.h"
#include "backend/OpenGLStateLess.h"
namespace render
{
class GLProgramFactory;
typedef std::shared_ptr<GLProgramFactory> GLProgramFactoryPtr;
/**
* \brief
* Implementation of RenderSystem.
*/
class OpenGLRenderSystem
: public RenderSystem,
public OpenGLStateManager
{
// Map of named Shader objects
typedef std::map<std::string, OpenGLShaderPtr> ShaderMap;
ShaderMap _shaders;
// whether this module has been realised
bool _realised;
bool _shaderProgramsAvailable;
// The GL program manager to acquire vfps
GLProgramFactoryPtr _glProgramFactory;
// Current shader program in use
ShaderProgram _currentShaderProgram;
// Map of OpenGLState references, with access functions.
OpenGLStates _state_sorted;
// Render time
std::size_t _time;
sigc::signal<void> _sigExtensionsInitialised;
sigc::connection _materialDefsLoaded;
sigc::connection _materialDefsUnloaded;
sigc::connection _sharedContextCreated;
sigc::connection _sharedContextDestroyed;
public:
/**
* Main constructor.
*/
OpenGLRenderSystem();
virtual ~OpenGLRenderSystem();
/* RenderSystem implementation */
ShaderPtr capture(const std::string& name) override;
void render(RenderViewType renderViewType, RenderStateFlags globalstate,
const Matrix4& modelview,
const Matrix4& projection,
const Vector3& viewer,
const VolumeTest& view) override;
void realise() override;
void unrealise() override;
GLProgramFactory& getGLProgramFactory();
std::size_t getTime() const override;
void setTime(std::size_t milliSeconds) override;
ShaderProgram getCurrentShaderProgram() const override;
void setShaderProgram(ShaderProgram prog) override;
void extensionsInitialised() override;
sigc::signal<void> signal_extensionsInitialised() override;
bool shaderProgramsAvailable() const override;
void setShaderProgramsAvailable(bool available) override;
typedef std::set<Renderable*> Renderables;
Renderables m_renderables;
mutable bool m_traverseRenderablesMutex;
/* OpenGLStateManager implementation */
void insertSortedState(const OpenGLStates::value_type& val) override;
void eraseSortedState(const OpenGLStates::key_type& key) override;
// renderables
void attachRenderable(Renderable& renderable) override;
void detachRenderable(Renderable& renderable) override;
void forEachRenderable(const RenderableCallback& callback) const override;
// RegisterableModule implementation
virtual const std::string& getName() const override;
virtual const StringSet& getDependencies() const override;
virtual void initialiseModule(const IApplicationContext& ctx) override;
virtual void shutdownModule() override;
};
typedef std::shared_ptr<OpenGLRenderSystem> OpenGLRenderSystemPtr;
} // namespace render