From 2f184509b8f61b0b395f10f1aa97bfc69c596423 Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Tue, 20 Dec 2022 22:16:27 +0100 Subject: [PATCH] Restore GLX context after OGRE plugin loading finishes. The probing process OGRE uses might change the current GLX context, e.g. when used with VirtualGL. Signed-off-by: Martin Pecka --- ogre2/src/Ogre2RenderEngine.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ogre2/src/Ogre2RenderEngine.cc b/ogre2/src/Ogre2RenderEngine.cc index f91422f27..9a20332e7 100644 --- a/ogre2/src/Ogre2RenderEngine.cc +++ b/ogre2/src/Ogre2RenderEngine.cc @@ -539,8 +539,20 @@ void Ogre2RenderEngine::LoadPlugins() // load the plugin try { +#if HAVE_GLX + // Store the current GLX context in case OGRE plugin init changes it + const auto context = glXGetCurrentContext(); + const auto display = glXGetCurrentDisplay(); + const auto drawable = glXGetCurrentDrawable(); +#endif + // Load the plugin into OGRE this->ogreRoot->loadPlugin(filename); + +#if HAVE_GLX + // Restore GLX context + glXMakeCurrent(display, drawable, context); +#endif } catch(Ogre::Exception &e) {