opengles1: 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
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;
}