Commit a609c03ac6ca55a4d7ebf5ee7cf34e29972b863c

Ryan C. Gordon 2019-02-04T23:24:10

opengles1: keep cached texturing state correct.

diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c
index a064fb1..bd17096 100644
--- a/src/render/opengles/SDL_render_gles.c
+++ b/src/render/opengles/SDL_render_gles.c
@@ -391,6 +391,8 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
     renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
                              texture_h, 0, format, type, NULL);
     renderdata->glDisable(GL_TEXTURE_2D);
+    renderdata->drawstate.texture = texture;
+    renderdata->drawstate.texturing = SDL_FALSE;
 
     result = renderdata->glGetError();
     if (result != GL_NO_ERROR) {
@@ -454,6 +456,9 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
     renderdata->glDisable(data->type);
     SDL_free(blob);
 
+    renderdata->drawstate.texture = texture;
+    renderdata->drawstate.texturing = SDL_FALSE;
+
     if (renderdata->glGetError() != GL_NO_ERROR) {
         return SDL_SetError("Failed to update texture");
     }
@@ -1060,6 +1065,9 @@ static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, floa
     data->glEnable(GL_TEXTURE_2D);
     data->glBindTexture(texturedata->type, texturedata->texture);
 
+    data->drawstate.texture = texture;
+    data->drawstate.texturing = SDL_TRUE;
+
     if (texw) {
         *texw = (float)texturedata->texw;
     }
@@ -1077,6 +1085,9 @@ static int GLES_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
     GLES_ActivateRenderer(renderer);
     data->glDisable(texturedata->type);
 
+    data->drawstate.texture = NULL;
+    data->drawstate.texturing = SDL_FALSE;
+
     return 0;
 }