From 6646baa3b3c07f123059c9d101d167444efb101a Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 31 Jan 2016 12:24:09 -0800 Subject: [PATCH] Qt: Add ability to force old versions of OpenGL --- src/platform/qt/Display.cpp | 16 ++++++++++------ src/platform/qt/Display.h | 5 ++++- src/platform/qt/DisplayGL.cpp | 12 ++++++++++-- src/platform/qt/DisplayGL.h | 2 +- src/platform/qt/SettingsView.cpp | 9 ++++++++- src/platform/sdl/main.c | 2 +- src/platform/sdl/main.h | 6 +++--- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index 014162562..5d76a5144 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -14,30 +14,34 @@ extern "C" { using namespace QGBA; -#ifdef BUILD_GL +#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) 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 +#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer)); format.setSwapInterval(1); #endif switch (s_driver) { -#ifdef BUILD_GL +#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) case Driver::OPENGL: - return new DisplayGL(format, parent); + return new DisplayGL(format, false, parent); +#endif +#ifdef BUILD_GL + case Driver::OPENGL1: + return new DisplayGL(format, true, parent); #endif case Driver::QT: return new DisplayQt(parent); default: -#ifdef BUILD_GL - return new DisplayGL(format, parent); +#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) + return new DisplayGL(format, false, parent); #else return new DisplayQt(parent); #endif diff --git a/src/platform/qt/Display.h b/src/platform/qt/Display.h index 097e4c12f..a4145f6df 100644 --- a/src/platform/qt/Display.h +++ b/src/platform/qt/Display.h @@ -22,8 +22,11 @@ Q_OBJECT public: enum class Driver { QT = 0, -#ifdef BUILD_GL +#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) OPENGL = 1, +#endif +#ifdef BUILD_GL + OPENGL1 = 2, #endif }; diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index c05ecdf1c..91ddaf68f 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -24,14 +24,22 @@ extern "C" { using namespace QGBA; -DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent) +DisplayGL::DisplayGL(const QGLFormat& format, bool force1, QWidget* parent) : Display(parent) , m_isDrawing(false) , m_gl(new EmptyGLWidget(format, this)) , m_drawThread(nullptr) , m_context(nullptr) { - m_painter = new PainterGL(m_gl, QGLFormat::openGLVersionFlags()); + QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags(); + if (force1) { + versions &= QGLFormat::OpenGL_Version_1_1 | + QGLFormat::OpenGL_Version_1_2 | + QGLFormat::OpenGL_Version_1_3 | + QGLFormat::OpenGL_Version_1_4 | + QGLFormat::OpenGL_Version_1_5; + } + m_painter = new PainterGL(m_gl, versions); m_gl->setMouseTracking(true); m_gl->setAttribute(Qt::WA_TransparentForMouseEvents); // This doesn't seem to work? } diff --git a/src/platform/qt/DisplayGL.h b/src/platform/qt/DisplayGL.h index 39fa1e308..fa0b9e514 100644 --- a/src/platform/qt/DisplayGL.h +++ b/src/platform/qt/DisplayGL.h @@ -45,7 +45,7 @@ class DisplayGL : public Display { Q_OBJECT public: - DisplayGL(const QGLFormat& format, QWidget* parent = nullptr); + DisplayGL(const QGLFormat& format, bool force1 = false, QWidget* parent = nullptr); ~DisplayGL(); bool isDrawing() const override { return m_isDrawing; } diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index 48ed5e4e8..ac7df35a3 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -114,13 +114,20 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1); } -#ifdef BUILD_GL +#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) m_ui.displayDriver->addItem(tr("OpenGL"), static_cast(Display::Driver::OPENGL)); if (displayDriver.isNull() || displayDriver.toInt() == static_cast(Display::Driver::OPENGL)) { m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1); } #endif +#ifdef BUILD_GL + m_ui.displayDriver->addItem(tr("OpenGL (force version 1.x)"), static_cast(Display::Driver::OPENGL1)); + if (displayDriver.isNull() || displayDriver.toInt() == static_cast(Display::Driver::OPENGL1)) { + m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1); + } +#endif + connect(m_ui.biosBrowse, SIGNAL(clicked()), this, SLOT(selectBios())); connect(m_ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateConfig())); connect(m_ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* button) { diff --git a/src/platform/sdl/main.c b/src/platform/sdl/main.c index ffc801413..ebbbaae93 100644 --- a/src/platform/sdl/main.c +++ b/src/platform/sdl/main.c @@ -95,7 +95,7 @@ int main(int argc, char** argv) { #ifdef BUILD_GL GBASDLGLCreate(&renderer); -#elif defined(BUILD_GLES2) +#elif defined(BUILD_GLES2) || defined(USE_EPOXY) GBASDLGLES2Create(&renderer); #else GBASDLSWCreate(&renderer); diff --git a/src/platform/sdl/main.h b/src/platform/sdl/main.h index 5504fe988..28ea116a4 100644 --- a/src/platform/sdl/main.h +++ b/src/platform/sdl/main.h @@ -26,7 +26,7 @@ #pragma GCC diagnostic pop #endif -#ifdef BUILD_GLES2 +#if defined(BUILD_GLES2) || defined(USE_EPOXY) #include "platform/opengl/gles2.h" #endif @@ -63,7 +63,7 @@ struct SDLSoftwareRenderer { #ifdef BUILD_GL struct GBAGLContext gl; #endif -#ifdef BUILD_GLES2 +#if defined(BUILD_GLES2) || defined(USE_EPOXY) struct GBAGLES2Context gl2; #endif @@ -92,7 +92,7 @@ void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer); void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer); #endif -#ifdef BUILD_GLES2 +#if defined(BUILD_GLES2) || defined(USE_EPOXY) void GBASDLGLES2Create(struct SDLSoftwareRenderer* renderer); #endif #endif