From bb3bc6e527d95834bd1da769f7ea528cff6aba4b Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 13 Dec 2021 10:23:05 +0000 Subject: [PATCH] Display OpenGL version in status bar. Displayed in red if less than version 3. --- app/main.cpp | 1 + sdrgui/mainwindow.cpp | 33 +++++++++++++++++++++++++++++++-- sdrgui/mainwindow.h | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 32e1a2f70..943c2a9b7 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -40,6 +40,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); // Needed for WebGL in QWebEngineView and MainWindow::openGLVersion #endif QApplication a(argc, argv); diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index 18a4ce2ba..91fe3cf2f 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -865,14 +865,43 @@ void MainWindow::saveCommandSettings() { } +QString MainWindow::openGLVersion() +{ + QOpenGLContext *glCurrentContext = QOpenGLContext::globalShareContext(); + if (glCurrentContext) + { + if (glCurrentContext->isValid()) + { + int major = glCurrentContext->format().majorVersion(); + int minor = glCurrentContext->format().minorVersion(); + bool es = glCurrentContext->isOpenGLES(); + QString version = QString("%1.%2%3").arg(major).arg(minor).arg(es ? " ES" : ""); + // Waterfall doesn't work if major version is less than 3, so display in red + if (major < 3) { + version = "" + version + ""; + } + return version; + } + else + { + return "N/A"; + } + } + else + { + return "N/A"; + } +} + void MainWindow::createStatusBar() { QString qtVersionStr = QString("Qt %1 ").arg(QT_VERSION_STR); + QString openGLVersionStr = QString("OpenGL %1 ").arg(openGLVersion()); #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) - m_showSystemWidget = new QLabel("SDRangel " + qApp->applicationVersion() + " " + qtVersionStr + m_showSystemWidget = new QLabel("SDRangel " + qApp->applicationVersion() + " " + qtVersionStr + openGLVersionStr + QSysInfo::currentCpuArchitecture() + " " + QSysInfo::prettyProductName(), this); #else - m_showSystemWidget = new QLabel("SDRangel " + qApp->applicationVersion() + " " + qtVersionStr, this); + m_showSystemWidget = new QLabel("SDRangel " + qApp->applicationVersion() + " " + qtVersionStr + openGLVersionStr, this); #endif statusBar()->addPermanentWidget(m_showSystemWidget); diff --git a/sdrgui/mainwindow.h b/sdrgui/mainwindow.h index 725d6a147..a0ca9bc6c 100644 --- a/sdrgui/mainwindow.h +++ b/sdrgui/mainwindow.h @@ -129,6 +129,7 @@ private: void saveFeatureSetPresetSettings(FeatureSetPreset* preset, int featureSetIndex); void saveCommandSettings(); + QString openGLVersion(); void createStatusBar(); void closeEvent(QCloseEvent*); void updatePresetControls();