diff --git a/components/sceneutil/glextensions.cpp b/components/sceneutil/glextensions.cpp index eb55e17b1c..3a14dab8ed 100644 --- a/components/sceneutil/glextensions.cpp +++ b/components/sceneutil/glextensions.cpp @@ -33,6 +33,11 @@ namespace SceneUtil GLExtensionsObserver GLExtensionsObserver::sInstance{}; } + bool glExtensionsReady() + { + return !sGLExtensions.empty(); + } + osg::GLExtensions& getGLExtensions() { if (sGLExtensions.empty()) diff --git a/components/sceneutil/glextensions.hpp b/components/sceneutil/glextensions.hpp index 17a4eb8488..05e7f715c1 100644 --- a/components/sceneutil/glextensions.hpp +++ b/components/sceneutil/glextensions.hpp @@ -6,6 +6,7 @@ namespace SceneUtil { + bool glExtensionsReady(); osg::GLExtensions& getGLExtensions(); class GetGLExtensionsOperation : public osg::GraphicsOperation diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 48efb7fda9..c76f0b6b5c 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -825,9 +825,9 @@ namespace SceneUtil , mPointLightFadeEnd(0.f) , mPointLightFadeStart(0.f) { - osg::GLExtensions& exts = SceneUtil::getGLExtensions(); - bool supportsUBO = exts.isUniformBufferObjectSupported; - bool supportsGPU4 = exts.isGpuShader4Supported; + osg::GLExtensions* exts = SceneUtil::glExtensionsReady() ? &SceneUtil::getGLExtensions() : nullptr; + bool supportsUBO = exts && exts->isUniformBufferObjectSupported; + bool supportsGPU4 = exts && exts->isGpuShader4Supported; mSupported[static_cast(LightingMethod::FFP)] = true; mSupported[static_cast(LightingMethod::PerObjectUniform)] = true;