mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
fixed gles/gles2 renderer creation fail on Android when default major/minor version doesn't match
This commit is contained in:
parent
8db4c5a9d3
commit
472068dd97
@ -279,15 +279,24 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
GLES_RenderData *data;
|
||||
GLint value;
|
||||
Uint32 windowFlags;
|
||||
int profileMask, majorVersion, minorVersion;
|
||||
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profileMask);
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &majorVersion);
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minorVersion);
|
||||
|
||||
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);
|
||||
|
||||
windowFlags = SDL_GetWindowFlags(window);
|
||||
if (!(windowFlags & SDL_WINDOW_OPENGL)) {
|
||||
if (!(windowFlags & SDL_WINDOW_OPENGL) ||
|
||||
profileMask != SDL_GL_CONTEXT_PROFILE_ES || majorVersion != 1 || minorVersion != 1) {
|
||||
if (SDL_RecreateWindow(window, windowFlags | SDL_WINDOW_OPENGL) < 0) {
|
||||
/* Uh oh, better try to put it back... */
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profileMask);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, majorVersion);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minorVersion);
|
||||
SDL_RecreateWindow(window, windowFlags);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1740,15 +1740,24 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
Uint32 windowFlags;
|
||||
GLint window_framebuffer;
|
||||
GLint value;
|
||||
int profileMask, majorVersion, minorVersion;
|
||||
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profileMask);
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &majorVersion);
|
||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minorVersion);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
|
||||
windowFlags = SDL_GetWindowFlags(window);
|
||||
if (!(windowFlags & SDL_WINDOW_OPENGL)) {
|
||||
if (!(windowFlags & SDL_WINDOW_OPENGL) ||
|
||||
profileMask != SDL_GL_CONTEXT_PROFILE_ES || majorVersion != 2 || minorVersion != 0) {
|
||||
if (SDL_RecreateWindow(window, windowFlags | SDL_WINDOW_OPENGL) < 0) {
|
||||
/* Uh oh, better try to put it back... */
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profileMask);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, majorVersion);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minorVersion);
|
||||
SDL_RecreateWindow(window, windowFlags);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user