|
|
@ -240,7 +240,7 @@ static void CleanupVulkanWindow()
|
|
|
|
ImGui_ImplVulkanH_DestroyWindow(g_Instance, g_Device, &g_MainWindowData, g_Allocator);
|
|
|
|
ImGui_ImplVulkanH_DestroyWindow(g_Instance, g_Device, &g_MainWindowData, g_Allocator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void FrameRender(ImGui_ImplVulkanH_Window* wd)
|
|
|
|
static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
VkResult err;
|
|
|
|
VkResult err;
|
|
|
|
|
|
|
|
|
|
|
@ -278,8 +278,8 @@ static void FrameRender(ImGui_ImplVulkanH_Window* wd)
|
|
|
|
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
|
|
|
|
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Record Imgui Draw Data and draw funcs into command buffer
|
|
|
|
// Record dear imgui primitives into command buffer
|
|
|
|
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), fd->CommandBuffer);
|
|
|
|
ImGui_ImplVulkan_RenderDrawData(draw_data, fd->CommandBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
// Submit command buffer
|
|
|
|
// Submit command buffer
|
|
|
|
vkCmdEndRenderPass(fd->CommandBuffer);
|
|
|
|
vkCmdEndRenderPass(fd->CommandBuffer);
|
|
|
@ -447,13 +447,17 @@ int main(int, char**)
|
|
|
|
done = true;
|
|
|
|
done = true;
|
|
|
|
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window))
|
|
|
|
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Note: your own application may rely on SDL_WINDOWEVENT_MINIMIZED/SDL_WINDOWEVENT_RESTORED to skip updating all-together.
|
|
|
|
|
|
|
|
// Here ImGui_ImplSDL2_NewFrame() will set io.DisplaySize to zero which will disable rendering but let application run.
|
|
|
|
|
|
|
|
// Please note that you can't Present into a minimized window.
|
|
|
|
g_SwapChainResizeWidth = (int)event.window.data1;
|
|
|
|
g_SwapChainResizeWidth = (int)event.window.data1;
|
|
|
|
g_SwapChainResizeHeight = (int)event.window.data2;
|
|
|
|
g_SwapChainResizeHeight = (int)event.window.data2;
|
|
|
|
g_SwapChainRebuild = true;
|
|
|
|
g_SwapChainRebuild = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (g_SwapChainRebuild)
|
|
|
|
// Resize swap chain?
|
|
|
|
|
|
|
|
if (g_SwapChainRebuild && g_SwapChainResizeWidth > 0 && g_SwapChainResizeHeight > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
g_SwapChainRebuild = false;
|
|
|
|
g_SwapChainRebuild = false;
|
|
|
|
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
|
|
|
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
|
|
@ -505,10 +509,13 @@ int main(int, char**)
|
|
|
|
|
|
|
|
|
|
|
|
// Rendering
|
|
|
|
// Rendering
|
|
|
|
ImGui::Render();
|
|
|
|
ImGui::Render();
|
|
|
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
|
|
|
ImDrawData* draw_data = ImGui::GetDrawData();
|
|
|
|
FrameRender(wd);
|
|
|
|
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
|
|
|
|
|
|
|
if (!is_minimized)
|
|
|
|
FramePresent(wd);
|
|
|
|
{
|
|
|
|
|
|
|
|
FrameRender(wd, draw_data);
|
|
|
|
|
|
|
|
FramePresent(wd);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
// Cleanup
|
|
|
|