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.
authorAlex Szpakowski <slime73@gmail.com>
Fri, 21 Dec 2018 20:53:31 -0400
changeset 12483fbce19db4e53
parent 12482 1acae5590352
child 12484 06031bc24165
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
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Wed Dec 19 18:10:02 2018 -0500
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Fri Dec 21 20:53:31 2018 -0400
     1.3 @@ -1388,6 +1388,13 @@
     1.4  
     1.5      GL_ActivateRenderer(renderer);
     1.6  
     1.7 +    if (renderdata->drawstate.texture == texture) {
     1.8 +        renderdata->drawstate.texture = NULL;
     1.9 +    }
    1.10 +    if (renderdata->drawstate.target == texture) {
    1.11 +        renderdata->drawstate.target = NULL;
    1.12 +    }
    1.13 +
    1.14      if (!data) {
    1.15          return;
    1.16      }
     2.1 --- a/src/render/opengles2/SDL_render_gles2.c	Wed Dec 19 18:10:02 2018 -0500
     2.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Fri Dec 21 20:53:31 2018 -0400
     2.3 @@ -1766,6 +1766,13 @@
     2.4  
     2.5      GLES2_ActivateRenderer(renderer);
     2.6  
     2.7 +    if (data->drawstate.texture == texture) {
     2.8 +        data->drawstate.texture = NULL;
     2.9 +    }
    2.10 +    if (data->drawstate.target == texture) {
    2.11 +        data->drawstate.target = NULL;
    2.12 +    }
    2.13 +
    2.14      /* Destroy the texture */
    2.15      if (tdata) {
    2.16          data->glDeleteTextures(1, &tdata->texture);