From c9466116894715a2343f43a0b6aa22602d89262e Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 24 May 2021 20:35:27 +0400 Subject: [PATCH] Improve OpenGL logging. --- ui/gl/gl_detection.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/ui/gl/gl_detection.cpp b/ui/gl/gl_detection.cpp index 86aed49..d6caf7d 100644 --- a/ui/gl/gl_detection.cpp +++ b/ui/gl/gl_detection.cpp @@ -14,7 +14,7 @@ #include #include -#define LOG_ONCE(x) static auto logged = [&] { LOG(x); return true; }; +#define LOG_ONCE(x) static auto logged = [&] { LOG(x); return true; }(); namespace Ui::GL { namespace { @@ -64,11 +64,28 @@ Capabilities CheckCapabilities(QWidget *widget) { return {}; } const auto supported = context->format(); - if (supported.profile() == QSurfaceFormat::NoProfile) { - LOG_ONCE(("OpenGL: NoProfile received in final format.")); + switch (supported.profile()) { + case QSurfaceFormat::NoProfile: { + LOG_ONCE(("OpenGL Profile: None.")); return {}; + } break; + case QSurfaceFormat::CoreProfile: { + LOG_ONCE(("OpenGL Profile: Core.")); + } break; + case QSurfaceFormat::CompatibilityProfile: { + LOG_ONCE(("OpenGL Profile: Compatibility.")); + } break; } static const auto extensionsLogged = [&] { + const auto renderer = reinterpret_cast( + functions->glGetString(GL_RENDERER)); + LOG(("OpenGL Renderer: %1").arg(renderer ? renderer : "[nullptr]")); + const auto vendor = reinterpret_cast( + functions->glGetString(GL_VENDOR)); + LOG(("OpenGL Vendor: %1").arg(vendor ? vendor : "[nullptr]")); + const auto version = reinterpret_cast( + functions->glGetString(GL_VERSION)); + LOG(("OpenGL Version: %1").arg(version ? version : "[nullptr]")); auto list = QStringList(); for (const auto extension : context->extensions()) { list.append(QString::fromLatin1(extension));