From cf05a5eb0ce9e9453ce71e7fa0c32b1988d43b45 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 22 Apr 2021 21:40:57 +0200 Subject: [PATCH] eglChooseConfig: only add EGL_DEPTH_SIZE if non 0 and fix static / shadowed variables warnings for dump configs --- src/video/SDL_egl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index e3b50d97f..d8adb6174 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -645,7 +645,8 @@ typedef struct { char const* name; } Attribute; -Attribute attributes[] = { +static +Attribute all_attributes[] = { ATTRIBUTE( EGL_BUFFER_SIZE ), ATTRIBUTE( EGL_ALPHA_SIZE ), ATTRIBUTE( EGL_BLUE_SIZE ), @@ -685,10 +686,10 @@ Attribute attributes[] = { static void dumpconfig(_THIS, EGLConfig config) { int attr; - for (attr = 0 ; attregl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, attributes[attr].attribute, &value); - SDL_Log("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value); + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, all_attributes[attr].attribute, &value); + SDL_Log("\t%-32s: %10d (0x%08x)\n", all_attributes[attr].name, value, value); } } @@ -729,10 +730,12 @@ SDL_EGL_ChooseConfig(_THIS) attribs[i++] = EGL_BUFFER_SIZE; attribs[i++] = _this->gl_config.buffer_size; } - - attribs[i++] = EGL_DEPTH_SIZE; - attribs[i++] = _this->gl_config.depth_size; - + + if (_this->gl_config.depth_size) { + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + } + if (_this->gl_config.stencil_size) { attribs[i++] = EGL_STENCIL_SIZE; attribs[i++] = _this->gl_config.stencil_size;