GLX: Avoid exiting if glXCreateContextAttribsARB fails

It's not clear that the glXCreateNewContext fallback does anyone any good
because it can't create the Core Profile Context we need, but better a
fallback message followed by Shader compilation errors than an obscure
X11 protocoll error. Probably.
epoxy
Günther Brammer 2016-01-29 17:06:58 +01:00
parent fd534c430e
commit 5e5d8dd49a
1 changed files with 10 additions and 3 deletions

View File

@ -464,6 +464,11 @@ void CStdGLCtx::Clear(bool multisample_change)
}
}
static int GLXErrorHandler(Display * dpy, XErrorEvent * ev)
{
return 0;
}
bool CStdGLCtx::Init(C4Window * pWindow, C4AbstractApp *)
{
// safety
@ -500,11 +505,13 @@ bool CStdGLCtx::Init(C4Window * pWindow, C4AbstractApp *)
if (glXCreateContextAttribsARB)
{
int (*oldErrorHandler) (Display *, XErrorEvent *) = XSetErrorHandler(GLXErrorHandler);
ctx = glXCreateContextAttribsARB(dpy, pWindow->Info, share_context, True, attribs);
XSync(dpy, False);
XSetErrorHandler(oldErrorHandler);
}
else
{
DebugLog(" gl: glXCreateContextAttribsARB not supported; falling back to attribute-less context creation");
if(!ctx) {
Log(" gl: falling back to attribute-less context creation.");
ctx = glXCreateNewContext(dpy, pWindow->Info, GLX_RGBA_TYPE, share_context, True);
}