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; using namespace QGBA;
#ifdef BUILD_GL #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
Display::Driver Display::s_driver = Display::Driver::OPENGL; Display::Driver Display::s_driver = Display::Driver::OPENGL;
#else #else
Display::Driver Display::s_driver = Display::Driver::QT; Display::Driver Display::s_driver = Display::Driver::QT;
#endif #endif
Display* Display::create(QWidget* parent) { 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)); QGLFormat format(QGLFormat(QGL::Rgba | QGL::DoubleBuffer));
format.setSwapInterval(1); format.setSwapInterval(1);
#endif #endif
switch (s_driver) { switch (s_driver) {
#ifdef BUILD_GL #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
case Driver::OPENGL: 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 #endif
case Driver::QT: case Driver::QT:
return new DisplayQt(parent); return new DisplayQt(parent);
default: default:
#ifdef BUILD_GL #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
return new DisplayGL(format, parent); return new DisplayGL(format, false, parent);
#else #else
return new DisplayQt(parent); return new DisplayQt(parent);
#endif #endif

View File

@ -22,8 +22,11 @@ Q_OBJECT
public: public:
enum class Driver { enum class Driver {
QT = 0, QT = 0,
#ifdef BUILD_GL #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
OPENGL = 1, OPENGL = 1,
#endif
#ifdef BUILD_GL
OPENGL1 = 2,
#endif #endif
}; };

View File

@ -24,14 +24,22 @@ extern "C" {
using namespace QGBA; using namespace QGBA;
DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent) DisplayGL::DisplayGL(const QGLFormat& format, bool force1, QWidget* parent)
: Display(parent) : Display(parent)
, m_isDrawing(false) , m_isDrawing(false)
, m_gl(new EmptyGLWidget(format, this)) , m_gl(new EmptyGLWidget(format, this))
, m_drawThread(nullptr) , m_drawThread(nullptr)
, m_context(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->setMouseTracking(true);
m_gl->setAttribute(Qt::WA_TransparentForMouseEvents); // This doesn't seem to work? m_gl->setAttribute(Qt::WA_TransparentForMouseEvents); // This doesn't seem to work?
} }

View File

@ -45,7 +45,7 @@ class DisplayGL : public Display {
Q_OBJECT Q_OBJECT
public: public:
DisplayGL(const QGLFormat& format, QWidget* parent = nullptr); DisplayGL(const QGLFormat& format, bool force1 = false, QWidget* parent = nullptr);
~DisplayGL(); ~DisplayGL();
bool isDrawing() const override { return m_isDrawing; } 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); 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)); m_ui.displayDriver->addItem(tr("OpenGL"), static_cast<int>(Display::Driver::OPENGL));
if (displayDriver.isNull() || displayDriver.toInt() == 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); m_ui.displayDriver->setCurrentIndex(m_ui.displayDriver->count() - 1);
} }
#endif #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.biosBrowse, SIGNAL(clicked()), this, SLOT(selectBios()));
connect(m_ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateConfig())); connect(m_ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateConfig()));
connect(m_ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* button) { connect(m_ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* button) {

View File

@ -95,7 +95,7 @@ int main(int argc, char** argv) {
#ifdef BUILD_GL #ifdef BUILD_GL
GBASDLGLCreate(&renderer); GBASDLGLCreate(&renderer);
#elif defined(BUILD_GLES2) #elif defined(BUILD_GLES2) || defined(USE_EPOXY)
GBASDLGLES2Create(&renderer); GBASDLGLES2Create(&renderer);
#else #else
GBASDLSWCreate(&renderer); GBASDLSWCreate(&renderer);

View File

@ -26,7 +26,7 @@
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(USE_EPOXY)
#include "platform/opengl/gles2.h" #include "platform/opengl/gles2.h"
#endif #endif
@ -63,7 +63,7 @@ struct SDLSoftwareRenderer {
#ifdef BUILD_GL #ifdef BUILD_GL
struct GBAGLContext gl; struct GBAGLContext gl;
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(USE_EPOXY)
struct GBAGLES2Context gl2; struct GBAGLES2Context gl2;
#endif #endif
@ -92,7 +92,7 @@ void GBASDLSWCreate(struct SDLSoftwareRenderer* renderer);
void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer); void GBASDLGLCreate(struct SDLSoftwareRenderer* renderer);
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(USE_EPOXY)
void GBASDLGLES2Create(struct SDLSoftwareRenderer* renderer); void GBASDLGLES2Create(struct SDLSoftwareRenderer* renderer);
#endif #endif
#endif #endif