From a34fe8161ff7b79bdd90633b2389a3993b899812 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 21 Oct 2021 12:28:35 -0700
Subject: [PATCH] Added the ability to bind NV12 textures in the OpenGL
renderer
---
src/render/opengl/SDL_render_gl.c | 34 +++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c
index 23a905dbe7..80cfd09c10 100644
--- a/src/render/opengl/SDL_render_gl.c
+++ b/src/render/opengl/SDL_render_gl.c
@@ -1671,6 +1671,16 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
}
data->glBindTexture(textype, texturedata->utexture);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ }
+ }
+ if (texturedata->nv12) {
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ }
+ data->glBindTexture(textype, texturedata->utexture);
+
if (data->GL_ARB_multitexture_supported) {
data->glActiveTextureARB(GL_TEXTURE0_ARB);
}
@@ -1681,9 +1691,12 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
data->drawstate.texturing = SDL_TRUE;
data->drawstate.texture = texture;
- if(texw) *texw = (float)texturedata->texw;
- if(texh) *texh = (float)texturedata->texh;
-
+ if (texw) {
+ *texw = (float)texturedata->texw;
+ }
+ if (texh) {
+ *texh = (float)texturedata->texh;
+ }
return 0;
}
@@ -1701,19 +1714,32 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
if (data->GL_ARB_multitexture_supported) {
data->glActiveTextureARB(GL_TEXTURE2_ARB);
}
+ data->glBindTexture(textype, 0);
data->glDisable(textype);
if (data->GL_ARB_multitexture_supported) {
data->glActiveTextureARB(GL_TEXTURE1_ARB);
}
+ data->glBindTexture(textype, 0);
data->glDisable(textype);
if (data->GL_ARB_multitexture_supported) {
data->glActiveTextureARB(GL_TEXTURE0_ARB);
}
}
-#endif
+ if (texturedata->nv12) {
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ }
+ data->glBindTexture(textype, 0);
+ data->glDisable(textype);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ }
+ }
+#endif
+ data->glBindTexture(textype, 0);
data->glDisable(textype);
data->drawstate.texturing = SDL_FALSE;