Simon Warta
Simon Warta

Reputation: 11418

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

In QML applications there are 3 rendering types:

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?

Upvotes: 6

Views: 2413

Answers (1)

Simon Warta
Simon Warta

Reputation: 11418

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

Upvotes: 3

Related Questions