Nominate our 2022 Qt Champions!

OpenGL Dynamic selected driver

  • Hello,
    is there a way to detect the current opengl implementation used between desktop , angle, software?
    I see a way to force the selection (using attributes), but not a direct way to detected the selected implementation.

    I would like to detect if I'm using desktop opengl because I need to workaround the fullscreen + dialogs bug.

    Thank you

  • If you are using QCoreApplication or QApplication, you can testit like this

    @QCoreApplication a(argc,argv);//in main

    bool test = a.testAttribute(Qt::AA_UseDesktopOpenGL);

    //or somewhere else in the code:
    bool test = qApp->testAttribute(Qt::AA_UseDesktopOpenGL);

  • unfortunately that doesn't seem to work, as these flags are used to force the loading behavior, but when you read them they are always false (of course with a QML scene already loaded).

  • Strange, for me work(I don't use QML)... Which version of Qt do you have??
    using this piece of code it give me true on test:

    #include <QApplication>
    #include <QOpenGLWidget>
    int main(int argc, char *argv[])
    QApplication a(argc, argv);

    QSurfaceFormat fmt;
    fmt.setVersion(3, 2);


    bool test = a.testAttribute(Qt::AA_UseDesktopOpenGL);
    QOpenGLWidget w;;

    return a.exec();

    play with commenting , uncommenting the line with setAttribute, test give tru if the line is uncommented, false if is commented, as expected.

  • Query format() from the QOpenGLContext after create(). Then check renderableType() to differentiate between OpenGL and OpenGL ES (ANGLE).

    As for differentiating between (non-ANGLE) OpenGL implementations, it's more tricky since there's no difference from Qt's point of view. However, you can still query strings like GL_RENDERER and look for "llvmpipe".

    The example qtbase/examples/opengl/contextinfo may be a useful tool and reference for doing such checks.

Log in to reply