opengles2: keep cached texturing state correct.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index fd93cd6..03e4192 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -1400,6 +1400,8 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
GLES2_ActivateRenderer(renderer);
+ renderdata->drawstate.texture = NULL; /* we trash this state. */
+
/* Determine the corresponding GLES texture format params */
switch (texture->format)
{
@@ -1595,6 +1597,8 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
return 0;
}
+ renderdata->drawstate.texture = NULL; /* we trash this state. */
+
/* Create a texture subimage with the supplied data */
data->glBindTexture(tdata->texture_type, tdata->texture);
GLES2_TexSubImage2D(data, tdata->texture_type,
@@ -1673,6 +1677,8 @@ GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
return 0;
}
+ renderdata->drawstate.texture = NULL; /* we trash this state. */
+
data->glBindTexture(tdata->texture_type, tdata->texture_v);
GLES2_TexSubImage2D(data, tdata->texture_type,
rect->x / 2,
@@ -1867,6 +1873,7 @@ static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, flo
GLES2_ActivateRenderer(renderer);
data->glBindTexture(texturedata->texture_type, texturedata->texture);
+ renderdata->drawstate.texture = texture;
if (texw) {
*texw = 1.0;
@@ -1885,6 +1892,7 @@ static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
GLES2_ActivateRenderer(renderer);
data->glBindTexture(texturedata->texture_type, 0);
+ data->drawstate.texture = NULL;
return 0;
}