qt: create opengl context on hardware renderer

Prevent OpenGLES renderer crashing on windows
This commit is contained in:
ts-korhonen
2021-12-23 20:31:51 +02:00
parent 4002149d4d
commit b3876ee934
2 changed files with 6 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ void HardwareRenderer::resizeGL(int w, int h)
void HardwareRenderer::initializeGL() void HardwareRenderer::initializeGL()
{ {
m_context->makeCurrent(this);
initializeOpenGLFunctions(); initializeOpenGLFunctions();
} }
@@ -44,6 +45,7 @@ void HardwareRenderer::onBlit(const std::unique_ptr<uint8_t>* img, int x, int y,
void HardwareRenderer::resizeEvent(QResizeEvent *event) { void HardwareRenderer::resizeEvent(QResizeEvent *event) {
onResize(width(), height()); onResize(width(), height());
QOpenGLWindow::resizeEvent(event); QOpenGLWindow::resizeEvent(event);
} }

View File

@@ -24,6 +24,7 @@ class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, publi
private: private:
bool wayland = false; bool wayland = false;
QWidget* parentWidget{nullptr}; QWidget* parentWidget{nullptr};
QOpenGLContext* m_context;
public: public:
void resizeGL(int w, int h) override; void resizeGL(int w, int h) override;
void initializeGL() override; void initializeGL() override;
@@ -34,6 +35,9 @@ public:
setMinimumSize(QSize(16, 16)); setMinimumSize(QSize(16, 16));
setFlags(Qt::FramelessWindowHint); setFlags(Qt::FramelessWindowHint);
parentWidget = parent; parentWidget = parent;
m_context = new QOpenGLContext();
m_context->create();
} }
~HardwareRenderer() ~HardwareRenderer()
{ {