4

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

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

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

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

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

4

1 回答 1

4

感谢@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;
});

window我的主要 QQuickWindow*在哪里。

于 2016-03-31T14:42:17.117 回答