Qt: Add ability to force old versions of OpenGL
Jeffrey Pfau jeffrey@endrift.com
Sun, 31 Jan 2016 12:24:09 -0800
7 files changed,
37 insertions(+),
15 deletions(-)
M
src/platform/qt/Display.cpp
→
src/platform/qt/Display.cpp
@@ -14,30 +14,34 @@ }
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
M
src/platform/qt/Display.h
→
src/platform/qt/Display.h
@@ -22,8 +22,11 @@
public: enum class Driver { QT = 0, +#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) + OPENGL = 1, +#endif #ifdef BUILD_GL - OPENGL = 1, + OPENGL1 = 2, #endif };
M
src/platform/qt/DisplayGL.cpp
→
src/platform/qt/DisplayGL.cpp
@@ -24,14 +24,22 @@ }
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? }
M
src/platform/qt/DisplayGL.h
→
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; }
M
src/platform/qt/SettingsView.cpp
→
src/platform/qt/SettingsView.cpp
@@ -114,9 +114,16 @@ if (!displayDriver.isNull() && displayDriver.toInt() == static_cast<int>(Display::Driver::QT)) {
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<int>(Display::Driver::OPENGL)); if (displayDriver.isNull() || displayDriver.toInt() == static_cast<int>(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<int>(Display::Driver::OPENGL1)); + if (displayDriver.isNull() || displayDriver.toInt() == static_cast<int>(Display::Driver::OPENGL1)) { m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1); } #endif
M
src/platform/sdl/main.c
→
src/platform/sdl/main.c
@@ -95,7 +95,7 @@ renderer.filter = opts.resampleVideo;
#ifdef BUILD_GL GBASDLGLCreate(&renderer); -#elif defined(BUILD_GLES2) +#elif defined(BUILD_GLES2) || defined(USE_EPOXY) GBASDLGLES2Create(&renderer); #else GBASDLSWCreate(&renderer);
M
src/platform/sdl/main.h
→
src/platform/sdl/main.h
@@ -26,7 +26,7 @@ #include <bcm_host.h>
#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 @@
#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 @@ #ifdef BUILD_GL
void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer); #endif -#ifdef BUILD_GLES2 +#if defined(BUILD_GLES2) || defined(USE_EPOXY) void GBASDLGLES2Create(struct SDLSoftwareRenderer* renderer); #endif #endif