From dc3443602b8352e76b6e5b89eca00909469b22eb Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 21 Dec 2018 20:53:31 -0400 Subject: [PATCH] render: Fix internal state getting out of sync when destroying a texture that was just rendered and then creating a new one, in the GL and GLES2 backends. Fixes bug #4433. --- src/render/opengl/SDL_render_gl.c | 7 +++++++ src/render/opengles2/SDL_render_gles2.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 01d6dadf0..29b6c9c31 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -1388,6 +1388,13 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_ActivateRenderer(renderer); + if (renderdata->drawstate.texture == texture) { + renderdata->drawstate.texture = NULL; + } + if (renderdata->drawstate.target == texture) { + renderdata->drawstate.target = NULL; + } + if (!data) { return; } diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index ad79fdd30..f2d4eb308 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1766,6 +1766,13 @@ GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) GLES2_ActivateRenderer(renderer); + if (data->drawstate.texture == texture) { + data->drawstate.texture = NULL; + } + if (data->drawstate.target == texture) { + data->drawstate.target = NULL; + } + /* Destroy the texture */ if (tdata) { data->glDeleteTextures(1, &tdata->texture);