1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Examples: SDL+Vulkan: handle swap chain resize even without Vulkan returning VK_SUBOPTIMAL_KHR (#7671)

This commit is contained in:
ocornut 2024-06-10 15:04:40 +02:00
parent a47bfb1b5b
commit 7538ca6f40
2 changed files with 10 additions and 12 deletions

View File

@ -43,8 +43,9 @@ Breaking changes:
Other changes: Other changes:
- Examples: GLFW+Vulkan: handle swap chain resize even without Vulkan returning - Examples: GLFW+Vulkan, SDL+Vulkan: handle swap chain resize even without Vulkan
VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671) [@AndreiNego] returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
[@AndreiNego, @ocornut]
----------------------------------------------------------------------- -----------------------------------------------------------------------

View File

@ -494,18 +494,15 @@ int main(int, char**)
} }
// Resize swap chain? // Resize swap chain?
if (g_SwapChainRebuild) int fb_width, fb_height;
{ SDL_GetWindowSize(window, &fb_width, &fb_height);
int width, height; if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
SDL_GetWindowSize(window, &width, &height);
if (width > 0 && height > 0)
{ {
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount); ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount); ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount);
g_MainWindowData.FrameIndex = 0; g_MainWindowData.FrameIndex = 0;
g_SwapChainRebuild = false; g_SwapChainRebuild = false;
} }
}
// Start the Dear ImGui frame // Start the Dear ImGui frame
ImGui_ImplVulkan_NewFrame(); ImGui_ImplVulkan_NewFrame();