From 5ca22d660e0f5cb536f4e5655f8f068678f6dd6f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 Aug 2025 08:01:24 +0530 Subject: [PATCH] Nicer error handling when EGL context initialize fails --- glfw/egl_context.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/glfw/egl_context.c b/glfw/egl_context.c index 63198262b..5ea7d2156 100644 --- a/glfw/egl_context.c +++ b/glfw/egl_context.c @@ -400,11 +400,12 @@ bool _glfwInitEGL(void) free(attribs); - if (_glfw.egl.display == EGL_NO_DISPLAY) + EGLint egl_err; + if (_glfw.egl.display == EGL_NO_DISPLAY && (egl_err = eglGetError()) != EGL_SUCCESS) { _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to get EGL display: %s", - getEGLErrorString(eglGetError())); + getEGLErrorString(egl_err)); _glfwTerminateEGL(); return false; @@ -413,8 +414,8 @@ bool _glfwInitEGL(void) if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor)) { _glfwInputError(GLFW_API_UNAVAILABLE, - "EGL: Failed to initialize EGL: %s", - getEGLErrorString(eglGetError())); + "EGL: Failed to initialize EGL: %s display_present: %d egl_platform_present: %d", + getEGLErrorString(eglGetError()), _glfw.egl.display != EGL_NO_DISPLAY, _glfw.egl.platform != 0); _glfwTerminateEGL(); return false;