Commit cf05a5eb0ce9e9453ce71e7fa0c32b1988d43b45

Sylvain 2021-04-22T21:40:57

eglChooseConfig: only add EGL_DEPTH_SIZE if non 0 and fix static / shadowed variables warnings for dump configs

diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index e3b50d9..d8adb61 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 ; attr<sizeof(attributes)/sizeof(Attribute) ; attr++) {
+    for (attr = 0 ; attr<sizeof(all_attributes)/sizeof(Attribute) ; attr++) {
         EGLint value;
-        _this->egl_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;