all repos — mgba @ 6529b3edf52665f567cabcb4cf6e59efafe2bf30

mGBA Game Boy Advance Emulator

Qt: Make display driver configurable
Jeffrey Pfau jeffrey@endrift.com
Sat, 13 Jun 2015 03:02:04 -0700
commit

6529b3edf52665f567cabcb4cf6e59efafe2bf30

parent

87d26d39f9758d53b5677b6fc71cdd3ea679ecea

M src/platform/qt/Display.cppsrc/platform/qt/Display.cpp

@@ -5,11 +5,44 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Display.h" +#include "DisplayGL.h" +#include "DisplayQt.h" + extern "C" { #include "gba/video.h" } using namespace QGBA; + +#ifdef BUILD_GL +Display::Driver Display::s_driver = Display::Driver::OPENGL; +#else +Display::Driver Display::s_driver = Display::Driver::QT; +#endif + +Display* Display::create(QWidget* parent) { +#ifdef BUILD_GL + QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer)); + format.setSwapInterval(1); +#endif + + switch (s_driver) { +#ifdef BUILD_GL + case Driver::OPENGL: + return new DisplayGL(format, parent); +#endif + + case Driver::QT: + return new DisplayQt(parent); + + default: +#ifdef BUILD_GL + return new DisplayGL(format, parent); +#else + return new DisplayQt(parent); +#endif + } +} Display::Display(QWidget* parent) : QWidget(parent)
M src/platform/qt/Display.hsrc/platform/qt/Display.h

@@ -16,8 +16,18 @@ class Display : public QWidget {

Q_OBJECT public: + enum class Driver { + QT = 0, +#ifdef BUILD_GL + OPENGL = 1, +#endif + }; + Display(QWidget* parent = nullptr); + static Display* create(QWidget* parent = nullptr); + static void setDriver(Driver driver) { s_driver = driver; } + public slots: virtual void startDrawing(GBAThread* context) = 0; virtual void stopDrawing() = 0;

@@ -29,6 +39,9 @@ virtual void filter(bool filter) = 0;

virtual void framePosted(const uint32_t*) = 0; virtual void showMessage(const QString& message) = 0; + +private: + static Driver s_driver; }; }
M src/platform/qt/GBAApp.cppsrc/platform/qt/GBAApp.cpp

@@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "GBAApp.h" #include "AudioProcessor.h" +#include "Display.h" #include "GameController.h" #include "Window.h"

@@ -55,6 +56,7 @@ w->loadConfig();

} freeArguments(&args); + Display::setDriver(static_cast<Display::Driver>(m_configController.getQtOption("videoDriver").toInt())); AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt())); w->controller()->reloadAudioDriver();
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -15,7 +15,7 @@ #include <QStackedLayout>

#include "CheatsView.h" #include "ConfigController.h" -#include "DisplayGL.h" +#include "Display.h" #include "GameController.h" #include "GBAApp.h" #include "GBAKeyEditor.h"

@@ -73,9 +73,7 @@ m_controller->setInputController(&m_inputController);

m_controller->setOverrides(m_config->overrides()); updateTitle(); - QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer)); - format.setSwapInterval(1); - m_display = new DisplayGL(format, this); + m_display = Display::create(this); m_logo.setDevicePixelRatio(m_screenWidget->devicePixelRatio()); m_logo = m_logo; // Free memory left over in old pixmap