diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 82491f6717183..bf1deb70f782b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -225,6 +225,7 @@ Other Changes: - Backends: OpenGL3: Added support for glad2 loader. (#3330) [@moritz-h] - Backends: Allegro 5: Fixed horizontal scrolling direction with mouse wheel / touch pads (it seems like Allegro 5 reports it differently from GLFW and SDL). (#3394, #2424, #1463) [@nobody-special666] +- Examples: Vulkan: Reworked buffer resize handling, fix for Linux/X11. (#3390, #2626) [@RoryO] - Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO] - CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon] diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp index ce3bf33b42dfc..d0fc8839b99d3 100644 --- a/examples/example_glfw_vulkan/main.cpp +++ b/examples/example_glfw_vulkan/main.cpp @@ -42,7 +42,6 @@ static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE; static ImGui_ImplVulkanH_Window g_MainWindowData; static int g_MinImageCount = 2; -static GLFWwindow* g_Window; static bool g_SwapChainRebuild = false; static int g_SwapChainResizeWidth = 0; static int g_SwapChainResizeHeight = 0; @@ -345,7 +344,7 @@ int main(int, char**) return 1; glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - g_Window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Vulkan example", NULL, NULL); + GLFWwindow *window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Vulkan example", NULL, NULL); // Setup Vulkan if (!glfwVulkanSupported()) @@ -359,12 +358,12 @@ int main(int, char**) // Create Window Surface VkSurfaceKHR surface; - VkResult err = glfwCreateWindowSurface(g_Instance, g_Window, g_Allocator, &surface); + VkResult err = glfwCreateWindowSurface(g_Instance, window, g_Allocator, &surface); check_vk_result(err); // Create Framebuffers int w, h; - glfwGetFramebufferSize(g_Window, &w, &h); + glfwGetFramebufferSize(window, &w, &h); ImGui_ImplVulkanH_Window* wd = &g_MainWindowData; SetupVulkanWindow(wd, surface, w, h); @@ -392,7 +391,7 @@ int main(int, char**) } // Setup Platform/Renderer bindings - ImGui_ImplGlfw_InitForVulkan(g_Window, true); + ImGui_ImplGlfw_InitForVulkan(window, true); ImGui_ImplVulkan_InitInfo init_info = {}; init_info.Instance = g_Instance; init_info.PhysicalDevice = g_PhysicalDevice; @@ -462,7 +461,7 @@ int main(int, char**) wd->ClearValue.color.float32[3] = clear_color.w; // Main loop - while (!glfwWindowShouldClose(g_Window)) + while (!glfwWindowShouldClose(window)) { // Poll and handle events (inputs, window resize, etc.) // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. @@ -545,9 +544,9 @@ int main(int, char**) // Present Main Platform Window if (!main_is_minimized) - FramePresent(wd); - } + FramePresent(wd, window); + } // Cleanup err = vkDeviceWaitIdle(g_Device); check_vk_result(err); @@ -558,7 +557,7 @@ int main(int, char**) CleanupVulkanWindow(); CleanupVulkan(); - glfwDestroyWindow(g_Window); + glfwDestroyWindow(window); glfwTerminate(); return 0; diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp index f518bffabf376..f988cf85a54dc 100644 --- a/examples/example_sdl_vulkan/main.cpp +++ b/examples/example_sdl_vulkan/main.cpp @@ -37,7 +37,6 @@ static uint32_t g_MinImageCount = 2; static bool g_SwapChainRebuild = false; static int g_SwapChainResizeWidth = 0; static int g_SwapChainResizeHeight = 0; -static SDL_Window* g_Window; static void check_vk_result(VkResult err) { @@ -335,20 +334,20 @@ int main(int, char**) // Setup window SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - g_Window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); + SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); // Setup Vulkan uint32_t extensions_count = 0; - SDL_Vulkan_GetInstanceExtensions(g_Window, &extensions_count, NULL); + SDL_Vulkan_GetInstanceExtensions(window, &extensions_count, NULL); const char** extensions = new const char*[extensions_count]; - SDL_Vulkan_GetInstanceExtensions(g_Window, &extensions_count, extensions); + SDL_Vulkan_GetInstanceExtensions(window, &extensions_count, extensions); SetupVulkan(extensions, extensions_count); delete[] extensions; // Create Window Surface VkSurfaceKHR surface; VkResult err; - if (SDL_Vulkan_CreateSurface(g_Window, g_Instance, &surface) == 0) + if (SDL_Vulkan_CreateSurface(window, g_Instance, &surface) == 0) { printf("Failed to create Vulkan surface.\n"); return 1; @@ -356,7 +355,7 @@ int main(int, char**) // Create Framebuffers int w, h; - SDL_GetWindowSize(g_Window, &w, &h); + SDL_GetWindowSize(window, &w, &h); ImGui_ImplVulkanH_Window* wd = &g_MainWindowData; SetupVulkanWindow(wd, surface, w, h); @@ -384,7 +383,7 @@ int main(int, char**) } // Setup Platform/Renderer bindings - ImGui_ImplSDL2_InitForVulkan(g_Window); + ImGui_ImplSDL2_InitForVulkan(window); ImGui_ImplVulkan_InitInfo init_info = {}; init_info.Instance = g_Instance; init_info.PhysicalDevice = g_PhysicalDevice; @@ -481,7 +480,7 @@ int main(int, char**) // Start the Dear ImGui frame ImGui_ImplVulkan_NewFrame(); - ImGui_ImplSDL2_NewFrame(g_Window); + ImGui_ImplSDL2_NewFrame(window); ImGui::NewFrame(); // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). @@ -544,7 +543,7 @@ int main(int, char**) // Present Main Platform Window if (!main_is_minimized) - FramePresent(wd); + FramePresent(wd, window); } // Cleanup @@ -557,7 +556,7 @@ int main(int, char**) CleanupVulkanWindow(); CleanupVulkan(); - SDL_DestroyWindow(g_Window); + SDL_DestroyWindow(window); SDL_Quit(); return 0;