start actually implementing multi-window feature, still rough around the edges

fix crash when closing main window if sub windows are involved

fix OpenGL context handling, still need to fix when changing display type
This commit is contained in:
Arisotura
2024-10-27 01:14:29 +02:00
parent f375099613
commit 881a740cab
8 changed files with 49 additions and 33 deletions

View File

@ -199,6 +199,10 @@ void EmuInstance::createWindow()
numWindows++;
emuThread->attachWindow(win);
// if creating a secondary window, we may need to initialize its OpenGL context here
if (win->hasOpenGL() && (win != topWindow))
emuThread->initContext(id);
}
void EmuInstance::deleteWindow(int id, bool close)
@ -208,12 +212,8 @@ void EmuInstance::deleteWindow(int id, bool close)
MainWindow* win = windowList[id];
if (!win) return;
if (win->hasOpenGL() && win == mainWindow)
{
// we intentionally don't unpause here
emuThread->emuPause();
emuThread->deinitContext();
}
if (win->hasOpenGL())
emuThread->deinitContext(id);
emuThread->detachWindow(win);
@ -226,9 +226,10 @@ void EmuInstance::deleteWindow(int id, bool close)
if (close)
win->close();
if ((!mainWindow) && (!deleting))
if (numWindows == 0)
{
// if we closed this instance's main window, delete the instance
// if we closed the last window, delete the instance
// if the main window is closed, Qt will take care of closing any secondary windows
deleteEmuInstance(instanceID);
}
}
@ -292,24 +293,18 @@ bool EmuInstance::usesOpenGL()
(globalCfg.GetInt("3D.Renderer") != renderer3D_Software);
}
void EmuInstance::initOpenGL()
void EmuInstance::initOpenGL(int win)
{
for (int i = 0; i < kMaxWindows; i++)
{
if (windowList[i])
windowList[i]->initOpenGL();
}
if (windowList[win])
windowList[win]->initOpenGL();
setVSyncGL(true);
}
void EmuInstance::deinitOpenGL()
void EmuInstance::deinitOpenGL(int win)
{
for (int i = 0; i < kMaxWindows; i++)
{
if (windowList[i])
windowList[i]->deinitOpenGL();
}
if (windowList[win])
windowList[win]->deinitOpenGL();
}
void EmuInstance::setVSyncGL(bool vsync)