Browse Source

ensure that SDL2 does not set conflicting window flags (thanks @pionere!)

Sam Lantinga 2 years ago
parent
commit
fcc994e132
1 changed files with 17 additions and 10 deletions
  1. 17 10
      src/video/SDL_video.c

+ 17 - 10
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) {