简体   繁体   English

在Mac El Capitan(OSX 10.11)上设置Qt 5.7 OpenGL版本

[英]Setting Qt 5.7 OpenGL version on Mac El Capitan (OSX 10.11)

I am trying to set the OpenGL version for my QOpenGLWidget to 3.3 using the following code. 我正在尝试使用以下代码将QOpenGLWidget的OpenGL版本设置为3.3。

QSurfaceFormat defaultFormat;
defaultFormat.setProfile(QSurfaceFormat::CoreProfile);
defaultFormat.setVersion(3, 3);
defaultFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
QSurfaceFormat::setDefaultFormat(defaultFormat);
QApplication a(argc, argv);

The problem is when I later call glGetString(GL_VERSION) I get 问题是当我稍后调用glGetString(GL_VERSION)我得到了

4.1 INTEL-10.14.73 4.1英特尔-10.14.73

as output. 作为输出。 Should this be happening? 这应该发生吗? It seems I can either use 2.1 or 4.1, and Qt won't allow me to use anything in between. 看来我可以使用2.1或4.1,并且Qt不允许我在两者之间使用任何东西。

Yes, that is normal. 是的,那很正常。 And perfectly valid. 并且完全有效。

With the exception of the 3.2 core profile break , every higher OpenGL version is backwards compatible with a lower one. 除了3.2核心配置文件中断外 ,每个更高的OpenGL版本都向后兼容一个较低的版本。 As such, if you ask for 3.3, an implementation is free to give you 4.1, since 4.1 does everything that 3.3 does. 这样,如果您要求3.3,则实现可以自由地给您4.1,因为4.1可以完成3.3的所有工作。

Indeed, if you ask for 2.1, an implementation is allowed to give you 4.1 compatibility profile, since that is backwards compatible with 2.1. 确实,如果您要求使用2.1,则允许实现为您提供4.1 兼容性配置文件,因为该配置文件向后兼容2.1。 Now on MacOSX, you won't get that, because Apple doesn't expose any compatibility profiles. 现在在MacOSX上,您将无法获得,因为Apple并未公开任何兼容性配置文件。 But they could have. 但是他们可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM