是由这里获取版本号的,版本号的存放方式为int version = 0; //! majorVersion<<8 + minorVersion,利用两个字节存放
qtbase\src\plugins\platforms\windows\qwindowsglcontext.cpp
QWindowsOpenGLContextFormat QWindowsOpenGLContextFormat::current()
{
QWindowsOpenGLContextFormat result;
const QByteArray version = QOpenGLStaticContext::getGlString(GL_VERSION);
int major, minor;
if (QPlatformOpenGLContext::parseOpenGLVersion(version, major, minor))
result.version = (major << 8) + minor;
else
result.version = 0x0200;
result.profile = QSurfaceFormat::NoProfile;
if (result.version < 0x0300) {
result.options |= QSurfaceFormat::DeprecatedFunctions;
return result;
}
// v3 onwards
GLint value = 0;
QOpenGLStaticContext::opengl32.glGetIntegerv(GL_CONTEXT_FLAGS, &value);
if (!(value & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT))
result.options |= QSurfaceFormat::DeprecatedFunctions;
if (value & GL_CONTEXT_FLAG_DEBUG_BIT)
result.options |= QSurfaceFormat::DebugContext;
value = 0;
QOpenGLStaticContext::opengl32.glGetIntegerv(RESET_NOTIFICATION_STRATEGY_ARB, &value);
if (value == LOSE_CONTEXT_ON_RESET_ARB)
result.options |= QSurfaceFormat::ResetNotification;
if (result.version < 0x0302)
return result;
// v3.2 onwards: Profiles
value = 0;
QOpenGLStaticContext::opengl32.glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &value);
if (value & GL_CONTEXT_CORE_PROFILE_BIT)
result.profile = QSurfaceFormat::CoreProfile;
else if (value & GL