Pau*_*one 12
检测OpenGL版本
OpenGLInfoQOpenGLContext::openGLModuleType()glGetString(GL_VERSION)如果您想强制执行特定的 OpenGL 版本
QT_OPENGL为desktop或将应用程序属性设置为Qt::AA_UseDesktopOpenGLQT_OPENGL为angle或将应用程序属性设置为Qt::AA_UseOpenGLESQT_OPENGL为software或将应用程序属性设置为Qt::AA_UseSoftwareOpenGLconfigure设置您想要的 OpenGL 实现的选项创建 Qt 的静态构建(但请注意Qt 许可规则)
-opengl desktop-opengl选项;那是因为它是默认的-opengl dynamic让 Qt 选择最佳选项的方法。这是在 Qt 5.4 中引入的。如果您需要此选项但由于任何其他原因不需要静态构建,则无需创建静态构建,因为预构建的二进制文件自 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();
}
Run Code Online (Sandbox Code Playgroud)
(感谢peppe在上述评论中的初步回答,并感谢 user12345 提供博客链接)