Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear current GLX context before destroying the current context #867

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Engine/OSGLContext_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*, int*, int*);
typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*, int*, int*);
typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*, GLXContext);
typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*, GLXDrawable, GLXContext);
typedef GLXContext (*PFNGLXGETCURRENTCONTEXTPROC)();
typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*, GLXDrawable);
typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*, int);
typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*, int, int*);
Expand Down Expand Up @@ -167,6 +168,7 @@ struct OSGLContext_glx_dataPrivate
PFNGLXQUERYVERSIONPROC QueryVersion;
PFNGLXDESTROYCONTEXTPROC DestroyContext;
PFNGLXMAKECURRENTPROC MakeCurrent;
PFNGLXGETCURRENTCONTEXTPROC GetCurrentContext;
PFNGLXSWAPBUFFERSPROC SwapBuffers;
PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
Expand Down Expand Up @@ -316,6 +318,7 @@ OSGLContext_x11::initGLXData(OSGLContext_glx_data* glxInfo)
glxInfo->_imp->QueryVersion = (PFNGLXQUERYVERSIONPROC)dlsym(glxInfo->_imp->handle, "glXQueryVersion");
glxInfo->_imp->DestroyContext = (PFNGLXDESTROYCONTEXTPROC)dlsym(glxInfo->_imp->handle, "glXDestroyContext");
glxInfo->_imp->MakeCurrent = (PFNGLXMAKECURRENTPROC)dlsym(glxInfo->_imp->handle, "glXMakeCurrent");
glxInfo->_imp->GetCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC)dlsym(glxInfo->_imp->handle, "glXGetCurrentContext");
glxInfo->_imp->SwapBuffers = (PFNGLXSWAPBUFFERSPROC)dlsym(glxInfo->_imp->handle, "glXSwapBuffers");
glxInfo->_imp->QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)dlsym(glxInfo->_imp->handle, "glXQueryExtensionsString");
glxInfo->_imp->CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)dlsym(glxInfo->_imp->handle, "glXCreateNewContext");
Expand Down Expand Up @@ -810,6 +813,10 @@ OSGLContext_x11::~OSGLContext_x11()
_imp->glxWindowHandle = 0;
}
if (_imp->glxContextHandle) {

if (glxInfo->_imp->GetCurrentContext() == _imp->glxContextHandle) {
glxInfo->_imp->MakeCurrent(glxInfo->_imp->x11.display, None, NULL);
}
glxInfo->_imp->DestroyContext(glxInfo->_imp->x11.display, _imp->glxContextHandle);
_imp->glxContextHandle = 0;
}
Expand Down