Skip to content

Commit

Permalink
#5200: OpenGLRenderSystem will listen to shared context created/destr…
Browse files Browse the repository at this point in the history
…oyed signal on its own.
  • Loading branch information
codereader committed Sep 17, 2020
1 parent 6311959 commit a2e9ab6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 0 additions & 4 deletions radiant/render/OpenGLModule.cpp
Expand Up @@ -57,15 +57,11 @@ void OpenGLModule::sharedContextCreated()
{
// Initialise the font before firing the extension initialised signal
_font.reset(new wxutil::GLFont(wxutil::GLFont::FONT_SANS, 12));

// This call will automatically realise the render system
GlobalRenderSystem().extensionsInitialised();
}

void OpenGLModule::sharedContextDestroyed()
{
_font.reset();
GlobalRenderSystem().unrealise();
}

bool OpenGLModule::shaderProgramsAvailable() const
Expand Down
9 changes: 8 additions & 1 deletion radiantcore/rendersystem/OpenGLRenderSystem.cpp
Expand Up @@ -493,7 +493,7 @@ const StringSet& OpenGLRenderSystem::getDependencies() const
if (_dependencies.empty())
{
_dependencies.insert(MODULE_SHADERSYSTEM);
_dependencies.insert(MODULE_OPENGL);
_dependencies.insert(MODULE_SHARED_GL_CONTEXT);
}

return _dependencies;
Expand All @@ -516,10 +516,17 @@ void OpenGLRenderSystem::initialiseModule(const IApplicationContext& ctx)
// greebo: Don't realise the module yet, this must wait
// until the shared GL context has been created (this
// happens as soon as the first GL widget has been realised).
_sharedContextCreated = GlobalOpenGLContext().signal_sharedContextCreated()
.connect(sigc::mem_fun(this, &OpenGLRenderSystem::extensionsInitialised));

_sharedContextDestroyed = GlobalOpenGLContext().signal_sharedContextDestroyed()
.connect(sigc::mem_fun(this, &OpenGLRenderSystem::unrealise));
}

void OpenGLRenderSystem::shutdownModule()
{
_sharedContextCreated.disconnect();
_sharedContextDestroyed.disconnect();
_materialDefsLoaded.disconnect();
_materialDefsUnloaded.disconnect();
}
Expand Down
2 changes: 2 additions & 0 deletions radiantcore/rendersystem/OpenGLRenderSystem.h
Expand Up @@ -53,6 +53,8 @@ class OpenGLRenderSystem

sigc::connection _materialDefsLoaded;
sigc::connection _materialDefsUnloaded;
sigc::connection _sharedContextCreated;
sigc::connection _sharedContextDestroyed;

private:
void propagateLightChangedFlagToAllLights();
Expand Down

0 comments on commit a2e9ab6

Please sign in to comment.