Commit 48ac92af548607e91fc6744872ad490717d277b5

Sam Lantinga 2019-06-08T18:40:11

Fixed bug 4041 - Android, SDL_Renderer OpenGLES 1 is loading GLESv2 library Sylvain On Android, if you set no attribute using SDL_GL_SetAttribute(), and try to create a SDL Render OpenGLES 1: - it loads first by default GLESv2 libraries - creates the rendere OpenGLES 1 - recreates the Window to have a context 1.1 ( https://hg.libsdl.org/SDL/file/4db4cfd59470/src/render/opengles/SDL_render_gles.c#l298 ) But it doesn't unload libraries, then reload GLESv1 lib. So the SDL_Renderer OpenGLES 1 is working with GLES 2 libs, which seems inconsistent. If you, at first, set SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); It will correctly load GLES v1 libraries. Here's a small patch to reload egl libs when SDL_RecreateWindow() is called. It fixes the issue, also the case from bug 4042 ( SDL_RecreateWindow() is used by SDL_Renderer gl, gles1, gles2. )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 8c552d9..fd67442 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1654,6 +1654,12 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
         } else {
             SDL_GL_UnloadLibrary();
         }
+    } else if (window->flags & SDL_WINDOW_OPENGL) {
+        SDL_GL_UnloadLibrary();
+        if (SDL_GL_LoadLibrary(NULL) < 0) {
+            return -1;
+        }
+        loaded_opengl = SDL_TRUE;
     }
 
     if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {