From 89c868f4f81cfdfa8ab46d83a31b42d0bd1af4a2 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 1 Oct 2016 11:40:57 -0700 Subject: [PATCH] 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. --- src/render/opengles/SDL_render_gles.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 9b725970d..b8b8c1d49 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; }