src/main.cpp

changeset 293
9f85a54ead29
parent 292
f071ec94c022
child 296
38f6fad61bad
--- 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>());

mercurial