Added the ability to bind NV12 textures in the OpenGL renderer

main
Sam Lantinga 2021-10-21 12:28:35 -07:00
parent f3fd1ffb99
commit a34fe8161f
1 changed files with 30 additions and 4 deletions

View File

@ -1671,6 +1671,16 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
} }
data->glBindTexture(textype, texturedata->utexture); 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) { if (data->GL_ARB_multitexture_supported) {
data->glActiveTextureARB(GL_TEXTURE0_ARB); 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.texturing = SDL_TRUE;
data->drawstate.texture = texture; data->drawstate.texture = texture;
if(texw) *texw = (float)texturedata->texw; if (texw) {
if(texh) *texh = (float)texturedata->texh; *texw = (float)texturedata->texw;
}
if (texh) {
*texh = (float)texturedata->texh;
}
return 0; return 0;
} }
@ -1701,11 +1714,24 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
if (data->GL_ARB_multitexture_supported) { if (data->GL_ARB_multitexture_supported) {
data->glActiveTextureARB(GL_TEXTURE2_ARB); data->glActiveTextureARB(GL_TEXTURE2_ARB);
} }
data->glBindTexture(textype, 0);
data->glDisable(textype); data->glDisable(textype);
if (data->GL_ARB_multitexture_supported) { if (data->GL_ARB_multitexture_supported) {
data->glActiveTextureARB(GL_TEXTURE1_ARB); data->glActiveTextureARB(GL_TEXTURE1_ARB);
} }
data->glBindTexture(textype, 0);
data->glDisable(textype);
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, 0);
data->glDisable(textype); data->glDisable(textype);
if (data->GL_ARB_multitexture_supported) { if (data->GL_ARB_multitexture_supported) {
@ -1713,7 +1739,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
} }
} }
#endif #endif
data->glBindTexture(textype, 0);
data->glDisable(textype); data->glDisable(textype);
data->drawstate.texturing = SDL_FALSE; data->drawstate.texturing = SDL_FALSE;