From ba450ee55430c9f293625aa53fd8e10115c61765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Mon, 25 Apr 2022 12:00:34 +0200 Subject: [PATCH] Error message when OpenGL can't be intialized --- imagescrollareagl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imagescrollareagl.cpp b/imagescrollareagl.cpp index 7c7bff1..d27aa71 100644 --- a/imagescrollareagl.cpp +++ b/imagescrollareagl.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include struct RawImageType { @@ -62,6 +64,13 @@ ImageWidget::ImageWidget(QWidget *parent) : QOpenGLWidget(parent) m_updateTimer->setSingleShot(true); connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(update())); setAcceptDrops(true); + QTimer::singleShot(1000, [this](){ + if(!isValid()) + { + QMessageBox::critical(this, tr("OpenGL error"), tr("Could not initialize OpenGL 3.3 context. Ensure that proper GPU driver is installed.")); + QCoreApplication::exit(-1); + } + }); } ImageWidget::~ImageWidget() @@ -258,6 +267,9 @@ void ImageWidget::initializeGL() f->glClearColor(0.5f, 0.5f, 0.5f, 1.0f); f3 = context()->versionFunctions(); + if(f3 == nullptr) + QMessageBox::critical(this, tr("OpenGL error"), tr("Could not initialize OpenGL 3.3 context. Ensure that proper GPU driver is installed.")); + m_vao = std::unique_ptr(new QOpenGLVertexArrayObject); m_vaoThumb = std::unique_ptr(new QOpenGLVertexArrayObject); m_vao->create();