Search code examples
windowsqtopenglqtquick2qt5.6

Check which OpenGL engine is used by Qt at runtime for release builds


In QML applications there are 3 rendering types:

  • Native OpenGL: "desktop"
  • ANGLE Direct3D: "angle"
  • A software renderer: "software"

We use the automatic loading mechanism of the supported type.

How can I programmatically determine which rendering type is used at runtime?

I know of QT_LOGGING_RULES=qt.qpa.gl=true but this produces a lot of noise and DEBUG messages, which are not logged in our release build. Is there another simple way to just get the rendering type?


Solution

  • Got it thanks to @peppe and some additional research:

    // 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;
    });
    

    where window is my main QQuickWindow*.