Commit 01c5554f0e7d6ac18c8f85a84f35ffcf410f030c

Ryan C. Gordon 2022-10-03T11:57:10

opengles2: SDL_GL_BindTexture() should bind all YUV textures. This matches what the non-GLES OpenGL renderer does. Fixes #6070.

diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index 8718f79..923a0c6 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -2024,6 +2024,23 @@ static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, flo
     GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata;
     GLES2_ActivateRenderer(renderer);
 
+#if SDL_HAVE_YUV
+    if (texturedata->yuv) {
+        data->glActiveTexture(GL_TEXTURE2);
+        data->glBindTexture(texturedata->texture_type, texturedata->texture_v);
+
+        data->glActiveTexture(GL_TEXTURE1);
+        data->glBindTexture(texturedata->texture_type, texturedata->texture_u);
+
+        data->glActiveTexture(GL_TEXTURE0);
+    } else if (texturedata->nv12) {
+        data->glActiveTexture(GL_TEXTURE1);
+        data->glBindTexture(texturedata->texture_type, texturedata->texture_u);
+
+        data->glActiveTexture(GL_TEXTURE0);
+    }
+#endif
+
     data->glBindTexture(texturedata->texture_type, texturedata->texture);
     data->drawstate.texture = texture;