Backends: SDL/Viewports: Fix crash when SDL backend is used with DirectX graphics API and system does not support Vulkan.

We must pass this flag only when we intend to render using vulkan backend.
This commit is contained in:
Rokas Kupstys 2020-01-29 11:40:49 +02:00 committed by omar
parent 3b828e6f96
commit 7794b104c5

View File

@ -74,6 +74,7 @@ static bool g_MousePressed[3] = { false, false, false };
static SDL_Cursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
static char* g_ClipboardTextData = NULL;
static bool g_MouseCanUseGlobalState = true;
static bool g_UseVulkan = false;
// Forward Declarations
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context);
@ -240,6 +241,7 @@ bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
#if !SDL_HAS_VULKAN
IM_ASSERT(0 && "Unsupported");
#endif
g_UseVulkan = true;
return ImGui_ImplSDL2_Init(window, NULL);
}
@ -467,7 +469,7 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
}
Uint32 sdl_flags = 0;
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : SDL_WINDOW_VULKAN;
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (g_UseVulkan ? SDL_WINDOW_VULKAN : 0);
sdl_flags |= SDL_GetWindowFlags(g_Window) & SDL_WINDOW_ALLOW_HIGHDPI;
sdl_flags |= SDL_WINDOW_HIDDEN;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;