mirror of https://github.com/mgba-emu/mgba.git
Qt: Make display driver configurable
This commit is contained in:
parent
87d26d39f9
commit
6529b3edf5
|
@ -5,12 +5,45 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
|
||||||
|
#include "DisplayGL.h"
|
||||||
|
#include "DisplayQt.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "gba/video.h"
|
#include "gba/video.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace QGBA;
|
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)
|
Display::Display(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,8 +16,18 @@ class Display : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class Driver {
|
||||||
|
QT = 0,
|
||||||
|
#ifdef BUILD_GL
|
||||||
|
OPENGL = 1,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
Display(QWidget* parent = nullptr);
|
Display(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
static Display* create(QWidget* parent = nullptr);
|
||||||
|
static void setDriver(Driver driver) { s_driver = driver; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void startDrawing(GBAThread* context) = 0;
|
virtual void startDrawing(GBAThread* context) = 0;
|
||||||
virtual void stopDrawing() = 0;
|
virtual void stopDrawing() = 0;
|
||||||
|
@ -29,6 +39,9 @@ public slots:
|
||||||
virtual void framePosted(const uint32_t*) = 0;
|
virtual void framePosted(const uint32_t*) = 0;
|
||||||
|
|
||||||
virtual void showMessage(const QString& message) = 0;
|
virtual void showMessage(const QString& message) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static Driver s_driver;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
|
|
||||||
#include "AudioProcessor.h"
|
#include "AudioProcessor.h"
|
||||||
|
#include "Display.h"
|
||||||
#include "GameController.h"
|
#include "GameController.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ GBAApp::GBAApp(int& argc, char* argv[])
|
||||||
}
|
}
|
||||||
freeArguments(&args);
|
freeArguments(&args);
|
||||||
|
|
||||||
|
Display::setDriver(static_cast<Display::Driver>(m_configController.getQtOption("videoDriver").toInt()));
|
||||||
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt()));
|
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController.getQtOption("audioDriver").toInt()));
|
||||||
w->controller()->reloadAudioDriver();
|
w->controller()->reloadAudioDriver();
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "CheatsView.h"
|
#include "CheatsView.h"
|
||||||
#include "ConfigController.h"
|
#include "ConfigController.h"
|
||||||
#include "DisplayGL.h"
|
#include "Display.h"
|
||||||
#include "GameController.h"
|
#include "GameController.h"
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
#include "GBAKeyEditor.h"
|
#include "GBAKeyEditor.h"
|
||||||
|
@ -73,9 +73,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
|
||||||
m_controller->setOverrides(m_config->overrides());
|
m_controller->setOverrides(m_config->overrides());
|
||||||
updateTitle();
|
updateTitle();
|
||||||
|
|
||||||
QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer));
|
m_display = Display::create(this);
|
||||||
format.setSwapInterval(1);
|
|
||||||
m_display = new DisplayGL(format, this);
|
|
||||||
|
|
||||||
m_logo.setDevicePixelRatio(m_screenWidget->devicePixelRatio());
|
m_logo.setDevicePixelRatio(m_screenWidget->devicePixelRatio());
|
||||||
m_logo = m_logo; // Free memory left over in old pixmap
|
m_logo = m_logo; // Free memory left over in old pixmap
|
||||||
|
|
Loading…
Reference in New Issue