GLInterface: Support surfaceless contexts on GLX

This commit is contained in:
Stenzek 2017-07-31 22:53:28 +10:00
parent 67997529b8
commit 287859c5e1
1 changed files with 13 additions and 6 deletions

View File

@ -148,9 +148,9 @@ bool cInterfaceGLX::Create(void* window_handle, bool stereo, bool core)
if (!ctx || s_glxError) if (!ctx || s_glxError)
{ {
ERROR_LOG(VIDEO, "Unable to create GL context."); ERROR_LOG(VIDEO, "Unable to create GL context.");
XSetErrorHandler(oldHandler);
return false; return false;
} }
XSetErrorHandler(oldHandler);
std::string tmp; std::string tmp;
std::istringstream buffer(glXQueryExtensionsString(dpy, screen)); std::istringstream buffer(glXQueryExtensionsString(dpy, screen));
@ -172,8 +172,11 @@ bool cInterfaceGLX::Create(void* window_handle, bool stereo, bool core)
if (!CreateWindowSurface()) if (!CreateWindowSurface())
{ {
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n"); ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n");
XSetErrorHandler(oldHandler);
return false; return false;
} }
XSetErrorHandler(oldHandler);
return true; return true;
} }
@ -182,6 +185,7 @@ bool cInterfaceGLX::Create(cInterfaceBase* main_context)
cInterfaceGLX* glx_context = static_cast<cInterfaceGLX*>(main_context); cInterfaceGLX* glx_context = static_cast<cInterfaceGLX*>(main_context);
m_has_handle = false; m_has_handle = false;
m_supports_pbuffer = glx_context->m_supports_pbuffer;
dpy = glx_context->dpy; dpy = glx_context->dpy;
fbconfig = glx_context->fbconfig; fbconfig = glx_context->fbconfig;
s_glxError = false; s_glxError = false;
@ -193,15 +197,18 @@ bool cInterfaceGLX::Create(cInterfaceBase* main_context)
if (!ctx || s_glxError) if (!ctx || s_glxError)
{ {
ERROR_LOG(VIDEO, "Unable to create GL context."); ERROR_LOG(VIDEO, "Unable to create GL context.");
XSetErrorHandler(oldHandler);
return false; return false;
} }
XSetErrorHandler(oldHandler);
if (!CreateWindowSurface()) if (m_supports_pbuffer && !CreateWindowSurface())
{ {
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n"); ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n");
XSetErrorHandler(oldHandler);
return false; return false;
} }
XSetErrorHandler(oldHandler);
return true; return true;
} }
@ -235,7 +242,7 @@ bool cInterfaceGLX::CreateWindowSurface()
win = XWindow.CreateXWindow(m_host_window, vi); win = XWindow.CreateXWindow(m_host_window, vi);
XFree(vi); XFree(vi);
} }
else else if (m_supports_pbuffer)
{ {
win = m_pbuffer = glXCreateGLXPbufferSGIX(dpy, fbconfig, 1, 1, nullptr); win = m_pbuffer = glXCreateGLXPbufferSGIX(dpy, fbconfig, 1, 1, nullptr);
if (!m_pbuffer) if (!m_pbuffer)
@ -247,11 +254,11 @@ bool cInterfaceGLX::CreateWindowSurface()
void cInterfaceGLX::DestroyWindowSurface() void cInterfaceGLX::DestroyWindowSurface()
{ {
if (!m_pbuffer) if (m_has_handle)
{ {
XWindow.DestroyXWindow(); XWindow.DestroyXWindow();
} }
else else if (m_supports_pbuffer && m_pbuffer)
{ {
glXDestroyGLXPbufferSGIX(dpy, m_pbuffer); glXDestroyGLXPbufferSGIX(dpy, m_pbuffer);
m_pbuffer = 0; m_pbuffer = 0;