Fixed bug #4711: prevent opengl SDL_renderer from crashing if GL_ARB_multitexture isn't supported
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c
index c267267..591f68f 100644
--- a/src/render/opengl/SDL_render_gl.c
+++ b/src/render/opengl/SDL_render_gl.c
@@ -1240,18 +1240,26 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
const GLenum textype = data->textype;
#if SDL_HAVE_YUV
if (texturedata->yuv) {
- data->glActiveTextureARB(GL_TEXTURE2_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE2_ARB);
+ }
data->glBindTexture(textype, texturedata->vtexture);
- data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ }
data->glBindTexture(textype, texturedata->utexture);
}
if (texturedata->nv12) {
- data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ }
data->glBindTexture(textype, texturedata->utexture);
}
#endif
- data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ }
data->glBindTexture(textype, texturedata->texture);
data->drawstate.texture = texture;
@@ -1647,13 +1655,19 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa
data->glEnable(textype);
#if SDL_HAVE_YUV
if (texturedata->yuv) {
- data->glActiveTextureARB(GL_TEXTURE2_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE2_ARB);
+ }
data->glBindTexture(textype, texturedata->vtexture);
- data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ }
data->glBindTexture(textype, texturedata->utexture);
- data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ }
}
#endif
data->glBindTexture(textype, texturedata->texture);
@@ -1678,13 +1692,19 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
#if SDL_HAVE_YUV
if (texturedata->yuv) {
- data->glActiveTextureARB(GL_TEXTURE2_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE2_ARB);
+ }
data->glDisable(textype);
- data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE1_ARB);
+ }
data->glDisable(textype);
- data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ if (data->GL_ARB_multitexture_supported) {
+ data->glActiveTextureARB(GL_TEXTURE0_ARB);
+ }
}
#endif