检查 Qt 在运行时使用哪个 OpenGL 引擎进行发布版本

Sim*_*rta 6 windows opengl qt qtquick2 qt5.6

在 QML 应用程序中,有 3 种渲染类型

  • 原生 OpenGL:“桌面”
  • 角度 Direct3D:“角度”
  • 软件渲染器:“软件”

我们使用支持类型的自动加载机制。

如何以编程方式确定在运行时使用哪种渲染类型?

我知道QT_LOGGING_RULES=qt.qpa.gl=true但这会产生大量噪音和调试消息,这些消息不会记录在我们的发布版本中。还有另一种简单的方法来获取渲染类型吗?

Sim*_*rta 3

感谢@peppe 和一些额外的研究:

// this connection must be established before show() is called
QObject::connect(window, &QQuickWindow::sceneGraphInitialized,
                 [=] () -> void {
    auto context = window->openglContext();
    auto functions = context->functions();
    const std::string vendor = reinterpret_cast<const char*>(functions->glGetString(GL_VENDOR));
    const std::string renderer = reinterpret_cast<const char*>(functions->glGetString(GL_RENDERER));
    const std::string version = reinterpret_cast<const char*>(functions->glGetString(GL_VERSION));
    qDebug() << "OpenGL vendor: " << vendor << " "
             << "renderer: " << renderer << " "
             << "version: " << version;
});
Run Code Online (Sandbox Code Playgroud)

window我的主要 QQuickWindow* 在哪里。