Fixed bug 3347 - OpenGL ES renderer doesn't flip projection matrix for target textures Simon Hug When updating the viewport in GLES_UpdateViewport, the OpenGL ES renderer doesn't flip the projection matrix for target textures. The lines, rectangles and textures (if drawn with glDrawArrays) are upside down when drawing to target textures.
diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c
index 9b72597..b8b8c1d 100644
--- a/src/render/opengles/SDL_render_gles.c
+++ b/src/render/opengles/SDL_render_gles.c
@@ -676,13 +676,22 @@ GLES_UpdateViewport(SDL_Renderer * renderer)
renderer->viewport.w, renderer->viewport.h);
}
+ data->glMatrixMode(GL_PROJECTION);
+ data->glLoadIdentity();
if (renderer->viewport.w && renderer->viewport.h) {
- data->glMatrixMode(GL_PROJECTION);
- data->glLoadIdentity();
- data->glOrthof((GLfloat) 0,
- (GLfloat) renderer->viewport.w,
- (GLfloat) renderer->viewport.h,
- (GLfloat) 0, 0.0, 1.0);
+ if (renderer->target) {
+ data->glOrthof((GLfloat) 0,
+ (GLfloat) renderer->viewport.w,
+ (GLfloat) 0,
+ (GLfloat) renderer->viewport.h,
+ 0.0, 1.0);
+ } else {
+ data->glOrthof((GLfloat) 0,
+ (GLfloat) renderer->viewport.w,
+ (GLfloat) renderer->viewport.h,
+ (GLfloat) 0,
+ 0.0, 1.0);
+ }
}
return 0;
}