mirror of https://github.com/mgba-emu/mgba.git
Qt: Improve OpenGLES support and cleanup ifdef maze
This commit is contained in:
parent
55c7c2f48e
commit
c917a71ef8
|
@ -33,49 +33,33 @@ QGBA::Display* QGBA::Display::create(QWidget* parent) {
|
|||
switch (s_driver) {
|
||||
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
|
||||
case Driver::OPENGL:
|
||||
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
|
||||
format.setVersion(2, 0);
|
||||
} else {
|
||||
format.setVersion(3, 3);
|
||||
default:
|
||||
if (DisplayGL::highestCompatible(format)) {
|
||||
return new DisplayGL(format, parent);
|
||||
}
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
if (DisplayGL::supportsFormat(format)) {
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
} else {
|
||||
#ifdef BUILD_GL
|
||||
LOG(QT, WARN) << ("Failed to create an OpenGL Core context, trying old-style...");
|
||||
format.setVersion(1, 4);
|
||||
format.setOption(QSurfaceFormat::DeprecatedFunctions);
|
||||
if (!DisplayGL::supportsFormat(format)) {
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
return new DisplayGL(format, parent);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef BUILD_GL
|
||||
case Driver::OPENGL1:
|
||||
format.setVersion(1, 4);
|
||||
if (!DisplayGL::supportsFormat(format)) {
|
||||
return nullptr;
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
|
||||
format.setVersion(1, 4);
|
||||
} else {
|
||||
format.setVersion(1, 1);
|
||||
}
|
||||
return new DisplayGL(format, parent);
|
||||
if (DisplayGL::supportsFormat(format)) {
|
||||
return new DisplayGL(format, parent);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Driver::QT:
|
||||
#if !defined(BUILD_GL) && !defined(BUILD_GLES2) && !defined(BUILD_GLES3) && !defined(USE_EPOXY)
|
||||
default:
|
||||
#endif
|
||||
return new DisplayQt(parent);
|
||||
|
||||
default:
|
||||
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
|
||||
return new DisplayGL(format, parent);
|
||||
#else
|
||||
return new DisplayQt(parent);
|
||||
#endif
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QGBA::Display::Display(QWidget* parent)
|
||||
|
|
|
@ -53,6 +53,12 @@ typedef struct _XDisplay Display;
|
|||
#define OVERHEAD_NSEC 300000
|
||||
#endif
|
||||
|
||||
// Legacy define from X11/X.h
|
||||
#ifdef Unsorted
|
||||
#undef Unsorted
|
||||
#endif
|
||||
|
||||
#include "LogController.h"
|
||||
#include "OpenGLBug.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
@ -277,6 +283,47 @@ void DisplayGL::startDrawing(std::shared_ptr<CoreController> controller) {
|
|||
QTimer::singleShot(8, this, &DisplayGL::updateContentSize);
|
||||
}
|
||||
|
||||
bool DisplayGL::highestCompatible(QSurfaceFormat& format) {
|
||||
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
|
||||
format.setVersion(3, 3);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
if (DisplayGL::supportsFormat(format)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
#if defined(BUILD_GLES3) || defined(USE_EPOXY)
|
||||
format.setVersion(3, 1);
|
||||
if (DisplayGL::supportsFormat(format)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if defined(BUILD_GLES2) || defined(USE_EPOXY)
|
||||
format.setVersion(2, 0);
|
||||
if (DisplayGL::supportsFormat(format)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_GL
|
||||
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
|
||||
LOG(QT, WARN) << tr("Failed to create an OpenGL 3 context, trying old-style...");
|
||||
#endif
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
|
||||
format.setVersion(1, 4);
|
||||
} else {
|
||||
format.setVersion(1, 1);
|
||||
}
|
||||
format.setOption(QSurfaceFormat::DeprecatedFunctions);
|
||||
if (DisplayGL::supportsFormat(format)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DisplayGL::supportsFormat(const QSurfaceFormat& format) {
|
||||
if (!s_supports.contains(format)) {
|
||||
QOpenGLContext context;
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
int framebufferHandle() override;
|
||||
QSize contentSize() const override { return m_cachedContentSize; }
|
||||
|
||||
static bool highestCompatible(QSurfaceFormat&);
|
||||
static bool supportsFormat(const QSurfaceFormat&);
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in New Issue