From 5faea84c631e39fbd9b2743bedb2545d882baed9 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 18 Sep 2021 11:54:25 -0400 Subject: [PATCH] render: Mark viewport/cliprect dirty when window is resized. Fixes #4751. --- src/render/opengl/SDL_render_gl.c | 9 ++++++++- src/render/opengles/SDL_render_gles.c | 10 +++++++++- src/render/opengles2/SDL_render_gles2.c | 9 ++++++++- src/render/vitagxm/SDL_render_vita_gxm.c | 10 +++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index d7f7a4406..758166a98 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -1279,7 +1279,14 @@ GL_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic data->drawstate.target = renderer->target; if (!data->drawstate.target) { - SDL_GL_GetDrawableSize(renderer->window, &data->drawstate.drawablew, &data->drawstate.drawableh); + int w, h; + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.drawablew = w; + data->drawstate.drawableh = h; + } } diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 017229e9c..c0a2ce9dc 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -934,7 +934,15 @@ GLES_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert data->drawstate.target = renderer->target; if (!renderer->target) { - SDL_GL_GetDrawableSize(renderer->window, &data->drawstate.drawablew, &data->drawstate.drawableh); + int w, h; + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.drawablew = w; + data->drawstate.drawableh = h; + } + } while (cmd) { diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 73cca1bcb..7ea703d8f 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1270,7 +1270,14 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver data->drawstate.target = renderer->target; if (!data->drawstate.target) { - SDL_GL_GetDrawableSize(renderer->window, &data->drawstate.drawablew, &data->drawstate.drawableh); + int w, h; + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.drawablew = w; + data->drawstate.drawableh = h; + } } /* upload the new VBO data for this set of commands. */ diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c index 67a834ba0..bd9230f9e 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/src/render/vitagxm/SDL_render_vita_gxm.c @@ -987,7 +987,15 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void * data->drawstate.target = renderer->target; if (!data->drawstate.target) { - SDL_GL_GetDrawableSize(renderer->window, &data->drawstate.drawablew, &data->drawstate.drawableh); + int w, h; + SDL_GL_GetDrawableSize(renderer->window, &w, &h); + if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) { + data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc. + data->drawstate.cliprect_dirty = SDL_TRUE; + data->drawstate.drawablew = w; + data->drawstate.drawableh = h; + } + } while (cmd) {