【问题标题】:Check which OpenGL engine is used by Qt at runtime for release builds检查 Qt 在运行时使用哪个 OpenGL 引擎进行发布构建
【发布时间】:2016-07-19 18:56:08
【问题描述】:

在 QML 应用程序中 there are 3 rendering types:

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

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

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

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

【问题讨论】:

  • “软件”是指通过像 Mesa 的 llvmpipe 这样的软件 OpenGL 渲染器,还是 Qt Quick 的 2D 渲染器?
  • @peppe Mesa 的 llvmpipe 通过随附的 opengl32sw.dll
  • 那你能检查一下GL_VENDORGL_VERSION等吗?您将获得 ANGLE、Mesa 等。
  • @peppe 我该怎么做? glGetString(GL_VENDOR) 给了我null(在 Linux 上)。

标签: windows qt opengl qtquick2 qt5.6


【解决方案1】:

感谢@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*。

【讨论】:

    猜你喜欢
    • 2012-09-06
    • 2012-07-27
    • 1970-01-01
    • 2016-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多