/
WxGLWidgetManager.cpp
60 lines (45 loc) · 1.22 KB
/
WxGLWidgetManager.cpp
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
#include "WxGLWidgetManager.h"
#include "igl.h"
#include "module/StaticModule.h"
#include "wxutil/GLWidget.h"
#include "wxutil/GLContext.h"
namespace ui
{
void WxGLWidgetManager::registerGLWidget(wxutil::GLWidget* widget)
{
auto result = _wxGLWidgets.insert(widget);
if (result.second && _wxGLWidgets.size() == 1)
{
auto context = std::make_shared<wxutil::GLContext>(widget);
GlobalOpenGLContext().setSharedContext(context);
}
}
void WxGLWidgetManager::unregisterGLWidget(wxutil::GLWidget* widget)
{
assert(_wxGLWidgets.find(widget) != _wxGLWidgets.end());
_wxGLWidgets.erase(widget);
if (_wxGLWidgets.empty())
{
GlobalOpenGLContext().setSharedContext(gl::IGLContext::Ptr());
}
}
const std::string& WxGLWidgetManager::getName() const
{
static std::string _name(MODULE_WXGLWIDGET_MANAGER);
return _name;
}
const StringSet& WxGLWidgetManager::getDependencies() const
{
static StringSet _dependencies;
return _dependencies;
}
void WxGLWidgetManager::initialiseModule(const IApplicationContext& ctx)
{
rMessage() << getName() << "::initialiseModule called." << std::endl;
}
void WxGLWidgetManager::shutdownModule()
{
_wxGLWidgets.clear();
}
module::StaticModuleRegistration<WxGLWidgetManager> wxGLWidgetManagerModule;
}