Skip to content

Commit

Permalink
#5609: When realising the render system in the constructor, give the …
Browse files Browse the repository at this point in the history
…code a chance to invoke extensionsInitialised() first.

The extensionsInitialised() call will query the GL setup for the ability to use GL programs, which should preferably be known before we realise the OpenGLShader objects.
  • Loading branch information
codereader committed May 13, 2021
1 parent b83c3d7 commit a88849e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions radiantcore/rendersystem/OpenGLRenderSystem.cpp
Expand Up @@ -47,6 +47,8 @@ OpenGLRenderSystem::OpenGLRenderSystem() :
_time(0),
m_traverseRenderablesMutex(false)
{
bool shouldRealise = false;

// For the static default rendersystem, the MaterialManager is not existent yet,
// hence it will be attached in initialiseModule().
if (module::GlobalModuleRegistry().moduleExists(MODULE_SHADERSYSTEM))
Expand All @@ -58,17 +60,24 @@ OpenGLRenderSystem::OpenGLRenderSystem() :

if (GlobalMaterialManager().isRealised())
{
realise();
// Hold back with the realise() call until we know whether we can call
// extensionsInitialised() below - this should happen before realise()
shouldRealise = true;
}
}

// If the openGL module is already initialised and a shared context is created
// trigger a call to extensionsInitialised().
if (GlobalRadiantCore().getModuleRegistry().moduleExists(MODULE_SHARED_GL_CONTEXT) &&
if (module::GlobalModuleRegistry().moduleExists(MODULE_SHARED_GL_CONTEXT) &&
GlobalOpenGLContext().getSharedContext())
{
extensionsInitialised();
}

if (shouldRealise)
{
realise();
}
}

OpenGLRenderSystem::~OpenGLRenderSystem()
Expand Down

0 comments on commit a88849e

Please sign in to comment.