actual non hacky way to share OpenGL contexts
This commit is contained in:
parent
660d830135
commit
a6ab27de6b
|
@ -681,31 +681,31 @@ ScreenPanelGL::ScreenPanelGL(QWidget* parent) : ScreenPanel(parent)
|
||||||
ScreenPanelGL::~ScreenPanelGL()
|
ScreenPanelGL::~ScreenPanelGL()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
GL::Context* hax = nullptr;
|
|
||||||
|
|
||||||
bool ScreenPanelGL::createContext()
|
bool ScreenPanelGL::createContext()
|
||||||
{
|
{
|
||||||
std::optional<WindowInfo> windowInfo = getWindowInfo();
|
std::optional<WindowInfo> 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())
|
if (windowInfo.has_value())
|
||||||
{
|
{
|
||||||
glContext = hax->CreateSharedContext(*getWindowInfo());
|
glContext = parentwin->getOGLContext()->CreateSharedContext(*getWindowInfo());
|
||||||
glContext->DoneCurrent();
|
glContext->DoneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return glContext != nullptr;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
std::array<GL::Context::Version, 2> 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);
|
std::array<GL::Context::Version, 2> versionsToTry = {
|
||||||
glContext->DoneCurrent();
|
GL::Context::Version{GL::Context::Profile::Core, 4, 3},
|
||||||
hax = glContext.get();
|
GL::Context::Version{GL::Context::Profile::Core, 3, 2}};
|
||||||
|
if (windowInfo.has_value())
|
||||||
|
{
|
||||||
|
glContext = GL::Context::Create(*getWindowInfo(), versionsToTry);
|
||||||
|
glContext->DoneCurrent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return glContext != nullptr;
|
return glContext != nullptr;
|
||||||
|
|
|
@ -380,7 +380,7 @@ int main(int argc, char** argv)
|
||||||
if (options->fullscreen)
|
if (options->fullscreen)
|
||||||
ToggleFullscreen(mainWindow);
|
ToggleFullscreen(mainWindow);
|
||||||
|
|
||||||
MainWindow* poop = new MainWindow();
|
MainWindow* poop = new MainWindow(mainWindow);
|
||||||
|
|
||||||
emuThread = new EmuThread();
|
emuThread = new EmuThread();
|
||||||
emuThread->attachWindow(mainWindow);
|
emuThread->attachWindow(mainWindow);
|
||||||
|
|
Loading…
Reference in New Issue