Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed magenta texture on iOS with OpenGL ES 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 31, 2012
1 parent 0ce3941 commit 071211d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/render/opengles/SDL_render_gles.c
Expand Up @@ -111,6 +111,7 @@ typedef struct
#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;
Expand Down Expand Up @@ -356,6 +357,9 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
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;

Expand Down Expand Up @@ -586,7 +590,7 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
GLES_ActivateRenderer(renderer);

if (texture == NULL) {
data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer);
return 0;
}

Expand Down
6 changes: 5 additions & 1 deletion src/render/opengles2/SDL_render_gles2.c
Expand Up @@ -145,6 +145,7 @@ typedef struct GLES2_DriverContext
#include "SDL_gles2funcs.h"
#undef SDL_PROC
GLES2_FBOList *framebuffers;
GLuint window_framebuffer;

int shader_format_count;
GLenum *shader_formats;
Expand Down Expand Up @@ -546,7 +547,7 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
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);
Expand Down Expand Up @@ -1394,6 +1395,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
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);
Expand Down Expand Up @@ -1485,6 +1487,8 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
#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;
Expand Down

0 comments on commit 071211d

Please sign in to comment.