Fixed magenta texture on iOS with OpenGL ES 2.0
authorSam Lantinga <slouken@libsdl.org>
Mon, 30 Jan 2012 20:56:25 -0500
changeset 6271 d1ba86bc57a5
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
--- a/src/render/opengles/SDL_render_gles.c	Mon Jan 30 20:09:50 2012 -0500
+++ b/src/render/opengles/SDL_render_gles.c	Mon Jan 30 20:56:25 2012 -0500
@@ -111,6 +111,7 @@
 #undef SDL_PROC
     SDL_bool GL_OES_framebuffer_object_supported;
     GLES_FBOList *framebuffers;
+    GLuint window_framebuffer;
 
     SDL_bool useDrawTexture;
     SDL_bool GL_OES_draw_texture_supported;
@@ -356,6 +357,9 @@
     if (SDL_GL_ExtensionSupported("GL_OES_framebuffer_object")) {
         data->GL_OES_framebuffer_object_supported = SDL_TRUE;
         renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
+
+        data->glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &value);
+        data->window_framebuffer = (GLuint)value;
     }
     data->framebuffers = NULL;
 
@@ -586,7 +590,7 @@
     GLES_ActivateRenderer(renderer);
 
     if (texture == NULL) {
-        data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
+        data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer);
         return 0;
     }
 
--- a/src/render/opengles2/SDL_render_gles2.c	Mon Jan 30 20:09:50 2012 -0500
+++ b/src/render/opengles2/SDL_render_gles2.c	Mon Jan 30 20:56:25 2012 -0500
@@ -145,6 +145,7 @@
 #include "SDL_gles2funcs.h"
 #undef SDL_PROC
     GLES2_FBOList *framebuffers;
+    GLuint window_framebuffer;
 
     int shader_format_count;
     GLenum *shader_formats;
@@ -546,7 +547,7 @@
     GLenum status;
 
     if (texture == NULL) {
-        data->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+        data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer);
     } else {
         texturedata = (GLES2_TextureData *) texture->driverdata;
         data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO);
@@ -1394,6 +1395,7 @@
     GLboolean hasCompiler;
 #endif
     Uint32 windowFlags;
+    GLint window_framebuffer;
 
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
@@ -1485,6 +1487,8 @@
 #endif /* ZUNE_HD */
 
     rdata->framebuffers = NULL;
+    rdata->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer);
+    rdata->window_framebuffer = (GLuint)window_framebuffer;
 
     /* Populate the function pointers for the module */
     renderer->WindowEvent         = &GLES2_WindowEvent;