WGL: Fall-back to a 3.1 context if 3.2 context creation fails

This is an emergency fallback for older Intel drivers on Windows, which
do not support OpenGL 3.2. As we're creating 3.2 contexts mostly to
access the Core profile, which was not available in earlier versions,
falling back to 3.1 should be fine; I don't think we're using anything
specific to 3.2.
qteditor
Nicolas Hake 2016-06-27 01:08:28 +02:00
parent cc595ec58d
commit 9a45843828
2 changed files with 25 additions and 19 deletions

View File

@ -317,17 +317,6 @@ CStdGLCtx *CStdGL::CreateContext(C4Window * pWindow, C4AbstractApp *pApp)
const char *gl_version = reinterpret_cast<const char *>(glGetString(GL_VERSION));
LogF("GL %s on %s (%s)", gl_version ? gl_version : "", gl_renderer ? gl_renderer : "", gl_vendor ? gl_vendor : "");
// Our shader-based skinning doesn't work on some Intel devices.
// Those devices return an OpenGL 3.1 context even though we
// request a 3.2 one; in this case, do CPU-based skinning instead.
{
assert(gl_version != NULL);
int major, minor;
sscanf(gl_version, "%d.%d", &major, &minor);
if (major < 3 || (major == 3 && minor < 2))
Workarounds.ForceSoftwareTransform = true;
}
if (Config.Graphics.DebugOpenGL)
{
// Dump extension list

View File

@ -320,15 +320,32 @@ bool CStdGLCtx::Init(C4Window * pWindow, C4AbstractApp *pApp)
// create context
if (wglCreateContextAttribsARB)
{
const int attribs[] = {
WGL_CONTEXT_FLAGS_ARB, Config.Graphics.DebugOpenGL ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
WGL_CONTEXT_MAJOR_VERSION_ARB, REQUESTED_GL_CTX_MAJOR,
WGL_CONTEXT_MINOR_VERSION_ARB, REQUESTED_GL_CTX_MINOR,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0
};
{
const int attribs[] = {
WGL_CONTEXT_FLAGS_ARB, Config.Graphics.DebugOpenGL ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
WGL_CONTEXT_MAJOR_VERSION_ARB, REQUESTED_GL_CTX_MAJOR,
WGL_CONTEXT_MINOR_VERSION_ARB, REQUESTED_GL_CTX_MINOR,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0
};
hrc = wglCreateContextAttribsARB(hDC, 0, attribs);
hrc = wglCreateContextAttribsARB(hDC, 0, attribs);
}
if (!hrc)
{
LogSilentF(" gl: OpenGL %d.%d not available; falling back to 3.1 emergency context.", REQUESTED_GL_CTX_MAJOR, REQUESTED_GL_CTX_MINOR);
// Some older Intel drivers don't support OpenGL 3.2; we don't use (much?) of
// that so we'll request a 3.1 context as a fallback.
const int attribs[] = {
WGL_CONTEXT_FLAGS_ARB, Config.Graphics.DebugOpenGL ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
0
};
pGL->Workarounds.ForceSoftwareTransform = true;
hrc = wglCreateContextAttribsARB(hDC, 0, attribs);
}
}
else
{