mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-13 23:35:06 +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;
|
Theme currentTheme;
|
||||||
void setTheme(Theme theme);
|
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:
|
public:
|
||||||
MainWindow(QApplication* app, QWidget* parent = nullptr);
|
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
|
// The emulator graphics context for the thread should be initialized in the emulator thread due to how GL contexts work
|
||||||
emuThread = std::thread([&]() {
|
emuThread = std::thread([&]() {
|
||||||
const RendererType rendererType = emu->getConfig().rendererType;
|
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
|
// Make GL context current for this thread, enable VSync
|
||||||
GL::Context* glContext = screen.getGLContext();
|
GL::Context* glContext = screen.getGLContext();
|
||||||
glContext->MakeCurrent();
|
glContext->MakeCurrent();
|
||||||
glContext->SetSwapInterval(1);
|
glContext->SetSwapInterval(1);
|
||||||
|
|
||||||
emu->initGraphicsContext(glContext);
|
emu->initGraphicsContext(glContext);
|
||||||
|
} else if (usingVk) {
|
||||||
|
Helpers::panic("Vulkan on Qt is currently WIP, try the SDL frontend instead!");
|
||||||
} else {
|
} 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");
|
bool success = emu->loadROM("OoT.3ds");
|
||||||
|
@ -51,11 +55,19 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
emu->runFrame();
|
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
|
// Cleanup when the main window closes
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
delete emu;
|
delete emu;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue