简体   繁体   中英

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.

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

4.1 INTEL-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.

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

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. Now on MacOSX, you won't get that, because Apple doesn't expose any compatibility profiles. But they could have.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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