Skip to content
Permalink
Browse files

fixed gles/gles2 renderer creation fail on Android when default major…

…/minor version doesn't match
  • Loading branch information
CarniBlood CarniBlood
CarniBlood authored and CarniBlood committed Dec 18, 2013
1 parent 8db4c5a commit 472068dd979d2179f0b9fa30f462837346491a79
Showing with 20 additions and 2 deletions.
  1. +10 −1 src/render/opengles/SDL_render_gles.c
  2. +10 −1 src/render/opengles2/SDL_render_gles2.c
@@ -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;
}

0 comments on commit 472068d

Please sign in to comment.