From df6ae1883cc7d4d67a21fba2f8eaff6644bd152d Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 26 Jan 2023 05:57:08 -0800 Subject: [PATCH] Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes #2794) --- CHANGES | 2 ++ src/platform/qt/DisplayGL.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index ec1e9eab4..414a980e1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ 0.10.2: (Future) Emulation fixes: - GBA Memory: Make VRAM access stalls only apply to BG RAM +Other fixes: + - Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794) 0.10.1: (2023-01-10) Emulation fixes: diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index 7a4f73858..469b7e315 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -513,10 +513,10 @@ void PainterGL::create() { #if defined(BUILD_GLES2) || defined(BUILD_GLES3) if (m_supportsShaders) { - QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions(); gl2Backend = static_cast(malloc(sizeof(mGLES2Context))); mGLES2ContextCreate(gl2Backend); m_backend = &gl2Backend->d; + QOpenGLFunctions* fn = m_gl->functions(); fn->glGenTextures(m_bridgeTexes.size(), m_bridgeTexes.data()); for (auto tex : m_bridgeTexes) { m_freeTex.enqueue(tex); @@ -543,7 +543,7 @@ void PainterGL::create() { #if defined(BUILD_GLES2) || defined(BUILD_GLES3) mGLES2Context* gl2Backend = reinterpret_cast(painter->m_backend); if (painter->m_widget && painter->supportsShaders()) { - QOpenGLFunctions_Baseline* fn = painter->m_gl->versionFunctions(); + QOpenGLFunctions* fn = painter->m_gl->functions(); fn->glFinish(); painter->m_widget->setTex(painter->m_finalTex[painter->m_finalTexIdx]); painter->m_finalTexIdx ^= 1; @@ -589,7 +589,7 @@ void PainterGL::destroy() { } makeCurrent(); #if defined(BUILD_GLES2) || defined(BUILD_GLES3) - QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions(); + QOpenGLFunctions* fn = m_gl->functions(); if (m_shader.passes) { mGLES2ShaderFree(&m_shader); } @@ -680,7 +680,7 @@ void PainterGL::start() { if (glContextHasBug(OpenGLBug::GLTHREAD_BLOCKS_SWAP)) { // Suggested on Discord as a way to strongly hint that glthread should be disabled // See https://gitlab.freedesktop.org/mesa/mesa/-/issues/8035 - QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions(); + QOpenGLFunctions* fn = m_gl->functions(); fn->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); } #endif @@ -972,7 +972,7 @@ QOpenGLContext* PainterGL::shareContext() { } void PainterGL::updateFramebufferHandle() { - QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions(); + QOpenGLFunctions* fn = m_gl->functions(); // TODO: Figure out why glFlush doesn't work here on Intel/Windows if (glContextHasBug(OpenGLBug::CROSS_THREAD_FLUSH)) { fn->glFinish();