mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
This commit is contained in:
parent
9b50e691ed
commit
df89a16d26
@ -51,6 +51,7 @@ Other Changes:
|
|||||||
(This is also necessary to support full multi/range-select/drag and drop operations.)
|
(This is also necessary to support full multi/range-select/drag and drop operations.)
|
||||||
- Metrics: Various tweaks, listing windows front-to-back, greying inactive items when possible.
|
- Metrics: Various tweaks, listing windows front-to-back, greying inactive items when possible.
|
||||||
- Demo: Add simple InputText() callbacks demo (aside from the more elaborate ones in 'Examples->Console').
|
- Demo: Add simple InputText() callbacks demo (aside from the more elaborate ones in 'Examples->Console').
|
||||||
|
- Examples: Vulkan: Reworked buffer resize handling, fix for Linux/X11. (#3390, #2626) [@RoryO]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
@ -310,7 +310,7 @@ static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
static void FramePresent(ImGui_ImplVulkanH_Window* wd, GLFWwindow* window)
|
||||||
{
|
{
|
||||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||||
VkPresentInfoKHR info = {};
|
VkPresentInfoKHR info = {};
|
||||||
@ -321,6 +321,12 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
|||||||
info.pSwapchains = &wd->Swapchain;
|
info.pSwapchains = &wd->Swapchain;
|
||||||
info.pImageIndices = &wd->FrameIndex;
|
info.pImageIndices = &wd->FrameIndex;
|
||||||
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
glfwGetFramebufferSize(window, &g_SwapChainResizeWidth, &g_SwapChainResizeHeight);
|
||||||
|
g_SwapChainRebuild = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
||||||
}
|
}
|
||||||
@ -330,13 +336,6 @@ static void glfw_error_callback(int error, const char* description)
|
|||||||
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
|
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void glfw_resize_callback(GLFWwindow*, int w, int h)
|
|
||||||
{
|
|
||||||
g_SwapChainRebuild = true;
|
|
||||||
g_SwapChainResizeWidth = w;
|
|
||||||
g_SwapChainResizeHeight = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
// Setup GLFW window
|
// Setup GLFW window
|
||||||
@ -365,7 +364,6 @@ int main(int, char**)
|
|||||||
// Create Framebuffers
|
// Create Framebuffers
|
||||||
int w, h;
|
int w, h;
|
||||||
glfwGetFramebufferSize(window, &w, &h);
|
glfwGetFramebufferSize(window, &w, &h);
|
||||||
glfwSetFramebufferSizeCallback(window, glfw_resize_callback);
|
|
||||||
ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
|
ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
|
||||||
SetupVulkanWindow(wd, surface, w, h);
|
SetupVulkanWindow(wd, surface, w, h);
|
||||||
|
|
||||||
@ -515,7 +513,7 @@ int main(int, char**)
|
|||||||
{
|
{
|
||||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
FrameRender(wd, draw_data);
|
FrameRender(wd, draw_data);
|
||||||
FramePresent(wd);
|
FramePresent(wd, window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
static void FramePresent(ImGui_ImplVulkanH_Window* wd, SDL_Window* window)
|
||||||
{
|
{
|
||||||
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore;
|
||||||
VkPresentInfoKHR info = {};
|
VkPresentInfoKHR info = {};
|
||||||
@ -313,6 +313,12 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
|||||||
info.pSwapchains = &wd->Swapchain;
|
info.pSwapchains = &wd->Swapchain;
|
||||||
info.pImageIndices = &wd->FrameIndex;
|
info.pImageIndices = &wd->FrameIndex;
|
||||||
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
VkResult err = vkQueuePresentKHR(g_Queue, &info);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
SDL_GetWindowSize(window, &g_SwapChainResizeWidth, &g_SwapChainResizeHeight);
|
||||||
|
g_SwapChainRebuild = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
||||||
}
|
}
|
||||||
@ -445,15 +451,6 @@ int main(int, char**)
|
|||||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
done = true;
|
done = true;
|
||||||
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_SwapChainResizeHeight = (int)event.window.data2;
|
|
||||||
g_SwapChainRebuild = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize swap chain?
|
// Resize swap chain?
|
||||||
@ -515,7 +512,7 @@ int main(int, char**)
|
|||||||
{
|
{
|
||||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
FrameRender(wd, draw_data);
|
FrameRender(wd, draw_data);
|
||||||
FramePresent(wd);
|
FramePresent(wd, window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user