Qt: Add ability to force old versions of OpenGL

This commit is contained in:
Jeffrey Pfau 2016-01-31 12:24:09 -08:00
parent 66d005030f
commit 6646baa3b3
7 changed files with 37 additions and 15 deletions

View File

@ -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

View File

@ -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
};

View File

@ -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?
}

View File

@ -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; }

View File

@ -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<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
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) {

View File

@ -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);

View File

@ -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