6

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?

Simon Warta
  • 10,850
  • 5
  • 40
  • 78

1 Answers1

3

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*.

Simon Warta
  • 10,850
  • 5
  • 40
  • 78