diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 45965e32d..18b7bfc58 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -202,6 +202,22 @@ typedef struct { } SDL_WindowTextureData; +static Uint32 +SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) +{ +#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ + if (_this->GL_CreateContext != NULL) { + return SDL_WINDOW_OPENGL; + } +#endif +#if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__) + if (_this->Metal_CreateView != NULL) { + return SDL_WINDOW_METAL; + } +#endif + return 0; +} + static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) { @@ -1635,16 +1651,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) /* Some platforms have certain graphics backends enabled by default */ if (!graphics_flags && !SDL_IsVideoContextExternal()) { -#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ - if (_this->GL_CreateContext != NULL) { - flags |= SDL_WINDOW_OPENGL; - } -#endif -#if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__) - if (_this->Metal_CreateView != NULL) { - flags |= SDL_WINDOW_METAL; - } -#endif + flags |= SDL_DefaultGraphicsBackends(_this); } if (flags & SDL_WINDOW_OPENGL) {