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

1

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?

Volumed answered 31/3, 2016 at 10:56 Comment(4)
With "software" do you mean through a software OpenGL renderer like Mesa's llvmpipe, or the 2D renderer of Qt Quick?Transpontine
@Transpontine Mesa's llvmpipe via the shipped opengl32sw.dllVolumed
Then can you just check GL_VENDOR, GL_VERSION etc.? You'll get ANGLE, Mesa, etc.Transpontine
@Transpontine How do I do that? glGetString(GL_VENDOR) gives me null (on Linux).Volumed
V
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*.

Volumed answered 31/3, 2016 at 14:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.