video: check graphics flags the same way in SDL_RecreateWindow as in SDL_CreateWindow - single check to validate the graphics flags - check it before tearing down the window
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
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 1945860..51e282f 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1874,6 +1874,13 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
SDL_bool loaded_vulkan = SDL_FALSE;
SDL_bool need_vulkan_unload = SDL_FALSE;
SDL_bool need_vulkan_load = SDL_FALSE;
+ Uint32 graphics_flags;
+
+ /* ensure no more than one of these flags is set */
+ graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN);
+ if ((graphics_flags & (graphics_flags - 1)) != 0) {
+ return SDL_SetError("Conflicting window flags specified");
+ }
if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
return SDL_ContextNotSupported("OpenGL");
@@ -1937,18 +1944,6 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
need_vulkan_load = SDL_TRUE;
}
- if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
- return SDL_SetError("Vulkan and OpenGL not supported on same window");
- }
-
- if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) {
- return SDL_SetError("Metal and OpenGL not supported on same window");
- }
-
- if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) {
- return SDL_SetError("Metal and Vulkan not supported on same window");
- }
-
if (need_gl_unload) {
SDL_GL_UnloadLibrary();
}