diff --git a/src/frontend/qt_sdl/Screen.cpp b/src/frontend/qt_sdl/Screen.cpp index 01df8032..3e68b1bf 100644 --- a/src/frontend/qt_sdl/Screen.cpp +++ b/src/frontend/qt_sdl/Screen.cpp @@ -681,31 +681,31 @@ ScreenPanelGL::ScreenPanelGL(QWidget* parent) : ScreenPanel(parent) ScreenPanelGL::~ScreenPanelGL() {} -GL::Context* hax = nullptr; - bool ScreenPanelGL::createContext() { std::optional windowInfo = getWindowInfo(); - if (hax) + // if our parent window is parented to another window, we will + // share our OpenGL context with that window + MainWindow* parentwin = (MainWindow*)parentWidget()->parentWidget(); + if (parentwin) { if (windowInfo.has_value()) { - glContext = hax->CreateSharedContext(*getWindowInfo()); + glContext = parentwin->getOGLContext()->CreateSharedContext(*getWindowInfo()); glContext->DoneCurrent(); } - - return glContext != nullptr; } - - std::array versionsToTry = { - GL::Context::Version{GL::Context::Profile::Core, 4, 3}, - GL::Context::Version{GL::Context::Profile::Core, 3, 2}}; - if (windowInfo.has_value()) + else { - glContext = GL::Context::Create(*getWindowInfo(), versionsToTry); - glContext->DoneCurrent(); - hax = glContext.get(); + std::array versionsToTry = { + GL::Context::Version{GL::Context::Profile::Core, 4, 3}, + GL::Context::Version{GL::Context::Profile::Core, 3, 2}}; + if (windowInfo.has_value()) + { + glContext = GL::Context::Create(*getWindowInfo(), versionsToTry); + glContext->DoneCurrent(); + } } return glContext != nullptr; diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index ca9e34d4..19f6804c 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -380,7 +380,7 @@ int main(int argc, char** argv) if (options->fullscreen) ToggleFullscreen(mainWindow); - MainWindow* poop = new MainWindow(); + MainWindow* poop = new MainWindow(mainWindow); emuThread = new EmuThread(); emuThread->attachWindow(mainWindow);