From b28e956b8c2a9548d411e39971a96d4d7b211fcf Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Tue, 12 Mar 2019 07:59:53 +0100 Subject: [PATCH] Fixed bug 4542 - Image flipped vertically when rendering on texture Have to recompute viewport because projection/glOrtho is different wether rendering is on target texture or not --- src/render/opengl/SDL_render_gl.c | 4 +++- src/render/opengles/SDL_render_gles.c | 2 ++ src/render/opengles2/SDL_render_gles2.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 81da88853..f0a5d9cee 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -773,6 +773,8 @@ GL_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return SDL_SetError("Render targets not supported by OpenGL"); } + data->drawstate.viewport_dirty = SDL_TRUE; + if (texture == NULL) { data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); return 0; @@ -1525,7 +1527,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor); - + window_flags = SDL_GetWindowFlags(window); if (!(window_flags & SDL_WINDOW_OPENGL) || profile_mask == SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index bd17096d0..7dc32ca95 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -503,6 +503,8 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return SDL_SetError("Can't enable render target support in this renderer"); } + data->drawstate.viewport_dirty = SDL_TRUE; + if (texture == NULL) { data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer); return 0; diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index a5e8e282e..cfc2708c4 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1748,6 +1748,8 @@ GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) GLES2_TextureData *texturedata = NULL; GLenum status; + data->drawstate.viewport_dirty = SDL_TRUE; + if (texture == NULL) { data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer); } else {