mirror of https://github.com/mgba-emu/mgba.git
Qt: Simplify OpenGL backend creation
This commit is contained in:
parent
04a81d2ec5
commit
8c6a57f7d9
|
@ -28,12 +28,7 @@ DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent)
|
||||||
, m_drawThread(nullptr)
|
, m_drawThread(nullptr)
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
{
|
{
|
||||||
QGLFormat::OpenGLVersionFlag glVersion = QGLFormat::OpenGL_Version_1_4;
|
m_painter = new PainterGL(m_gl, QGLFormat::openGLVersionFlags());
|
||||||
QGLFormat::OpenGLVersionFlags supported = QGLFormat::openGLVersionFlags();
|
|
||||||
if (supported & QGLFormat::OpenGL_Version_2_1) {
|
|
||||||
glVersion = QGLFormat::OpenGL_Version_2_1;
|
|
||||||
}
|
|
||||||
m_painter = new PainterGL(m_gl, glVersion);
|
|
||||||
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?
|
||||||
}
|
}
|
||||||
|
@ -147,7 +142,7 @@ void DisplayGL::resizePainter() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PainterGL::PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlag glVersion)
|
PainterGL::PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlags glVersion)
|
||||||
: m_gl(parent)
|
: m_gl(parent)
|
||||||
, m_active(false)
|
, m_active(false)
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
|
@ -156,27 +151,22 @@ PainterGL::PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlag glVersion)
|
||||||
#ifdef BUILD_GL
|
#ifdef BUILD_GL
|
||||||
GBAGLContext* glBackend;
|
GBAGLContext* glBackend;
|
||||||
#endif
|
#endif
|
||||||
#if !defined(_WIN32)
|
#ifndef _WIN32
|
||||||
GBAGLES2Context* gl2Backend;
|
GBAGLES2Context* gl2Backend;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (glVersion) {
|
#ifndef _WIN32
|
||||||
default:
|
if (glVersion & QGLFormat::OpenGL_Version_3_0) {
|
||||||
#if !defined(_WIN32)
|
|
||||||
gl2Backend = new GBAGLES2Context;
|
gl2Backend = new GBAGLES2Context;
|
||||||
GBAGLES2ContextCreate(gl2Backend);
|
GBAGLES2ContextCreate(gl2Backend);
|
||||||
m_backend = &gl2Backend->d;
|
m_backend = &gl2Backend->d;
|
||||||
break;
|
} else {
|
||||||
|
#else
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
case QGLFormat::OpenGL_Version_1_1:
|
|
||||||
case QGLFormat::OpenGL_Version_1_2:
|
|
||||||
case QGLFormat::OpenGL_Version_1_3:
|
|
||||||
case QGLFormat::OpenGL_Version_1_4:
|
|
||||||
case QGLFormat::OpenGL_Version_1_5:
|
|
||||||
glBackend = new GBAGLContext;
|
glBackend = new GBAGLContext;
|
||||||
GBAGLContextCreate(glBackend);
|
GBAGLContextCreate(glBackend);
|
||||||
m_backend = &glBackend->d;
|
m_backend = &glBackend->d;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
m_backend->swap = [](VideoBackend* v) {
|
m_backend->swap = [](VideoBackend* v) {
|
||||||
PainterGL* painter = static_cast<PainterGL*>(v->user);
|
PainterGL* painter = static_cast<PainterGL*>(v->user);
|
||||||
|
@ -199,6 +189,7 @@ PainterGL::~PainterGL() {
|
||||||
delete[] item;
|
delete[] item;
|
||||||
}
|
}
|
||||||
delete m_backend;
|
delete m_backend;
|
||||||
|
m_backend = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PainterGL::setContext(GBAThread* context) {
|
void PainterGL::setContext(GBAThread* context) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ class PainterGL : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlag = QGLFormat::OpenGL_Version_1_1);
|
PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlags = QGLFormat::OpenGL_Version_1_1);
|
||||||
~PainterGL();
|
~PainterGL();
|
||||||
|
|
||||||
void setContext(GBAThread*);
|
void setContext(GBAThread*);
|
||||||
|
|
Loading…
Reference in New Issue