From 276b1bc07a0532adc34eb8dcf3b6a55f79fc8585 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 31 Jan 2016 19:17:18 +0100 Subject: [PATCH] Add check for EGL specific buffer swap issue Fixes #675. --- README.md | 2 ++ include/GLFW/glfw3.h | 3 +++ src/egl_context.c | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/README.md b/README.md index fcf4bf34..43c1abca 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,8 @@ used by the tests and examples and are not required to build the library. - [GLX] Bugfix: NetBSD does not provide `libGL.so.1` - [EGL] Added `_GLFW_USE_EGLPLATFORM_H` configuration macro for controlling whether to use an existing `EGL/eglplatform.h` header + - [EGL] Added and documented test for if the context is current on the calling + thread during buffer swap - [EGL] Removed dependency on external EGL headers diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 5201faf6..a1f058f8 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3429,6 +3429,9 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void); * * @param[in] window The window whose buffers to swap. * + * @remarks __EGL:__ The context of the specified window must be current on the + * calling thread. + * * @par Thread Safety * This function may be called from any thread. * diff --git a/src/egl_context.c b/src/egl_context.c index 0eb0aa41..579e17f1 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -584,6 +584,13 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window) void _glfwPlatformSwapBuffers(_GLFWwindow* window) { + if (window != _glfwPlatformGetCurrentContext()) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGL: The context must be current on the calling thread when swapping buffers"); + return; + } + eglSwapBuffers(_glfw.egl.display, window->context.egl.surface); }