From c6ec66ed9e59df8ec31647ef29f97e2c2ab67be1 Mon Sep 17 00:00:00 2001 From: Yousry Abdallah Date: Tue, 5 Jan 2016 11:03:36 +0100 Subject: [PATCH] Update egl_context.c - Knowing the thread id greatly simplifies debugging. - The return value of eglMakeCurrent should be checked. --- src/egl_context.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 0eb0aa417..f6c731c46 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -30,7 +30,8 @@ #include #include #include - +#include +#include // Return a description of the specified EGL error // @@ -564,19 +565,32 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig, void _glfwPlatformMakeContextCurrent(_GLFWwindow* window) { + + int tid = syscall(SYS_gettid); + EGLBoolean ok = 1; + if (window) { - eglMakeCurrent(_glfw.egl.display, - window->context.egl.surface, - window->context.egl.surface, - window->context.egl.handle); + printf("----> [glfw]_glfwPlatformMakeContextCurrent With window called (TID: %d).\n", tid); + ok = eglMakeCurrent(_glfw.egl.display, + window->context.egl.surface, + window->context.egl.surface, + window->context.egl.handle); } else { - eglMakeCurrent(_glfw.egl.display, - EGL_NO_SURFACE, - EGL_NO_SURFACE, - EGL_NO_CONTEXT); + printf("----> [glfw]_glfwPlatformMakeContextCurrent empty (TID: %d).\n", tid); + ok = eglMakeCurrent(_glfw.egl.display, + EGL_NO_SURFACE, + EGL_NO_SURFACE, + EGL_NO_CONTEXT); + } + + if(ok == 0) { + printf("----> [glfw] _glfwPlatformMakeContextCurrent failed.\n"); + int errCode = eglGetError(); + printf("----> [glfw] Error Code: %0x\n", errCode); + abort(); } _glfwPlatformSetCurrentContext(window);