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. )
This commit is contained in:
Sam Lantinga 2019-06-08 18:40:11 -07:00
parent 1b73d578f3
commit 48ac92af54
1 changed files with 6 additions and 0 deletions
src/video

View File

@ -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)) {