+ attribs.major = majorVersion;
+ attribs.minor = minorVersion;
+ if (contextFlags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
+ if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+
+ switch (profileMask) {
+ case WGL_CONTEXT_CORE_PROFILE_BIT_ARB:
+ /* There are no profiles before OpenGL 3.2. The
+ * WGL_ARB_create_context_profile spec says:
+ *
+ * "If the requested OpenGL version is less than 3.2,
+ * WGL_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
+ * of the context is determined solely by the requested version."
+ */
+ if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 2)) {
+ attribs.profile = ST_PROFILE_OPENGL_CORE;
+ break;
+ }
+ /* fall-through */
+ case WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
+ /*
+ * The spec also says:
+ *
+ * "If version 3.1 is requested, the context returned may implement
+ * any of the following versions:
+ *
+ * * Version 3.1. The GL_ARB_compatibility extension may or may not
+ * be implemented, as determined by the implementation.
+ * * The core profile of version 3.2 or greater."
+ *
+ * But Mesa doesn't support GL_ARB_compatibility, while most prevalent
+ * Windows OpenGL implementations do, and unfortunately many Windows
+ * applications don't check whether they receive or not a context with
+ * GL_ARB_compatibility, so returning a core profile here does more harm
+ * than good.
+ */
+ attribs.profile = ST_PROFILE_DEFAULT;
+ break;
+ case WGL_CONTEXT_ES_PROFILE_BIT_EXT:
+ if (majorVersion >= 2) {
+ attribs.profile = ST_PROFILE_OPENGL_ES2;
+ } else {
+ attribs.profile = ST_PROFILE_OPENGL_ES1;
+ }
+ break;
+ default:
+ assert(0);
+ goto no_st_ctx;
+ }