From b3876ee9345fbf2d87fe51cc96cde4b1fc76c0b7 Mon Sep 17 00:00:00 2001 From: ts-korhonen Date: Thu, 23 Dec 2021 20:31:51 +0200 Subject: [PATCH] qt: create opengl context on hardware renderer Prevent OpenGLES renderer crashing on windows --- src/qt/qt_hardwarerenderer.cpp | 2 ++ src/qt/qt_hardwarerenderer.hpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/qt/qt_hardwarerenderer.cpp b/src/qt/qt_hardwarerenderer.cpp index 4c491495f..ec0f71f3a 100644 --- a/src/qt/qt_hardwarerenderer.cpp +++ b/src/qt/qt_hardwarerenderer.cpp @@ -14,6 +14,7 @@ void HardwareRenderer::resizeGL(int w, int h) void HardwareRenderer::initializeGL() { + m_context->makeCurrent(this); initializeOpenGLFunctions(); } @@ -44,6 +45,7 @@ void HardwareRenderer::onBlit(const std::unique_ptr* img, int x, int y, void HardwareRenderer::resizeEvent(QResizeEvent *event) { onResize(width(), height()); + QOpenGLWindow::resizeEvent(event); } diff --git a/src/qt/qt_hardwarerenderer.hpp b/src/qt/qt_hardwarerenderer.hpp index 3c8fb3110..d2152def5 100644 --- a/src/qt/qt_hardwarerenderer.hpp +++ b/src/qt/qt_hardwarerenderer.hpp @@ -24,6 +24,7 @@ class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, publi private: bool wayland = false; QWidget* parentWidget{nullptr}; + QOpenGLContext* m_context; public: void resizeGL(int w, int h) override; void initializeGL() override; @@ -34,6 +35,9 @@ public: setMinimumSize(QSize(16, 16)); setFlags(Qt::FramelessWindowHint); parentWidget = parent; + + m_context = new QOpenGLContext(); + m_context->create(); } ~HardwareRenderer() {