mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-08 12:01:39 +12:00
Get emulator rendering working with Qt
This commit is contained in:
parent
4329976dbc
commit
5155682e0f
12 changed files with 98 additions and 22 deletions
|
@ -4,7 +4,7 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
|||
setWindowTitle("Alber");
|
||||
// Enable drop events for loading ROMs
|
||||
setAcceptDrops(true);
|
||||
resize(320, 240);
|
||||
resize(400, 240 * 2);
|
||||
screen.show();
|
||||
|
||||
// Set our menu bar up
|
||||
|
@ -25,9 +25,42 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
|||
themeSelect->setGeometry(40, 40, 100, 50);
|
||||
themeSelect->show();
|
||||
connect(themeSelect, &QComboBox::currentIndexChanged, this, [&](int index) { setTheme(static_cast<Theme>(index)); });
|
||||
|
||||
emu = new Emulator();
|
||||
|
||||
// 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;
|
||||
|
||||
if (rendererType == RendererType::OpenGL || rendererType == RendererType::Software) {
|
||||
// Make GL context current for this thread, enable VSync
|
||||
GL::Context* glContext = screen.getGLContext();
|
||||
glContext->MakeCurrent();
|
||||
glContext->SetSwapInterval(1);
|
||||
|
||||
emu->initGraphicsContext(glContext);
|
||||
} else if (rendererType != RendererType::Null) {
|
||||
Helpers::panic("Unsupported renderer type for the Qt backend! Vulkan on Qt is currently WIP, try the SDL frontend instead!");
|
||||
}
|
||||
|
||||
bool success = emu->loadROM("OoT.3ds");
|
||||
if (!success) {
|
||||
Helpers::panic("Failed to load ROM");
|
||||
}
|
||||
|
||||
while (true) {
|
||||
emu->runFrame();
|
||||
screen.getGLContext()->SwapBuffers();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() { delete menuBar; }
|
||||
// Cleanup when the main window closes
|
||||
MainWindow::~MainWindow() {
|
||||
delete emu;
|
||||
delete menuBar;
|
||||
delete themeSelect;
|
||||
}
|
||||
|
||||
void MainWindow::setTheme(Theme theme) {
|
||||
currentTheme = theme;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifdef PANDA3DS_ENABLE_OPENGL
|
||||
ScreenWidget::ScreenWidget(QWidget* parent) : QWidget(parent) {
|
||||
// Create a native window for use with our graphics API of choice
|
||||
resize(320, 240);
|
||||
resize(400, 240 * 2);
|
||||
|
||||
setAutoFillBackground(false);
|
||||
setAttribute(Qt::WA_NativeWindow, true);
|
||||
|
@ -33,18 +33,6 @@ ScreenWidget::ScreenWidget(QWidget* parent) : QWidget(parent) {
|
|||
if (!createGLContext()) {
|
||||
Helpers::panic("Failed to create GL context for display");
|
||||
}
|
||||
|
||||
// Make our context current to use it
|
||||
glContext->MakeCurrent();
|
||||
// Enable VSync for now
|
||||
glContext->SetSwapInterval(1);
|
||||
|
||||
OpenGL::setViewport(320, 240);
|
||||
OpenGL::setClearColor(1.0, 0.0, 0.0, 1.0);
|
||||
OpenGL::clearColor();
|
||||
|
||||
// Swap buffers to display our red as a test
|
||||
glContext->SwapBuffers();
|
||||
}
|
||||
|
||||
bool ScreenWidget::createGLContext() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue