From 48ac92af548607e91fc6744872ad490717d277b5 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 8 Jun 2019 18:40:11 -0700 Subject: [PATCH] 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. ) --- src/video/SDL_video.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8c552d9a8cc59..fd67442d611ba 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)) {