Opened 5 years ago
Last modified 5 years ago
#3626 assigned enhancement
Use highest OpenGL version available
Reported by: | Tom Goddard | Owned by: | Tom Goddard |
---|---|---|---|
Priority: | moderate | Milestone: | |
Component: | Graphics | Version: | |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Notify when closed: | Platform: | all | |
Project: | ChimeraX |
Description
It would be nice if ChimeraX created OpenGL contexts with the highest OpenGL version core profile offered by the driver. We currently require at least OpenGL 3.3. But future enhancements that require more recent OpenGL versions could be offered optionally if the driver allows them.
On macOS ChimeraX requests through Qt an OpenGL context version 3.3 but we get back a 4.1 context, the highest available. On Windows we request 3.3 and get 3.3 even though 4.6 is available on two tested Windows machines. Leaving out the QSurfaceFormat.setVersion(3,3) call on Windows causes ChimeraX to say it could not get a core profile context even though version 4.6 core and 4.6 compatibility are the highest available and we specifically request a core profile. This appears to be a bug in Qt. I did not see any way to ask what the highest available version is. So it looks like the Qt bug and API doesn't offer a way to get the highest core profile version. We could try to hack around this as follows. As for a context without specifying a version. That currently returns a non-core context with version 4.6. So try again and specify version 4.6. That works at least on the two Windows machines tested. If that were to fail we could make a third try requesting a version 3.3 context as we do now.
Change History (2)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Qt docs for QSurfaceFormat.setProfile() say "This setting is ignored if the requested OpenGL version is less than 3.2." So apparently if no version is specified it is also ignored. Looking at the QSurfaceFormat source code shows the default version requested is 2.0. There is an api to request a major version. What if I request major version 4? On Mac I get 4.1. On Windows I get 4.0.
Looking at how an OpenGL context is creates on Windows
https://www.khronos.org/opengl/wiki/Creating_an_OpenGL_Context_(WGL)
explains that the problem is really OpenGL not Qt. OpenGL post 3.0 decided to allow deprecating and removing features. So you don't necessarily want the highest version since it may have removed features you need. So the API forces you to request a specific version and it returns to you a version guaranteed to have all the features of that version (possibly a newer version if no deprecated stuff was removed).
The bad design of OpenGL knows no limits. In practice I still want the OpenGL 4.6 profile as I suspect nothing has been deprecated and removed. But it looks like the only way to get it is to request it, have it fail, then request a lower version and just keep on going until you get something.
On macOS, not requesting a version but requesting a core profile gives version 2.1 non-core profile. Should report a Qt bug that if a core profile is requested but no version specified then it gives a non-core profile even when core profiles are available and have higher versions than no-core profiles.