mirror of https://github.com/mgba-emu/mgba.git
Qt: Simplify OpenGL context creation
This commit is contained in:
parent
6f8b4114fc
commit
f95be3071a
1
CHANGES
1
CHANGES
|
@ -18,6 +18,7 @@ Misc:
|
||||||
- OpenGL: Add texSize uniform
|
- OpenGL: Add texSize uniform
|
||||||
- ARM7: Clean up instruction decoding for future expandability
|
- ARM7: Clean up instruction decoding for future expandability
|
||||||
- Qt: Make -g flag work in Qt build
|
- Qt: Make -g flag work in Qt build
|
||||||
|
- Qt: Simplify OpenGL context creation
|
||||||
|
|
||||||
0.4.1: (2016-07-11)
|
0.4.1: (2016-07-11)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -29,11 +29,13 @@ Display* Display::create(QWidget* parent) {
|
||||||
switch (s_driver) {
|
switch (s_driver) {
|
||||||
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
|
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
|
||||||
case Driver::OPENGL:
|
case Driver::OPENGL:
|
||||||
return new DisplayGL(format, false, parent);
|
format.setVersion(3, 0);
|
||||||
|
return new DisplayGL(format, parent);
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_GL
|
#ifdef BUILD_GL
|
||||||
case Driver::OPENGL1:
|
case Driver::OPENGL1:
|
||||||
return new DisplayGL(format, true, parent);
|
format.setVersion(1, 4);
|
||||||
|
return new DisplayGL(format, parent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case Driver::QT:
|
case Driver::QT:
|
||||||
|
@ -41,7 +43,8 @@ Display* Display::create(QWidget* parent) {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
|
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
|
||||||
return new DisplayGL(format, false, parent);
|
format.setVersion(3, 0);
|
||||||
|
return new DisplayGL(format, parent);
|
||||||
#else
|
#else
|
||||||
return new DisplayQt(parent);
|
return new DisplayQt(parent);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,22 +24,14 @@ extern "C" {
|
||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
|
||||||
DisplayGL::DisplayGL(const QGLFormat& format, bool force1, QWidget* parent)
|
DisplayGL::DisplayGL(const QGLFormat& format, 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)
|
||||||
{
|
{
|
||||||
QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags();
|
m_painter = new PainterGL(format.majorVersion(), m_gl);
|
||||||
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?
|
||||||
}
|
}
|
||||||
|
@ -179,7 +171,7 @@ void DisplayGL::resizePainter() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PainterGL::PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlags glVersion)
|
PainterGL::PainterGL(int majorVersion, QGLWidget* parent)
|
||||||
: m_gl(parent)
|
: m_gl(parent)
|
||||||
, m_active(false)
|
, m_active(false)
|
||||||
, m_started(false)
|
, m_started(false)
|
||||||
|
@ -196,7 +188,7 @@ PainterGL::PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlags glVersion)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_WIN32) || defined(USE_EPOXY)
|
#if !defined(_WIN32) || defined(USE_EPOXY)
|
||||||
if (glVersion & (QGLFormat::OpenGL_Version_3_0 | QGLFormat::OpenGL_ES_Version_2_0)) {
|
if (majorVersion >= 2) {
|
||||||
gl2Backend = new mGLES2Context;
|
gl2Backend = new mGLES2Context;
|
||||||
mGLES2ContextCreate(gl2Backend);
|
mGLES2ContextCreate(gl2Backend);
|
||||||
m_backend = &gl2Backend->d;
|
m_backend = &gl2Backend->d;
|
||||||
|
|
|
@ -43,7 +43,7 @@ class DisplayGL : public Display {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DisplayGL(const QGLFormat& format, bool force1 = false, QWidget* parent = nullptr);
|
DisplayGL(const QGLFormat& format, QWidget* parent = nullptr);
|
||||||
~DisplayGL();
|
~DisplayGL();
|
||||||
|
|
||||||
bool isDrawing() const override { return m_isDrawing; }
|
bool isDrawing() const override { return m_isDrawing; }
|
||||||
|
@ -80,7 +80,7 @@ class PainterGL : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlags = QGLFormat::OpenGL_Version_1_1);
|
PainterGL(int majorVersion, QGLWidget* parent);
|
||||||
~PainterGL();
|
~PainterGL();
|
||||||
|
|
||||||
void setContext(mCoreThread*);
|
void setContext(mCoreThread*);
|
||||||
|
|
Loading…
Reference in New Issue