From f2c7f3b200d82f3965bedbe4f52d6082fb74d1be Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 6 Mar 2020 17:28:32 +0100 Subject: [PATCH] Viewports: Renamed UpdatePlatformWindows > PlatformWindowsUpdate, RenderPlatformWindowsDefault -> PlatformWindowsRender, DestroyPlatformWindows > PlatformWindowsDestroy (#1542) --- docs/CHANGELOG.txt | 2 +- examples/example_glfw_opengl2/main.cpp | 4 +-- examples/example_glfw_opengl3/main.cpp | 4 +-- examples/example_glfw_vulkan/main.cpp | 4 +-- examples/example_sdl_directx11/main.cpp | 4 +-- examples/example_sdl_opengl2/main.cpp | 4 +-- examples/example_sdl_opengl3/main.cpp | 4 +-- examples/example_sdl_vulkan/main.cpp | 4 +-- examples/example_win32_directx10/main.cpp | 4 +-- examples/example_win32_directx11/main.cpp | 4 +-- examples/example_win32_directx12/main.cpp | 4 +-- examples/example_win32_directx9/main.cpp | 4 +-- examples/imgui_impl_dx10.cpp | 2 +- examples/imgui_impl_dx11.cpp | 2 +- examples/imgui_impl_dx12.cpp | 2 +- examples/imgui_impl_dx9.cpp | 2 +- examples/imgui_impl_glfw.cpp | 2 +- examples/imgui_impl_opengl2.cpp | 2 +- examples/imgui_impl_opengl3.cpp | 2 +- examples/imgui_impl_vulkan.cpp | 2 +- examples/imgui_impl_win32.cpp | 2 +- imgui.cpp | 36 ++++++++++---------- imgui.h | 40 +++++++++++------------ imgui_internal.h | 2 +- 24 files changed, 71 insertions(+), 71 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 0289741a9..c1810abaa 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -82,7 +82,7 @@ Other changes: - Added GetWindowDpiScale(). - Added GetOverlayDrawList(ImGuiViewport* viewport). The no-parameter version of GetOverlayDrawList() return the overlay for the current window's viewport. -- Added UpdatePlatformWindows(), RenderPlatformWindows(), DestroyPlatformWindows() for usage for application core. +- Added PlatformWindowsUpdate(), PlatformWindowsRender(), PlatformWindowsDestroy() for usage for application core. - Added FindViewportByID(), FindViewportByPlatformHandle() for usage by back-ends. - Added ImGuiConfigFlags_ViewportsEnable configuration flag and other viewport options. - Added io.ConfigViewportsNoAutoMerge, io.ConfigViewportsNoTaskBarIcon, io.ConfigViewportsNoDecoration, io.ConfigViewportsNoDefaultParent options. diff --git a/examples/example_glfw_opengl2/main.cpp b/examples/example_glfw_opengl2/main.cpp index 051d4281b..585db73fe 100644 --- a/examples/example_glfw_opengl2/main.cpp +++ b/examples/example_glfw_opengl2/main.cpp @@ -160,8 +160,8 @@ int main(int, char**) if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { GLFWwindow* backup_current_context = glfwGetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); glfwMakeContextCurrent(backup_current_context); } diff --git a/examples/example_glfw_opengl3/main.cpp b/examples/example_glfw_opengl3/main.cpp index 0f29f849f..b8de5cbe0 100644 --- a/examples/example_glfw_opengl3/main.cpp +++ b/examples/example_glfw_opengl3/main.cpp @@ -205,8 +205,8 @@ int main(int, char**) if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { GLFWwindow* backup_current_context = glfwGetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); glfwMakeContextCurrent(backup_current_context); } diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp index da23d2470..f30219f67 100644 --- a/examples/example_glfw_vulkan/main.cpp +++ b/examples/example_glfw_vulkan/main.cpp @@ -525,8 +525,8 @@ int main(int, char**) // Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); } FramePresent(wd); diff --git a/examples/example_sdl_directx11/main.cpp b/examples/example_sdl_directx11/main.cpp index 60c06245a..ea2e85a5c 100644 --- a/examples/example_sdl_directx11/main.cpp +++ b/examples/example_sdl_directx11/main.cpp @@ -166,8 +166,8 @@ int main(int, char**) // Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); } g_pSwapChain->Present(1, 0); // Present with vsync diff --git a/examples/example_sdl_opengl2/main.cpp b/examples/example_sdl_opengl2/main.cpp index aa7656346..78b0b220c 100644 --- a/examples/example_sdl_opengl2/main.cpp +++ b/examples/example_sdl_opengl2/main.cpp @@ -158,8 +158,8 @@ int main(int, char**) { SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow(); SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); SDL_GL_MakeCurrent(backup_current_window, backup_current_context); } diff --git a/examples/example_sdl_opengl3/main.cpp b/examples/example_sdl_opengl3/main.cpp index af0892870..e8f7441b5 100644 --- a/examples/example_sdl_opengl3/main.cpp +++ b/examples/example_sdl_opengl3/main.cpp @@ -207,8 +207,8 @@ int main(int, char**) { SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow(); SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); SDL_GL_MakeCurrent(backup_current_window, backup_current_context); } diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp index 7d84f34af..ec99439bd 100644 --- a/examples/example_sdl_vulkan/main.cpp +++ b/examples/example_sdl_vulkan/main.cpp @@ -522,8 +522,8 @@ int main(int, char**) // Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); } FramePresent(wd); diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index 284bf7874..f30b26822 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -159,8 +159,8 @@ int main(int, char**) // Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); } g_pSwapChain->Present(1, 0); // Present with vsync diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index d3828ff94..07cf519dd 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -166,8 +166,8 @@ int main(int, char**) // Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); } g_pSwapChain->Present(1, 0); // Present with vsync diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index 259c30269..6c1e3deb9 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -210,8 +210,8 @@ int main(int, char**) // Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(NULL, (void*)g_pd3dCommandList); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(NULL, (void*)g_pd3dCommandList); } g_pSwapChain->Present(1, 0); // Present with vsync diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index d96e5c481..3be45fa07 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -165,8 +165,8 @@ int main(int, char**) // Update and Render additional Platform Windows if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); + ImGui::PlatformWindowsUpdate(); + ImGui::PlatformWindowsRender(); } HRESULT result = g_pd3dDevice->Present(NULL, NULL, NULL, NULL); diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index 95dc6fd28..852a908ef 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -655,6 +655,6 @@ void ImGui_ImplDX10_InitPlatformInterface() void ImGui_ImplDX10_ShutdownPlatformInterface() { - ImGui::DestroyPlatformWindows(); + ImGui::PlatformWindowsDestroy(); } diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index ffd05625b..2a40cc583 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -671,5 +671,5 @@ static void ImGui_ImplDX11_InitPlatformInterface() static void ImGui_ImplDX11_ShutdownPlatformInterface() { - ImGui::DestroyPlatformWindows(); + ImGui::PlatformWindowsDestroy(); } diff --git a/examples/imgui_impl_dx12.cpp b/examples/imgui_impl_dx12.cpp index 3ead29c5a..57ac0afe1 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/examples/imgui_impl_dx12.cpp @@ -947,5 +947,5 @@ void ImGui_ImplDX12_InitPlatformInterface() void ImGui_ImplDX12_ShutdownPlatformInterface() { - ImGui::DestroyPlatformWindows(); + ImGui::PlatformWindowsDestroy(); } diff --git a/examples/imgui_impl_dx9.cpp b/examples/imgui_impl_dx9.cpp index 27435cbc3..0a22f9228 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/examples/imgui_impl_dx9.cpp @@ -423,7 +423,7 @@ static void ImGui_ImplDX9_InitPlatformInterface() static void ImGui_ImplDX9_ShutdownPlatformInterface() { - ImGui::DestroyPlatformWindows(); + ImGui::PlatformWindowsDestroy(); } static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows() diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index bcbee4365..462c35fef 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -598,7 +598,7 @@ static LRESULT CALLBACK WndProcNoInputs(HWND hWnd, UINT msg, WPARAM wParam, LPAR // Let mouse pass-through the window. This will allow the back-end to set io.MouseHoveredViewport properly (which is OPTIONAL). // The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging. // If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in - // your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system. + // your main loop after calling PlatformWindowsUpdate(). Iterate all viewports/platform windows and pass the flag to your windowing system. ImGuiViewport* viewport = (ImGuiViewport*)::GetPropA(hWnd, "IMGUI_VIEWPORT"); if (viewport->Flags & ImGuiViewportFlags_NoInputs) return HTTRANSPARENT; diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp index ba440957f..d3a264a3e 100644 --- a/examples/imgui_impl_opengl2.cpp +++ b/examples/imgui_impl_opengl2.cpp @@ -283,5 +283,5 @@ static void ImGui_ImplOpenGL2_InitPlatformInterface() static void ImGui_ImplOpenGL2_ShutdownPlatformInterface() { - ImGui::DestroyPlatformWindows(); + ImGui::PlatformWindowsDestroy(); } diff --git a/examples/imgui_impl_opengl3.cpp b/examples/imgui_impl_opengl3.cpp index 6eb38c7ca..624c30ffe 100644 --- a/examples/imgui_impl_opengl3.cpp +++ b/examples/imgui_impl_opengl3.cpp @@ -712,5 +712,5 @@ static void ImGui_ImplOpenGL3_InitPlatformInterface() static void ImGui_ImplOpenGL3_ShutdownPlatformInterface() { - ImGui::DestroyPlatformWindows(); + ImGui::PlatformWindowsDestroy(); } diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index 3d0ad9a1e..6482ffd88 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -1445,5 +1445,5 @@ void ImGui_ImplVulkan_InitPlatformInterface() void ImGui_ImplVulkan_ShutdownPlatformInterface() { - ImGui::DestroyPlatformWindows(); + ImGui::PlatformWindowsDestroy(); } diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index 716709a37..b5b272d32 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -798,7 +798,7 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd, // Let mouse pass-through the window. This will allow the back-end to set io.MouseHoveredViewport properly (which is OPTIONAL). // The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging. // If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in - // your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system. + // your main loop after calling PlatformWindowsUpdate(). Iterate all viewports/platform windows and pass the flag to your windowing system. if (viewport->Flags & ImGuiViewportFlags_NoInputs) return HTTRANSPARENT; break; diff --git a/imgui.cpp b/imgui.cpp index 1331aef92..9d3688d66 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3912,7 +3912,7 @@ static void NewFrameSanityChecks() { if ((g.IO.BackendFlags & ImGuiBackendFlags_PlatformHasViewports) && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasViewports)) { - IM_ASSERT((g.FrameCount == 0 || g.FrameCount == g.FrameCountPlatformEnded) && "Forgot to call UpdatePlatformWindows() in main loop after EndFrame()? Check examples/ applications for reference."); + IM_ASSERT((g.FrameCount == 0 || g.FrameCount == g.FrameCountPlatformEnded) && "Forgot to call PlatformWindowsUpdate() in main loop after EndFrame()? Check examples/ applications for reference."); IM_ASSERT(g.PlatformIO.Platform_CreateWindow != NULL && "Platform init didn't install handlers?"); IM_ASSERT(g.PlatformIO.Platform_DestroyWindow != NULL && "Platform init didn't install handlers?"); IM_ASSERT(g.PlatformIO.Platform_GetWindowPos != NULL && "Platform init didn't install handlers?"); @@ -4233,7 +4233,7 @@ void ImGui::Shutdown(ImGuiContext* context) // Destroy platform windows ImGuiContext* backup_context = ImGui::GetCurrentContext(); SetCurrentContext(context); - DestroyPlatformWindows(); + PlatformWindowsDestroy(); SetCurrentContext(backup_context); // Shutdown extensions @@ -10582,13 +10582,13 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl // - UpdateViewportsEndFrame() [Internal] // - AddUpdateViewport() [Internal] // - UpdateSelectWindowViewport() [Internal] -// - UpdatePlatformWindows() -// - RenderPlatformWindowsDefault() +// - PlatformWindowsUpdate() +// - PlatformWindowsRender() // - FindPlatformMonitorForPos() [Internal] // - FindPlatformMonitorForRect() [Internal] // - UpdateViewportPlatformMonitor() [Internal] -// - DestroyPlatformWindow() [Internal] -// - DestroyPlatformWindows() +// - PlatformWindowsDestroyOne() [Internal] +// - PlatformWindowsDestroy() //----------------------------------------------------------------------------- ImGuiViewport* ImGui::GetMainViewport() @@ -10809,7 +10809,7 @@ static void ImGui::UpdateViewportsNewFrame() // Destroy IMGUI_DEBUG_LOG_VIEWPORT("Delete Viewport %08X (%s)\n", viewport->ID, viewport->Window ? viewport->Window->Name : "n/a"); - DestroyPlatformWindow(viewport); // In most circumstances the platform window will already be destroyed here. + PlatformWindowsDestroyOne(viewport); // In most circumstances the platform window will already be destroyed here. IM_ASSERT(g.PlatformIO.Viewports.contains(viewport) == false); IM_DELETE(viewport); n--; @@ -10820,7 +10820,7 @@ static void ImGui::UpdateViewportsNewFrame() if (viewports_enabled) { // Update Position and Size (from Platform Window to ImGui) if requested. - // We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities. + // We do it early in the frame instead of waiting for PlatformWindowsUpdate() to avoid a frame of lag when moving/resizing using OS facilities. if (!(viewport->Flags & ImGuiViewportFlags_Minimized) && platform_funcs_available) { if (viewport->PlatformRequestMove) @@ -10943,7 +10943,7 @@ static void ImGui::UpdateViewportsEndFrame() IM_ASSERT(viewport->Window != NULL); g.PlatformIO.Viewports.push_back(viewport); } - g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called + g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because PlatformWindowsUpdate() won't do it and may not even be called } // FIXME: We should ideally refactor the system to call this every frame (we currently don't) @@ -11135,11 +11135,11 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) } // Called by user at the end of the main loop, after EndFrame() -// This will handle the creation/update of all OS windows via function defined in the ImGuiPlatformIO api. -void ImGui::UpdatePlatformWindows() +// This will handle the creation/update of all OS windows via function defined in the ImGuiPlatformIO API. +void ImGui::PlatformWindowsUpdate() { ImGuiContext& g = *GImGui; - IM_ASSERT(g.FrameCountEnded == g.FrameCount && "Forgot to call Render() or EndFrame() before UpdatePlatformWindows()?"); + IM_ASSERT(g.FrameCountEnded == g.FrameCount && "Forgot to call Render() or EndFrame() before PlatformWindowsUpdate()?"); IM_ASSERT(g.FrameCountPlatformEnded < g.FrameCount); g.FrameCountPlatformEnded = g.FrameCount; if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)) @@ -11152,13 +11152,13 @@ void ImGui::UpdatePlatformWindows() ImGuiViewportP* viewport = g.Viewports[i]; // Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window - // (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy DestroyPlatformWindow to be made each frame) + // (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy PlatformWindowsDestroyOne to be made each frame) bool destroy_platform_window = false; destroy_platform_window |= (viewport->LastFrameActive < g.FrameCount - 1); destroy_platform_window |= (viewport->Window && !IsWindowActiveAndVisible(viewport->Window)); if (destroy_platform_window) { - DestroyPlatformWindow(viewport); + PlatformWindowsDestroyOne(viewport); continue; } @@ -11267,7 +11267,7 @@ void ImGui::UpdatePlatformWindows() // if ((platform_io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0) // MySwapBufferFunction(platform_io.Viewports[i], my_args); // -void ImGui::RenderPlatformWindowsDefault(void* platform_render_arg, void* renderer_render_arg) +void ImGui::PlatformWindowsRender(void* platform_render_arg, void* renderer_render_arg) { // Skip the main viewport (index 0), which is always fully handled by the application! ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); @@ -11341,7 +11341,7 @@ static void ImGui::UpdateViewportPlatformMonitor(ImGuiViewportP* viewport) viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetMainRect()); } -void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) +void ImGui::PlatformWindowsDestroyOne(ImGuiViewportP* viewport) { ImGuiContext& g = *GImGui; if (viewport->PlatformWindowCreated) @@ -11365,7 +11365,7 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) viewport->ClearRequestFlags(); } -void ImGui::DestroyPlatformWindows() +void ImGui::PlatformWindowsDestroy() { // We call the destroy window on every viewport (including the main viewport, index 0) to give a chance to the back-end // to clear any data they may have stored in e.g. PlatformUserData, RendererUserData. @@ -11375,7 +11375,7 @@ void ImGui::DestroyPlatformWindows() // crashing if it doesn't have data stored. ImGuiContext& g = *GImGui; for (int i = 0; i < g.Viewports.Size; i++) - DestroyPlatformWindow(g.Viewports[i]); + PlatformWindowsDestroyOne(g.Viewports[i]); } diff --git a/imgui.h b/imgui.h index b13f35355..f277e8ff0 100644 --- a/imgui.h +++ b/imgui.h @@ -779,11 +779,11 @@ namespace ImGui // Note: You may use GetWindowViewport() to get the current viewport of the current window. IMGUI_API ImGuiPlatformIO& GetPlatformIO(); // platform/renderer functions, for back-end to setup + viewports list. IMGUI_API ImGuiViewport* GetMainViewport(); // main viewport. same as GetPlatformIO().MainViewport == GetPlatformIO().Viewports[0]. - IMGUI_API void UpdatePlatformWindows(); // call in main loop. will call CreateWindow/ResizeWindow/etc. platform functions for each secondary viewport, and DestroyWindow for each inactive viewport. - IMGUI_API void RenderPlatformWindowsDefault(void* platform_render_arg = NULL, void* renderer_render_arg = NULL); // call in main loop. will call RenderWindow/SwapBuffers platform functions for each secondary viewport which doesn't have the ImGuiViewportFlags_Minimized flag set. May be reimplemented by user for custom rendering needs. - IMGUI_API void DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from back-end Shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext(). - IMGUI_API ImGuiViewport* FindViewportByID(ImGuiID id); // this is a helper for back-ends. - IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // this is a helper for back-ends. the type platform_handle is decided by the back-end (e.g. HWND, MyWindow*, GLFWwindow* etc.) + IMGUI_API void PlatformWindowsUpdate(); // call in main loop. will call CreateWindow/ResizeWindow/etc. platform functions for each secondary viewport, and DestroyWindow for each inactive viewport. + IMGUI_API void PlatformWindowsRender(void* platform_render_arg = NULL, void* renderer_render_arg = NULL); // call in main loop. will call RenderWindow/SwapBuffers platform functions for each secondary viewport which doesn't have the ImGuiViewportFlags_Minimized flag set. May be reimplemented by user for custom rendering needs. + IMGUI_API void PlatformWindowsDestroy(); // call DestroyWindow platform functions for all viewports. call from back-end Shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext(). + IMGUI_API ImGuiViewport* FindViewportByID(ImGuiID id); // helper for back-ends to find a viewport. + IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // helper for back-ends to find a viewport. the type platform_handle is decided by the back-end (e.g. HWND, MyWindow*, GLFWwindow* etc.) } // namespace ImGui @@ -2412,7 +2412,7 @@ struct ImFont // Steps to use multi-viewports in your application, when using a default back-end from the examples/ folder: // - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // - Back-end: The back-end initialization will setup all necessary ImGuiPlatformIO's functions and update monitors info every frame. -// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render(). +// - Application: In your main loop, call ImGui::PlatformWindowsUpdate(), ImGui::PlatformWindowsRender() after EndFrame() or Render(). // - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls. // // Steps to use multi-viewports in your application, when using a custom back-end: @@ -2424,18 +2424,18 @@ struct ImFont // Set 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports'. // Update ImGuiPlatformIO's Monitors list every frame. // Update MousePos every frame, in absolute coordinates. -// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render(). -// You may skip calling RenderPlatformWindowsDefault() if its API is not convenient for your needs. Read comments below. +// - Application: In your main loop, call ImGui::PlatformWindowsUpdate(), ImGui::PlatformWindowsRender() after EndFrame() or Render(). +// You may skip calling PlatformWindowsRender() if its API is not convenient for your needs. Read comments below. // - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls. // -// About ImGui::RenderPlatformWindowsDefault(): +// About ImGui::PlatformWindowsRender(): // - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default back-ends. // - You can check its simple source code to understand what it does. // It basically iterates secondary viewports and call 4 functions that are setup in ImGuiPlatformIO, if available: // Platform_RenderWindow(), Renderer_RenderWindow(), Platform_SwapBuffers(), Renderer_SwapBuffers() -// Those functions pointers exists only for the benefit of RenderPlatformWindowsDefault(). +// Those functions pointers exists only for the benefit of PlatformWindowsRender(). // - If you have very specific rendering needs (e.g. flipping multiple swap-chain simultaneously, unusual sync/threading issues, etc.), -// you may be tempted to ignore RenderPlatformWindowsDefault() and write customized code to perform your renderingg. +// you may be tempted to ignore PlatformWindowsRender() and write customized code to perform your renderingg. // You may decide to setup the platform_io's *RenderWindow and *SwapBuffers pointers and call your functions through those pointers, // or you may decide to never setup those pointers and call your code directly. They are a convenience, not an obligatory interface. //----------------------------------------------------------------------------- @@ -2451,10 +2451,10 @@ struct ImGuiPlatformIO // For reference, the second column shows which function are generally calling the Platform Functions: // N = ImGui::NewFrame() ~ beginning of the dear imgui frame: read info from platform/OS windows (latest size/position) // F = ImGui::Begin(), ImGui::EndFrame() ~ during the dear imgui frame - // U = ImGui::UpdatePlatformWindows() ~ after the dear imgui frame: create and update all platform/OS windows - // R = ImGui::RenderPlatformWindowsDefault() ~ render - // D = ImGui::DestroyPlatformWindows() ~ shutdown - // The general idea is that NewFrame() we will read the current Platform/OS state, and UpdatePlatformWindows() will write to it. + // U = ImGui::PlatformWindowsUpdate() ~ after the dear imgui frame: create and update all platform/OS windows + // R = ImGui::PlatformWindowsRender() ~ render (read comment above about this function!) + // D = ImGui::PlatformWindowsDestroy() ~ shutdown + // The general idea is that NewFrame() we will read the current Platform/OS state, and PlatformWindowsUpdate() will write to it. // // The functions are designed so we can mix and match 2 imgui_impl_xxxx files, one for the Platform (~window/input handling), one for Renderer. // Custom engine back-ends will often provide both Platform and Renderer interfaces and so may not need to use all functions. @@ -2473,9 +2473,9 @@ struct ImGuiPlatformIO bool (*Platform_GetWindowMinimized)(ImGuiViewport* vp); // N . . . . // Get platform window minimized state. When minimized, we generally won't attempt to get/set size and contents will be culled more easily void (*Platform_SetWindowTitle)(ImGuiViewport* vp, const char* str); // . . U . . // Set platform window title (given an UTF-8 string) void (*Platform_SetWindowAlpha)(ImGuiViewport* vp, float alpha); // . . U . . // (Optional) Setup window transparency - void (*Platform_UpdateWindow)(ImGuiViewport* vp); // . . U . . // (Optional) Called by UpdatePlatformWindows(). Optional hook to allow the platform back-end from doing general book-keeping every frame. - void (*Platform_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Main rendering (platform side! This is often unused, or just setting a "current" context for OpenGL bindings). 'render_arg' is the value passed to RenderPlatformWindowsDefault(). - void (*Platform_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers (platform side! This is often unused!). 'render_arg' is the value passed to RenderPlatformWindowsDefault(). + void (*Platform_UpdateWindow)(ImGuiViewport* vp); // . . U . . // (Optional) Called by PlatformWindowsUpdate(). Optional hook to allow the platform back-end from doing general book-keeping every frame. + void (*Platform_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Main rendering (platform side! This is often unused, or just setting a "current" context for OpenGL bindings). 'render_arg' is the value passed to PlatformWindowsRender(). + void (*Platform_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers (platform side! This is often unused!). 'render_arg' is the value passed to PlatformWindowsRender(). float (*Platform_GetWindowDpiScale)(ImGuiViewport* vp); // N . . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI. void (*Platform_OnChangedViewport)(ImGuiViewport* vp); // . F . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Called during Begin() every time the viewport we are outputting into changes, so back-end has a chance to swap fonts to adjust style. void (*Platform_SetImeInputPos)(ImGuiViewport* vp, ImVec2 pos); // . F . . . // (Optional) Set IME (Input Method Editor, e.g. for Asian languages) input position, so text preview appears over the imgui input box. FIXME: The call timing of this is inconsistent because we want to support without multi-viewports. @@ -2485,8 +2485,8 @@ struct ImGuiPlatformIO void (*Renderer_CreateWindow)(ImGuiViewport* vp); // . . U . . // Create swap chain, frame buffers etc. (called after Platform_CreateWindow) void (*Renderer_DestroyWindow)(ImGuiViewport* vp); // N . U . D // Destroy swap chain, frame buffers etc. (called before Platform_DestroyWindow) void (*Renderer_SetWindowSize)(ImGuiViewport* vp, ImVec2 size); // . . U . . // Resize swap chain, frame buffers etc. (called after Platform_SetWindowSize) - void (*Renderer_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Clear framebuffer, setup render target, then render the viewport->DrawData. 'render_arg' is the value passed to RenderPlatformWindowsDefault(). - void (*Renderer_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to RenderPlatformWindowsDefault(). + void (*Renderer_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Clear framebuffer, setup render target, then render the viewport->DrawData. 'render_arg' is the value passed to PlatformWindowsRender(). + void (*Renderer_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to PlatformWindowsRender(). // (Optional) Monitor list // - Updated by: app/back-end. Update every frame to dynamically support changing monitor or DPI configuration. diff --git a/imgui_internal.h b/imgui_internal.h index 2e82ed413..9b71f8060 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1869,7 +1869,7 @@ namespace ImGui // Viewports IMGUI_API void TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos); IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale); - IMGUI_API void DestroyPlatformWindow(ImGuiViewportP* viewport); + IMGUI_API void PlatformWindowsDestroyOne(ImGuiViewportP* viewport); IMGUI_API void ShowViewportThumbnails(); // Settings