mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-11 08:39:48 +12:00
[Qt] Be a little less OpenGL-hyperfocused
This commit is contained in:
parent
c10a3e7160
commit
fbfea624cb
2 changed files with 20 additions and 3 deletions
|
@ -30,6 +30,11 @@ class MainWindow : public QMainWindow {
|
|||
|
||||
Theme currentTheme;
|
||||
void setTheme(Theme theme);
|
||||
void swapEmuBuffer();
|
||||
|
||||
// Tracks whether we are using an OpenGL-backed renderer or a Vulkan-backed renderer
|
||||
bool usingGL = false;
|
||||
bool usingVk = false;
|
||||
|
||||
public:
|
||||
MainWindow(QApplication* app, QWidget* parent = nullptr);
|
||||
|
|
|
@ -32,16 +32,20 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
|||
// The emulator graphics context for the thread should be initialized in the emulator thread due to how GL contexts work
|
||||
emuThread = std::thread([&]() {
|
||||
const RendererType rendererType = emu->getConfig().rendererType;
|
||||
usingGL = (rendererType == RendererType::OpenGL || rendererType == RendererType::Software || rendererType == RendererType::Null);
|
||||
usingVk = (rendererType == RendererType::Vulkan);
|
||||
|
||||
if (rendererType == RendererType::OpenGL || rendererType == RendererType::Software || rendererType == RendererType::Null) {
|
||||
if (usingGL) {
|
||||
// Make GL context current for this thread, enable VSync
|
||||
GL::Context* glContext = screen.getGLContext();
|
||||
glContext->MakeCurrent();
|
||||
glContext->SetSwapInterval(1);
|
||||
|
||||
emu->initGraphicsContext(glContext);
|
||||
} else if (usingVk) {
|
||||
Helpers::panic("Vulkan on Qt is currently WIP, try the SDL frontend instead!");
|
||||
} else {
|
||||
Helpers::panic("Unsupported renderer type for the Qt backend! Vulkan on Qt is currently WIP, try the SDL frontend instead!");
|
||||
Helpers::panic("Unsupported graphics backend for Qt frontend!");
|
||||
}
|
||||
|
||||
bool success = emu->loadROM("OoT.3ds");
|
||||
|
@ -51,11 +55,19 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
|||
|
||||
while (true) {
|
||||
emu->runFrame();
|
||||
screen.getGLContext()->SwapBuffers();
|
||||
swapEmuBuffer();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::swapEmuBuffer() {
|
||||
if (usingGL) {
|
||||
screen.getGLContext()->SwapBuffers();
|
||||
} else {
|
||||
Helpers::panic("[Qt] Don't know how to swap buffers for the current rendering backend :(");
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup when the main window closes
|
||||
MainWindow::~MainWindow() {
|
||||
delete emu;
|
||||
|
|
Loading…
Add table
Reference in a new issue