mirror of
https://github.com/glfw/glfw.git
synced 2025-04-10 23:31:55 +00:00
Fix for not being able to clear the user context
This commit is contained in:
parent
e4e46b4cc5
commit
58aad6c136
6 changed files with 83 additions and 30 deletions
|
@ -619,8 +619,9 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
|||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFWwindow* previous;
|
||||
_GLFWusercontext* previousUserContext;
|
||||
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
previousUserContext = _glfwPlatformGetTls(&_glfw.usercontextSlot);
|
||||
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
|
||||
if (window && window->context.client == GLFW_NO_API)
|
||||
|
@ -630,6 +631,12 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
|||
return;
|
||||
}
|
||||
|
||||
if (previousUserContext)
|
||||
{
|
||||
assert(previous==NULL);
|
||||
previousUserContext->makeCurrent(NULL);
|
||||
}
|
||||
|
||||
if (previous)
|
||||
{
|
||||
if (!window || window->context.source != previous->context.source)
|
||||
|
|
|
@ -919,16 +919,32 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
|
|||
|
||||
static void _glfwMakeUserContextCurrentEGL(_GLFWusercontext* context)
|
||||
{
|
||||
if (!eglMakeCurrent(_glfw.egl.display,
|
||||
context->egl.surface,
|
||||
context->egl.surface,
|
||||
context->egl.handle))
|
||||
if (context)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: Failed to make user context current: %s",
|
||||
getEGLErrorString(eglGetError()));
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
if (!eglMakeCurrent(_glfw.egl.display,
|
||||
context->egl.surface,
|
||||
context->egl.surface,
|
||||
context->egl.handle))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: Failed to make user context current: %s",
|
||||
getEGLErrorString(eglGetError()));
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!eglMakeCurrent(_glfw.egl.display,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"EGL: Failed to clear current user context: %s",
|
||||
getEGLErrorString(eglGetError()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, context);
|
||||
}
|
||||
|
|
|
@ -687,12 +687,24 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
|
|||
|
||||
static void _glfwMakeUserContextCurrentGLX(_GLFWusercontext* context)
|
||||
{
|
||||
if(!glXMakeCurrent(_glfw.x11.display, context->window->context.glx.window,context->glx.handle))
|
||||
if (context)
|
||||
{
|
||||
if(!glXMakeCurrent(_glfw.x11.display, context->window->context.glx.window,context->glx.handle))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"GLX: Failed to make user context current");
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"GLX: Failed to make user context current");
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"GLX: Failed to clear current user context");
|
||||
return;
|
||||
}
|
||||
}
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, context);
|
||||
}
|
||||
|
|
|
@ -357,9 +357,12 @@ static void _glfwMakeUserContextCurrentNSGL(_GLFWusercontext* context)
|
|||
{
|
||||
@autoreleasepool {
|
||||
|
||||
if (context)
|
||||
[context->nsgl.object makeCurrentContext];
|
||||
else
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, context);
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, context);
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
@ -368,7 +371,7 @@ static void _glfwDestroyUserContextNSGL(_GLFWusercontext* context)
|
|||
{
|
||||
@autoreleasepool {
|
||||
|
||||
[context->nsgl.object release];
|
||||
[context->nsgl.object release];
|
||||
|
||||
} // autoreleasepool
|
||||
free(context);
|
||||
|
|
|
@ -300,15 +300,18 @@ GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
|
|||
|
||||
static void _glfwMakeUserContextCurrentOSMesa(_GLFWusercontext* context)
|
||||
{
|
||||
if (!OSMesaMakeCurrent(context->osmesa.handle,
|
||||
context->window->context.osmesa.buffer,
|
||||
GL_UNSIGNED_BYTE,
|
||||
context->window->context.osmesa.width, context->window->context.osmesa.height))
|
||||
if (context)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"OSMesa: Failed to make user context current");
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
if (!OSMesaMakeCurrent(context->osmesa.handle,
|
||||
context->window->context.osmesa.buffer,
|
||||
GL_UNSIGNED_BYTE,
|
||||
context->window->context.osmesa.width, context->window->context.osmesa.height))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"OSMesa: Failed to make user context current");
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, context);
|
||||
}
|
||||
|
|
|
@ -787,13 +787,25 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||
|
||||
static void _glfwMakeUserContextCurrentWGL(_GLFWusercontext* context)
|
||||
{
|
||||
if(!wglMakeCurrent(context->window->context.wgl.dc,context->wgl.handle))
|
||||
if (context)
|
||||
{
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||
"WGL: Failed to make user context current");
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
if (!wglMakeCurrent(context->window->context.wgl.dc,context->wgl.handle))
|
||||
{
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||
"WGL: Failed to make user context current");
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!wglMakeCurrent(NULL, NULL))
|
||||
{
|
||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||
"WGL: Failed to clear current user context");
|
||||
}
|
||||
}
|
||||
|
||||
_glfwPlatformSetTls(&_glfw.usercontextSlot, context);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue