SDL_RecreateWindow: allow clearing VULKAN when recreating 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 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
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 65aafc6..9f5bbb2 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1674,6 +1674,9 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
SDL_bool loaded_opengl = SDL_FALSE;
SDL_bool need_gl_unload = SDL_FALSE;
SDL_bool need_gl_load = SDL_FALSE;
+ SDL_bool loaded_vulkan = SDL_FALSE;
+ SDL_bool need_vulkan_unload = SDL_FALSE;
+ SDL_bool need_vulkan_load = SDL_FALSE;
if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
return SDL_SetError("OpenGL support is either not configured in SDL "
@@ -1728,8 +1731,14 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
}
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
- SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
- return -1;
+ if (flags & SDL_WINDOW_VULKAN) {
+ need_vulkan_load = SDL_TRUE;
+ } else {
+ need_vulkan_unload = SDL_TRUE;
+ }
+ } else if (window->flags & SDL_WINDOW_VULKAN) {
+ need_vulkan_unload = SDL_TRUE;
+ need_vulkan_load = SDL_TRUE;
}
if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
@@ -1751,6 +1760,10 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
SDL_GL_UnloadLibrary();
}
+ if (need_vulkan_unload) {
+ SDL_Vulkan_UnloadLibrary();
+ }
+
if (need_gl_load) {
if (SDL_GL_LoadLibrary(NULL) < 0) {
return -1;
@@ -1758,6 +1771,13 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
loaded_opengl = SDL_TRUE;
}
+ if (need_vulkan_unload) {
+ if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
+ return -1;
+ }
+ loaded_vulkan = SDL_TRUE;
+ }
+
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
window->is_destroying = SDL_FALSE;
@@ -1768,6 +1788,10 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
SDL_GL_UnloadLibrary();
window->flags &= ~SDL_WINDOW_OPENGL;
}
+ if (loaded_vulkan) {
+ SDL_Vulkan_UnloadLibrary();
+ window->flags &= ~SDL_WINDOW_VULKAN;
+ }
return -1;
}
}