Skip to content

Commit dd9b9d4

Browse files
castholmslouken
authored andcommitted
Check if GL_OES_EGL_image_external is supported before trying to use it
1 parent 7ec13a2 commit dd9b9d4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/render/opengles2/SDL_render_gles2.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ typedef struct GLES2_RenderData
173173

174174
bool debug_enabled;
175175

176+
bool GL_OES_EGL_image_external_supported;
176177
bool GL_EXT_blend_minmax_supported;
177178

178179
#define SDL_PROC(ret, func, params) ret (APIENTRY *func) params;
@@ -1623,9 +1624,12 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
16231624
#endif
16241625
#ifdef GL_TEXTURE_EXTERNAL_OES
16251626
case SDL_PIXELFORMAT_EXTERNAL_OES:
1626-
format = GL_NONE;
1627-
type = GL_NONE;
1628-
break;
1627+
if (renderdata->GL_OES_EGL_image_external_supported) {
1628+
format = GL_NONE;
1629+
type = GL_NONE;
1630+
break;
1631+
}
1632+
SDL_FALLTHROUGH;
16291633
#endif
16301634
default:
16311635
return SDL_SetError("Texture format not supported");
@@ -2249,7 +2253,11 @@ static bool GLES2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
22492253
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV21);
22502254
#endif
22512255
#ifdef GL_TEXTURE_EXTERNAL_OES
2252-
if (GLES2_CacheShader(data, GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES, GL_FRAGMENT_SHADER)) {
2256+
if (SDL_GL_ExtensionSupported("GL_OES_EGL_image_external")) {
2257+
data->GL_OES_EGL_image_external_supported = true;
2258+
if (!GLES2_CacheShader(data, GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES, GL_FRAGMENT_SHADER)) {
2259+
goto error;
2260+
}
22532261
SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_EXTERNAL_OES);
22542262
}
22552263
#endif

0 commit comments

Comments
 (0)