Tue, 28 Jun 2022 19:21:37 +0300
Add OpenGL information to about page
src/about.ui | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions |
--- a/src/about.ui Tue Jun 28 18:02:51 2022 +0300 +++ b/src/about.ui Tue Jun 28 19:21:37 2022 +0300 @@ -36,11 +36,18 @@ </style></head><body style=" font-family:'EPSONEXT 丸ã´ã·ãã¯ä½ï¼'; font-size:11pt; font-weight:400; font-style:normal;"> <h1 style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/icons/appicon.png" height="64" /><span style=" font-size:xx-large; font-weight:600;"> %APPNAME% %VERSION%</span></h1> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt version: %QTVERSION%</p> +<hr /> +<h2 style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:x-large; font-weight:600;">Build time information</span></h2> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The following information was gathered during the build of this program.</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">%GLMVERSIONSTRING%</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Build type: %BUILDTYPE%</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Compiler: %COMPILER_ID% %COMPILER_VERSION%</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Compiler system: %COMPILER_SYSTEM% (%COMPILER_CPU%)</p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Compiler flags: %COMPILER_FLAGS%</p></body></html></string> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Compiler flags: %COMPILER_FLAGS%</p> +<hr /> +<h2 style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:x-large; font-weight:600;">OpenGL information</span></h2> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">OpenGL version: %GL_VERSION%</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">OpenGL Extensions: %GL_EXTENSIONS%</p></body></html></string> </property> </widget> </item>
--- a/src/main.cpp Tue Jun 28 18:02:51 2022 +0300 +++ b/src/main.cpp Tue Jun 28 19:21:37 2022 +0300 @@ -20,6 +20,7 @@ #include "src/ui/objecteditor.h" #include "src/version.h" #include "src/widgets/colorselectdialog.h" +#include <GL/glew.h> static const QDir LOCALE_DIR {":/locale"}; @@ -380,6 +381,17 @@ QDialog dialog{parent}; Ui_About ui; ui.setupUi(&dialog); + const char* glVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION)); + const QString extensions = []{ + GLint numExtensions; + glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + QStringList extensionsList; + for (GLint i = 0; i < numExtensions; i++) { + const GLubyte* ext = glGetStringi(GL_EXTENSIONS, i); + extensionsList.push_back(reinterpret_cast<const char*>(ext)); + } + return extensionsList.join(" "); + }(); for (QTextBrowser* browser : dialog.findChildren<QTextBrowser*>()) { browser->setHtml( browser->toHtml() @@ -395,6 +407,8 @@ .replace("%COMPILER_CPU%", CMAKE_SYSTEM_PROCESSOR) .replace("%COMPILER_SYSTEM%", CMAKE_SYSTEM) .replace("%GLMVERSIONSTRING%", GLM_VERSION_MESSAGE) + .replace("%GL_VERSION%", glVersion) + .replace("%GL_EXTENSIONS%", extensions) ); } dialog.setWindowTitle(QObject::tr("About %1").arg(CMAKE_PROJECT_NAME)); @@ -775,7 +789,14 @@ QObject::connect( ui.actionAbout, &QAction::triggered, - [&mainWindow]{about(&mainWindow);} + [&mainWindow, &ui]{ + // Make sure that there's an OpenGL context active, otherwise + // we cannot obtain OpenGL information + if (ui.mdiArea->findChildren<ModelSubWindow*>().empty()) { + ui.actionNew->trigger(); + } + about(&mainWindow); + } ); mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock); mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>());