SDL_RecreateWindow: allow clearing VULKAN when recreating the window

Sylvain Becker 2020-12-02 13:37:59 +01:00
parent 93fbab0fac
commit 035f8f2391
1 changed files with 26 additions and 2 deletions

View File

@ -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;
}
}