From 5e38964fbfed38efdcf5c1628ca65d7e3469764a Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 20 May 2021 16:07:19 +0400 Subject: [PATCH] Allow force-disabling OpenGL. --- ui/gl/gl_detection.cpp | 13 +++++++++++++ ui/gl/gl_detection.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/ui/gl/gl_detection.cpp b/ui/gl/gl_detection.cpp index 5e8797c..ce83b34 100644 --- a/ui/gl/gl_detection.cpp +++ b/ui/gl/gl_detection.cpp @@ -16,8 +16,17 @@ #define LOG_ONCE(x) static auto logged = [&] { LOG(x); return true; }; namespace Ui::GL { +namespace { + +bool ForceDisabled/* = false*/; + +} // namespace Capabilities CheckCapabilities(QWidget *widget) { + if (ForceDisabled) { + LOG_ONCE(("OpenGL: Force-disabled.")); + return {}; + } auto format = QSurfaceFormat(); format.setAlphaBufferSize(8); if (widget) { @@ -73,4 +82,8 @@ Capabilities CheckCapabilities(QWidget *widget) { return result; } +void ForceDisable(bool disable) { + ForceDisabled = disable; +} + } // namespace Ui::GL diff --git a/ui/gl/gl_detection.h b/ui/gl/gl_detection.h index 1001e47..a9a55a5 100644 --- a/ui/gl/gl_detection.h +++ b/ui/gl/gl_detection.h @@ -17,4 +17,6 @@ struct Capabilities { [[nodiscard]] Capabilities CheckCapabilities(QWidget *widget = nullptr); +void ForceDisable(bool disable); + } // namespace Ui::GL