There are several ways that Qt can use OpenGL: desktop (native), ANGLE, ES... and now there's 'dynamic' which can choose at runtime. Within an app, is there a way that you can detect which one is in use? Either within C++ or within QML?
e.g. something equivalent to the global declarations that let you detect OS
To detect the OpenGL version
OpenGLInfo
QOpenGLContext::openGLModuleType()
glGetString(GL_VERSION)
If you want to enforce a particular OpenGL version
QT_OPENGL
to desktop
or set the application attribute to Qt::AA_UseDesktopOpenGL
QT_OPENGL
to angle
or set the application attribute to Qt::AA_UseOpenGLES
QT_OPENGL
to software
or set the application attribute to Qt::AA_UseSoftwareOpenGL
configure
options to set the implementation of OpenGL you want (but be mindful of the Qt licensing rules)
-opengl desktop
-opengl
option; that's because it is the default-opengl dynamic
which lets Qt choose the best option. This was introduced in Qt 5.4. If you want this option but don't need a static build for any other reason, there's no need to create a static build, as the prebuilt binaries use this option since Qt 5.5.#include <QGuiApplication>
//...
int main(int argc, char *argv[])
{
// Set the OpenGL type before instantiating the application
// In this example, we're forcing use of ANGLE.
// Do either one of the following (not both). They are equivalent.
qputenv("QT_OPENGL", "angle");
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
// Now instantiate the app
QGuiApplication app(argc, argv);
//...
return app.exec();
}
(thanks to peppe for the initial answers in the comments above and thanks to user12345 for the Blog link)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With