all repos — mgba @ 48162e75e741743428fcbe6feca0f2f383da9806

mGBA Game Boy Advance Emulator

Qt: Fix forcing 1.x when getting a 2/3 backwards-compatible context
Vicki Pfau vi@endrift.com
Wed, 26 Jun 2019 15:39:18 -0700
commit

48162e75e741743428fcbe6feca0f2f383da9806

parent

042a77a932d2d2f2d7606df365c6ed8eb87b69f6

2 files changed, 10 insertions(+), 4 deletions(-)

jump to
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -50,14 +50,20 @@ #endif

auto version = m_gl->format().version(); QStringList extensions = QString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))).split(' '); + int forceVersion = 0; + if (format.majorVersion() < 2) { + forceVersion = 1; + } + if ((version == qMakePair(2, 1) && !extensions.contains("GL_ARB_framebuffer_object")) || version == qMakePair(2, 0)) { QSurfaceFormat newFormat(format); newFormat.setVersion(1, 4); + forceVersion = 1; m_gl->setFormat(newFormat); m_gl->create(); } - m_painter = new PainterGL(windowHandle(), m_gl); + m_painter = new PainterGL(windowHandle(), m_gl, forceVersion); setUpdatesEnabled(false); // Prevent paint events, which can cause race conditions }

@@ -230,7 +236,7 @@ int DisplayGL::framebufferHandle() {

return m_painter->glTex(); } -PainterGL::PainterGL(QWindow* surface, QOpenGLContext* parent) +PainterGL::PainterGL(QWindow* surface, QOpenGLContext* parent, int forceVersion) : m_gl(parent) , m_surface(surface) {

@@ -250,7 +256,7 @@

#ifdef BUILD_GLES2 auto version = m_gl->format().version(); QStringList extensions = QString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))).split(' '); - if ((version == qMakePair(2, 1) && extensions.contains("GL_ARB_framebuffer_object")) || version.first > 2) { + if (forceVersion != 1 && ((version == qMakePair(2, 1) && extensions.contains("GL_ARB_framebuffer_object")) || version.first > 2)) { gl2Backend = static_cast<mGLES2Context*>(malloc(sizeof(mGLES2Context))); mGLES2ContextCreate(gl2Backend); m_backend = &gl2Backend->d;
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -77,7 +77,7 @@ class PainterGL : public QObject {

Q_OBJECT public: - PainterGL(QWindow* surface, QOpenGLContext* parent); + PainterGL(QWindow* surface, QOpenGLContext* parent, int forceVersion = 0); ~PainterGL(); void setContext(std::shared_ptr<CoreController>);