Fixed magenta texture on iOS with OpenGL ES 2.0
authorSam Lantinga
Mon, 30 Jan 2012 20:56:25 -0500
changeset 6271d1ba86bc57a5
parent 6270 0cf2443a0b17
child 6272 f3dbef2cc0f2
Fixed magenta texture on iOS with OpenGL ES 2.0
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles/SDL_render_gles.c	Mon Jan 30 20:09:50 2012 -0500
     1.2 +++ b/src/render/opengles/SDL_render_gles.c	Mon Jan 30 20:56:25 2012 -0500
     1.3 @@ -111,6 +111,7 @@
     1.4  #undef SDL_PROC
     1.5      SDL_bool GL_OES_framebuffer_object_supported;
     1.6      GLES_FBOList *framebuffers;
     1.7 +    GLuint window_framebuffer;
     1.8  
     1.9      SDL_bool useDrawTexture;
    1.10      SDL_bool GL_OES_draw_texture_supported;
    1.11 @@ -356,6 +357,9 @@
    1.12      if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object")) {
    1.13          data->GL_OES_framebuffer_object_supported = SDL_TRUE;
    1.14          renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
    1.15 +
    1.16 +        data->glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &value);
    1.17 +        data->window_framebuffer = (GLuint)value;
    1.18      }
    1.19      data->framebuffers = NULL;
    1.20  
    1.21 @@ -586,7 +590,7 @@
    1.22      GLES_ActivateRenderer(renderer);
    1.23  
    1.24      if (texture == NULL) {
    1.25 -        data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
    1.26 +        data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer);
    1.27          return 0;
    1.28      }
    1.29  
     2.1 --- a/src/render/opengles2/SDL_render_gles2.c	Mon Jan 30 20:09:50 2012 -0500
     2.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Mon Jan 30 20:56:25 2012 -0500
     2.3 @@ -145,6 +145,7 @@
     2.4  #include "SDL_gles2funcs.h"
     2.5  #undef SDL_PROC
     2.6      GLES2_FBOList *framebuffers;
     2.7 +    GLuint window_framebuffer;
     2.8  
     2.9      int shader_format_count;
    2.10      GLenum *shader_formats;
    2.11 @@ -546,7 +547,7 @@
    2.12      GLenum status;
    2.13  
    2.14      if (texture == NULL) {
    2.15 -        data->glBindFramebuffer(GL_FRAMEBUFFER, 0);
    2.16 +        data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer);
    2.17      } else {
    2.18          texturedata = (GLES2_TextureData *) texture->driverdata;
    2.19          data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO);
    2.20 @@ -1394,6 +1395,7 @@
    2.21      GLboolean hasCompiler;
    2.22  #endif
    2.23      Uint32 windowFlags;
    2.24 +    GLint window_framebuffer;
    2.25  
    2.26      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    2.27      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
    2.28 @@ -1485,6 +1487,8 @@
    2.29  #endif /* ZUNE_HD */
    2.30  
    2.31      rdata->framebuffers = NULL;
    2.32 +    rdata->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer);
    2.33 +    rdata->window_framebuffer = (GLuint)window_framebuffer;
    2.34  
    2.35      /* Populate the function pointers for the module */
    2.36      renderer->WindowEvent         = &GLES2_WindowEvent;