diff --git a/examples/imgui_impl_allegro5.cpp b/backends/imgui_impl_allegro5.cpp similarity index 97% rename from examples/imgui_impl_allegro5.cpp rename to backends/imgui_impl_allegro5.cpp index ca2cfae4..cadc4b7f 100644 --- a/examples/imgui_impl_allegro5.cpp +++ b/backends/imgui_impl_allegro5.cpp @@ -1,4 +1,4 @@ -// dear imgui: Renderer + Platform Binding for Allegro 5 +// dear imgui: Renderer + Platform Backend for Allegro 5 // (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) // Implemented features: @@ -9,9 +9,9 @@ // [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually. // [ ] Platform: Missing gamepad support. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui, Original Allegro 5 code by @birthggd +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -86,7 +86,6 @@ static void ImGui_ImplAllegro5_SetupRenderState(ImDrawData* draw_data) } // Render function. -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data) { // Avoid rendering when minimized @@ -253,7 +252,7 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display) { g_Display = display; - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5"; diff --git a/examples/imgui_impl_allegro5.h b/backends/imgui_impl_allegro5.h similarity index 82% rename from examples/imgui_impl_allegro5.h rename to backends/imgui_impl_allegro5.h index f41e4c90..ef91d4b3 100644 --- a/examples/imgui_impl_allegro5.h +++ b/backends/imgui_impl_allegro5.h @@ -1,4 +1,4 @@ -// dear imgui: Renderer + Platform Binding for Allegro 5 +// dear imgui: Renderer + Platform Backend for Allegro 5 // (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) // Implemented features: @@ -9,9 +9,9 @@ // [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually. // [ ] Platform: Missing gamepad support. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui, Original Allegro 5 code by @birthggd +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_dx10.cpp b/backends/imgui_impl_dx10.cpp similarity index 97% rename from examples/imgui_impl_dx10.cpp rename to backends/imgui_impl_dx10.cpp index 6d69a4a3..8f168efd 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/backends/imgui_impl_dx10.cpp @@ -1,14 +1,14 @@ -// dear imgui: Renderer for DirectX10 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX10 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -21,7 +21,7 @@ // 2018-07-13: DirectX10: Fixed unreleased resources in Init and Shutdown functions. // 2018-06-08: Misc: Extracted imgui_impl_dx10.cpp/.h away from the old combined DX10+Win32 example. // 2018-06-08: DirectX10: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-04-09: Misc: Fixed erroneous call to io.Fonts->ClearInputData() + ClearTexData() that was left in DX10 example but removed in 1.47 (Nov 2015) on other back-ends. +// 2018-04-09: Misc: Fixed erroneous call to io.Fonts->ClearInputData() + ClearTexData() that was left in DX10 example but removed in 1.47 (Nov 2015) on other backends. // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX10_RenderDrawData() in the .h file so you can call it yourself. // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. // 2016-05-07: DirectX10: Disabling depth-write. @@ -96,7 +96,6 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* } // Render function -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data) { // Avoid rendering when minimized @@ -504,7 +503,7 @@ void ImGui_ImplDX10_InvalidateDeviceObjects() bool ImGui_ImplDX10_Init(ID3D10Device* device) { - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_dx10"; io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. @@ -547,7 +546,7 @@ void ImGui_ImplDX10_NewFrame() //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- @@ -567,7 +566,7 @@ static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport) viewport->RendererUserData = data; // PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*). - // Some back-ends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. + // Some backends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle; IM_ASSERT(hwnd != 0); diff --git a/examples/imgui_impl_dx10.h b/backends/imgui_impl_dx10.h similarity index 73% rename from examples/imgui_impl_dx10.h rename to backends/imgui_impl_dx10.h index fcee65af..2905ef5d 100644 --- a/examples/imgui_impl_dx10.h +++ b/backends/imgui_impl_dx10.h @@ -1,14 +1,14 @@ -// dear imgui: Renderer for DirectX10 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX10 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_dx11.cpp b/backends/imgui_impl_dx11.cpp similarity index 97% rename from examples/imgui_impl_dx11.cpp rename to backends/imgui_impl_dx11.cpp index 7d4750ad..af862546 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/backends/imgui_impl_dx11.cpp @@ -1,14 +1,14 @@ -// dear imgui: Renderer for DirectX11 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX11 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -100,7 +100,6 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC } // Render function -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data) { // Avoid rendering when minimized @@ -516,7 +515,7 @@ void ImGui_ImplDX11_InvalidateDeviceObjects() bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context) { - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_dx11"; io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. @@ -563,7 +562,7 @@ void ImGui_ImplDX11_NewFrame() //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- @@ -583,7 +582,7 @@ static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport) viewport->RendererUserData = data; // PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*). - // Some back-end will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. + // Some backend will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle; IM_ASSERT(hwnd != 0); diff --git a/examples/imgui_impl_dx11.h b/backends/imgui_impl_dx11.h similarity index 75% rename from examples/imgui_impl_dx11.h rename to backends/imgui_impl_dx11.h index 95895d74..cd8e9e11 100644 --- a/examples/imgui_impl_dx11.h +++ b/backends/imgui_impl_dx11.h @@ -1,14 +1,14 @@ -// dear imgui: Renderer for DirectX11 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX11 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_dx12.cpp b/backends/imgui_impl_dx12.cpp similarity index 97% rename from examples/imgui_impl_dx12.cpp rename to backends/imgui_impl_dx12.cpp index 837b8cf0..8810b60d 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/backends/imgui_impl_dx12.cpp @@ -1,5 +1,5 @@ -// dear imgui: Renderer for DirectX12 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX12 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! @@ -7,13 +7,13 @@ // FIXME: The transition from removing a viewport and moving the window in an existing hosted viewport tends to flicker. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// Important: to compile on 32-bit systems, this back-end requires code to be compiled with '#define ImTextureID ImU64'. +// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. // This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. // This define is done in the example .vcxproj file and need to be replicated in your app (by e.g. editing imconfig.h) -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -72,7 +72,7 @@ struct ImGui_ImplDX12_FrameContext // Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data. // Main viewport created by application will only use the Resources field. -// Secondary viewports created by this back-end will use all the fields (including Window fields), +// Secondary viewports created by this backend will use all the fields (including Window fields), struct ImGuiViewportDataDx12 { // Window @@ -213,7 +213,6 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic } // Render function -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx) { // Avoid rendering when minimized @@ -704,7 +703,7 @@ void ImGui_ImplDX12_InvalidateDeviceObjects() bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle) { - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_dx12"; io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. @@ -722,7 +721,7 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO ImGuiViewport* main_viewport = ImGui::GetMainViewport(); main_viewport->RendererUserData = IM_NEW(ImGuiViewportDataDx12)(); - // Setup back-end capabilities flags + // Setup backend capabilities flags io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional) if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) ImGui_ImplDX12_InitPlatformInterface(); @@ -762,7 +761,7 @@ void ImGui_ImplDX12_NewFrame() //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- @@ -772,7 +771,7 @@ static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport) viewport->RendererUserData = data; // PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*). - // Some back-ends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. + // Some backends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle; IM_ASSERT(hwnd != 0); diff --git a/examples/imgui_impl_dx12.h b/backends/imgui_impl_dx12.h similarity index 81% rename from examples/imgui_impl_dx12.h rename to backends/imgui_impl_dx12.h index ede3d46d..4a2adaf6 100644 --- a/examples/imgui_impl_dx12.h +++ b/backends/imgui_impl_dx12.h @@ -1,18 +1,18 @@ -// dear imgui: Renderer for DirectX12 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX12 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// Important: to compile on 32-bit systems, this back-end requires code to be compiled with '#define ImTextureID ImU64'. +// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. // This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. // This define is done in the example .vcxproj file and need to be replicated in your app (by e.g. editing imconfig.h) -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_dx9.cpp b/backends/imgui_impl_dx9.cpp similarity index 96% rename from examples/imgui_impl_dx9.cpp rename to backends/imgui_impl_dx9.cpp index f8abc61a..8f0e3463 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/backends/imgui_impl_dx9.cpp @@ -1,14 +1,14 @@ -// dear imgui: Renderer for DirectX9 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX9 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -110,7 +110,6 @@ static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) } // Render function. -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) { // Avoid rendering when minimized @@ -231,7 +230,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) { - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_dx9"; io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. @@ -306,7 +305,7 @@ void ImGui_ImplDX9_NewFrame() //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- @@ -326,7 +325,7 @@ static void ImGui_ImplDX9_CreateWindow(ImGuiViewport* viewport) viewport->RendererUserData = data; // PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*). - // Some back-ends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. + // Some backends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle; IM_ASSERT(hwnd != 0); diff --git a/examples/imgui_impl_dx9.h b/backends/imgui_impl_dx9.h similarity index 73% rename from examples/imgui_impl_dx9.h rename to backends/imgui_impl_dx9.h index b0117fe9..f04de4c1 100644 --- a/examples/imgui_impl_dx9.h +++ b/backends/imgui_impl_dx9.h @@ -1,14 +1,14 @@ -// dear imgui: Renderer for DirectX9 -// This needs to be used along with a Platform Binding (e.g. Win32) +// dear imgui: Renderer Backend for DirectX9 +// This needs to be used along with a Platform Backend (e.g. Win32) // Implemented features: // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp similarity index 98% rename from examples/imgui_impl_glfw.cpp rename to backends/imgui_impl_glfw.cpp index caded5c4..b2fb4275 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/backends/imgui_impl_glfw.cpp @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for GLFW +// dear imgui: Platform Backend for GLFW // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // (Requires: GLFW 3.1+. Prefer GLFW 3.3+ for full feature support.) @@ -13,9 +13,9 @@ // Issues: // [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor). -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -169,7 +169,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw g_Window = window; g_Time = 0.0; - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) @@ -352,7 +352,7 @@ static void ImGui_ImplGlfw_UpdateMousePosAndButtons() // Important: this information is not easy to provide and many high-level windowing library won't be able to provide it correctly, because // - This is _ignoring_ viewports with the ImGuiViewportFlags_NoInputs flag (pass-through windows). // - This is _regardless_ of whether another viewport is focused or being dragged from. - // If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the back-end, imgui will ignore this field and infer the information by relying on the + // If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, imgui will ignore this field and infer the information by relying on the // rectangles and last focused time of every viewports it knows about. It will be unaware of other windows that may be sitting between or over your windows. // [GLFW] FIXME: This is currently only correct on Win32. See what we do below with the WM_NCHITTEST, missing an equivalent for other systems. // See https://github.com/glfw/glfw/issues/1236 if you want to help in making this a GLFW feature. @@ -467,7 +467,7 @@ static void ImGui_ImplGlfw_UpdateMonitors() void ImGui_ImplGlfw_NewFrame() { ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); + IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); // Setup display size (every frame to accommodate for window resizing) int w, h; @@ -494,7 +494,7 @@ void ImGui_ImplGlfw_NewFrame() //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- @@ -618,7 +618,7 @@ static LRESULT CALLBACK WndProcNoInputs(HWND hWnd, UINT msg, WPARAM wParam, LPAR { if (msg == WM_NCHITTEST) { - // Let mouse pass-through the window. This will allow the back-end to set io.MouseHoveredViewport properly (which is OPTIONAL). + // Let mouse pass-through the window. This will allow the backend 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. diff --git a/examples/imgui_impl_glfw.h b/backends/imgui_impl_glfw.h similarity index 90% rename from examples/imgui_impl_glfw.h rename to backends/imgui_impl_glfw.h index 9ad0d9b3..d2b4b43c 100644 --- a/examples/imgui_impl_glfw.h +++ b/backends/imgui_impl_glfw.h @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for GLFW +// dear imgui: Platform Backend for GLFW // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) @@ -12,9 +12,9 @@ // Issues: // [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor). -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // About GLSL version: // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. diff --git a/examples/imgui_impl_glut.cpp b/backends/imgui_impl_glut.cpp similarity index 96% rename from examples/imgui_impl_glut.cpp rename to backends/imgui_impl_glut.cpp index c8051452..90ad3330 100644 --- a/examples/imgui_impl_glut.cpp +++ b/backends/imgui_impl_glut.cpp @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for GLUT/FreeGLUT +// dear imgui: Platform Backend for GLUT/FreeGLUT // This needs to be used along with a Renderer (e.g. OpenGL2) // !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! @@ -11,9 +11,9 @@ // [ ] Platform: Missing clipboard support (not supported by Glut). // [ ] Platform: Missing gamepad support. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) diff --git a/examples/imgui_impl_glut.h b/backends/imgui_impl_glut.h similarity index 88% rename from examples/imgui_impl_glut.h rename to backends/imgui_impl_glut.h index 9acb77fb..9d8282e7 100644 --- a/examples/imgui_impl_glut.h +++ b/backends/imgui_impl_glut.h @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for GLUT/FreeGLUT +// dear imgui: Platform Backend for GLUT/FreeGLUT // This needs to be used along with a Renderer (e.g. OpenGL2) // !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! @@ -11,9 +11,9 @@ // [ ] Platform: Missing clipboard support (not supported by Glut). // [ ] Platform: Missing gamepad support. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_marmalade.cpp b/backends/imgui_impl_marmalade.cpp similarity index 96% rename from examples/imgui_impl_marmalade.cpp rename to backends/imgui_impl_marmalade.cpp index 00626072..805d0c3e 100644 --- a/examples/imgui_impl_marmalade.cpp +++ b/backends/imgui_impl_marmalade.cpp @@ -1,4 +1,4 @@ -// dear imgui: Renderer + Platform Binding for Marmalade + IwGx +// dear imgui: Renderer + Platform Backend for Marmalade + IwGx // Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) // Implemented features: @@ -6,9 +6,9 @@ // Missing features: // [ ] Renderer: Clipping rectangles are not honored. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -39,7 +39,6 @@ static bool g_osdKeyboardEnabled = false; static ImVec2 g_RenderScale = ImVec2(1.0f, 1.0f); // Render function. -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data) { // Avoid rendering when minimized diff --git a/examples/imgui_impl_marmalade.h b/backends/imgui_impl_marmalade.h similarity index 81% rename from examples/imgui_impl_marmalade.h rename to backends/imgui_impl_marmalade.h index 9e92d899..db521d58 100644 --- a/examples/imgui_impl_marmalade.h +++ b/backends/imgui_impl_marmalade.h @@ -1,12 +1,12 @@ -// dear imgui: Renderer + Platform Binding for Marmalade + IwGx +// dear imgui: Renderer + Platform Backend for Marmalade + IwGx // Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) // Implemented features: // [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID! -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_metal.h b/backends/imgui_impl_metal.h similarity index 79% rename from examples/imgui_impl_metal.h rename to backends/imgui_impl_metal.h index c12755d9..a6f40006 100644 --- a/examples/imgui_impl_metal.h +++ b/backends/imgui_impl_metal.h @@ -1,5 +1,5 @@ -// dear imgui: Renderer for Metal -// This needs to be used along with a Platform Binding (e.g. OSX) +// dear imgui: Renderer Backend for Metal +// This needs to be used along with a Platform Backend (e.g. OSX) // Implemented features: // [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID! @@ -7,9 +7,9 @@ // Missing features: // [ ] Renderer: Multi-viewport / platform windows. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_metal.mm b/backends/imgui_impl_metal.mm similarity index 98% rename from examples/imgui_impl_metal.mm rename to backends/imgui_impl_metal.mm index 10814b46..b21930c8 100644 --- a/examples/imgui_impl_metal.mm +++ b/backends/imgui_impl_metal.mm @@ -1,5 +1,5 @@ -// dear imgui: Renderer for Metal -// This needs to be used along with a Platform Binding (e.g. OSX) +// dear imgui: Renderer Backend for Metal +// This needs to be used along with a Platform Backend (e.g. OSX) // Implemented features: // [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID! @@ -7,9 +7,9 @@ // Missing features: // [ ] Renderer: Multi-viewport / platform windows. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) diff --git a/examples/imgui_impl_opengl2.cpp b/backends/imgui_impl_opengl2.cpp similarity index 95% rename from examples/imgui_impl_opengl2.cpp rename to backends/imgui_impl_opengl2.cpp index ba440957..a2b74fee 100644 --- a/examples/imgui_impl_opengl2.cpp +++ b/backends/imgui_impl_opengl2.cpp @@ -1,13 +1,13 @@ -// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) -// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) +// dear imgui: Renderer Backend for OpenGL2 (legacy OpenGL, fixed pipeline) +// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** // **Prefer using the code in imgui_impl_opengl3.cpp** @@ -64,7 +64,7 @@ static void ImGui_ImplOpenGL2_ShutdownPlatformInterface(); // Functions bool ImGui_ImplOpenGL2_Init() { - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_opengl2"; io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional) @@ -124,8 +124,8 @@ static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_wid } // OpenGL2 Render function. -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) -// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so. +// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly. +// This is in order to be able to run within an OpenGL engine that doesn't do so. void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data) { // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) @@ -260,7 +260,7 @@ void ImGui_ImplOpenGL2_DestroyDeviceObjects() //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- diff --git a/examples/imgui_impl_opengl2.h b/backends/imgui_impl_opengl2.h similarity index 81% rename from examples/imgui_impl_opengl2.h rename to backends/imgui_impl_opengl2.h index 89ab7fa0..ebc055d6 100644 --- a/examples/imgui_impl_opengl2.h +++ b/backends/imgui_impl_opengl2.h @@ -1,13 +1,13 @@ -// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline) -// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) +// dear imgui: Renderer Backend for OpenGL2 (legacy OpenGL, fixed pipeline) +// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** // **Prefer using the code in imgui_impl_opengl3.cpp** diff --git a/examples/imgui_impl_opengl3.cpp b/backends/imgui_impl_opengl3.cpp similarity index 98% rename from examples/imgui_impl_opengl3.cpp rename to backends/imgui_impl_opengl3.cpp index c2768a79..3c5057b5 100644 --- a/examples/imgui_impl_opengl3.cpp +++ b/backends/imgui_impl_opengl3.cpp @@ -1,16 +1,16 @@ -// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline +// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline // - Desktop GL: 2.x 3.x 4.x // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) -// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) +// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -161,7 +161,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) g_GlVersion = 200; // GLES 2 #endif - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_opengl3"; #ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET @@ -300,8 +300,8 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid } // OpenGL3 Render function. -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) -// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so. +// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly. +// This is in order to be able to run within an OpenGL engine that doesn't do so. void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data) { // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) @@ -700,7 +700,7 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects() //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- diff --git a/examples/imgui_impl_opengl3.h b/backends/imgui_impl_opengl3.h similarity index 91% rename from examples/imgui_impl_opengl3.h rename to backends/imgui_impl_opengl3.h index 5000b931..82860eb1 100644 --- a/examples/imgui_impl_opengl3.h +++ b/backends/imgui_impl_opengl3.h @@ -1,16 +1,16 @@ -// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline +// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline // - Desktop GL: 2.x 3.x 4.x // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) -// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) +// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices. -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // About Desktop OpenGL function loaders: // Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. diff --git a/examples/imgui_impl_osx.h b/backends/imgui_impl_osx.h similarity index 61% rename from examples/imgui_impl_osx.h rename to backends/imgui_impl_osx.h index 8aa0d7a2..fe5566d8 100644 --- a/examples/imgui_impl_osx.h +++ b/backends/imgui_impl_osx.h @@ -1,14 +1,18 @@ -// dear imgui: Platform Binding for OSX / Cocoa +// dear imgui: Platform Backend for OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) -// [ALPHA] Early bindings, not well tested. If you want a portable application, prefer using the GLFW or SDL platform bindings on Mac. +// [ALPHA] Early backend, not well tested. If you want a portable application, prefer using the GLFW or SDL platform Backends on Mac. // Implemented features: // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this back-end). +// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend). // Issues: // [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. // [ ] Platform: Multi-viewport / platform windows. +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs + #include "imgui.h" // IMGUI_IMPL_API @class NSEvent; diff --git a/examples/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm similarity index 96% rename from examples/imgui_impl_osx.mm rename to backends/imgui_impl_osx.mm index f84efbb5..6dfa91bd 100644 --- a/examples/imgui_impl_osx.mm +++ b/backends/imgui_impl_osx.mm @@ -1,14 +1,18 @@ -// dear imgui: Platform Binding for OSX / Cocoa +// dear imgui: Platform Backend for OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) -// [ALPHA] Early bindings, not well tested. If you want a portable application, prefer using the GLFW or SDL platform bindings on Mac. +// [ALPHA] Early backend, not well tested. If you want a portable application, prefer using the GLFW or SDL platform Backends on Mac. // Implemented features: // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this back-end). +// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend). // Issues: // [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. // [ ] Platform: Multi-viewport / platform windows. +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs + #include "imgui.h" #include "imgui_impl_osx.h" #import @@ -45,7 +49,7 @@ bool ImGui_ImplOSX_Init() { ImGuiIO& io = ImGui::GetIO(); - // Setup back-end capabilities flags + // Setup backend capabilities flags io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) //io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) //io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional) diff --git a/examples/imgui_impl_sdl.cpp b/backends/imgui_impl_sdl.cpp similarity index 98% rename from examples/imgui_impl_sdl.cpp rename to backends/imgui_impl_sdl.cpp index e1cfa7ff..eb90a195 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/backends/imgui_impl_sdl.cpp @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for SDL2 +// dear imgui: Platform Backend for SDL2 // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) // (Requires: SDL 2.0. Prefer SDL 2.0.4+ for full feature support.) @@ -13,9 +13,9 @@ // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. // [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows). -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // CHANGELOG // (minor and older changes stripped away, please see git history for details) @@ -165,7 +165,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, void* sdl_gl_context) { g_Window = window; - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) #if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE @@ -447,7 +447,7 @@ static void ImGui_ImplSDL2_UpdateMonitors() void ImGui_ImplSDL2_NewFrame(SDL_Window* window) { ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); + IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); // Setup display size (every frame to accommodate for window resizing) int w, h; @@ -475,7 +475,7 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window) //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- diff --git a/examples/imgui_impl_sdl.h b/backends/imgui_impl_sdl.h similarity index 86% rename from examples/imgui_impl_sdl.h rename to backends/imgui_impl_sdl.h index 2911eefb..6d8a0715 100644 --- a/examples/imgui_impl_sdl.h +++ b/backends/imgui_impl_sdl.h @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for SDL2 +// dear imgui: Platform Backend for SDL2 // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) @@ -12,9 +12,9 @@ // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. // [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows). -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/imgui_impl_vulkan.cpp b/backends/imgui_impl_vulkan.cpp similarity index 98% rename from examples/imgui_impl_vulkan.cpp rename to backends/imgui_impl_vulkan.cpp index 1cf5c789..050116f4 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/backends/imgui_impl_vulkan.cpp @@ -1,24 +1,24 @@ -// dear imgui: Renderer for Vulkan -// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) +// dear imgui: Renderer Backend for Vulkan +// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // Implemented features: // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. // [x] Platform: Multi-viewport / platform windows. With issues (flickering when creating a new viewport). // Missing features: -// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914 +// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914 -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification. // IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/ // Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. // - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering back-end in your engine/app. +// You will use those if you want to use this rendering backend in your engine/app. // - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. +// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. // Read comments in imgui_impl_vulkan.h. // CHANGELOG @@ -36,7 +36,7 @@ // 2019-02-16: Vulkan: Viewport and clipping rectangles correctly using draw_data->FramebufferScale to allow retina display. // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. // 2018-08-25: Vulkan: Fixed mishandled VkSurfaceCapabilitiesKHR::maxImageCount=0 case. -// 2018-06-22: Inverted the parameters to ImGui_ImplVulkan_RenderDrawData() to be consistent with other bindings. +// 2018-06-22: Inverted the parameters to ImGui_ImplVulkan_RenderDrawData() to be consistent with other backends. // 2018-06-08: Misc: Extracted imgui_impl_vulkan.cpp/.h away from the old combined GLFW+Vulkan example. // 2018-06-08: Vulkan: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. // 2018-03-03: Vulkan: Various refactor, created a couple of ImGui_ImplVulkanH_XXX helper that the example can use and that viewport support will use. @@ -329,7 +329,6 @@ static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline } // Render function -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline) { // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) @@ -903,7 +902,7 @@ void ImGui_ImplVulkan_DestroyDeviceObjects() bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass) { - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_vulkan"; io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. @@ -975,7 +974,7 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count) // Those functions only exist because: // 1) they facilitate the readability and maintenance of the multiple main.cpp examples files. // 2) the upcoming multi-viewport feature will need them internally. -// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings, +// Generally we avoid exposing any kind of superfluous high-level helpers in the backends, // but it is too much code to duplicate everywhere so we exceptionally expose them. // // Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.). @@ -1357,7 +1356,7 @@ void ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(VkDevice device, const V //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- diff --git a/examples/imgui_impl_vulkan.h b/backends/imgui_impl_vulkan.h similarity index 91% rename from examples/imgui_impl_vulkan.h rename to backends/imgui_impl_vulkan.h index 31dbd01f..274535bc 100644 --- a/examples/imgui_impl_vulkan.h +++ b/backends/imgui_impl_vulkan.h @@ -1,24 +1,24 @@ -// dear imgui: Renderer for Vulkan -// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) +// dear imgui: Renderer Backend for Vulkan +// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // Implemented features: // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. // Missing features: // [ ] Platform: Multi-viewport / platform windows. -// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914 +// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914 -// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification. // IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/ // Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. // - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering back-end in your engine/app. +// You will use those if you want to use this rendering backend in your engine/app. // - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. +// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. // Read comments in imgui_impl_vulkan.h. #pragma once diff --git a/examples/imgui_impl_win32.cpp b/backends/imgui_impl_win32.cpp similarity index 97% rename from examples/imgui_impl_win32.cpp rename to backends/imgui_impl_win32.cpp index 07a0c560..93626cda 100644 --- a/examples/imgui_impl_win32.cpp +++ b/backends/imgui_impl_win32.cpp @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) +// dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // Implemented features: @@ -8,6 +8,10 @@ // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs + #include "imgui.h" #include "imgui_impl_win32.h" #ifndef WIN32_LEAN_AND_MEAN @@ -76,7 +80,7 @@ bool ImGui_ImplWin32_Init(void* hwnd) if (!::QueryPerformanceCounter((LARGE_INTEGER*)&g_Time)) return false; - // Setup back-end capabilities flags + // Setup backend capabilities flags ImGuiIO& io = ImGui::GetIO(); io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) @@ -208,7 +212,7 @@ static void ImGui_ImplWin32_UpdateMousePos() // Important: this information is not easy to provide and many high-level windowing library won't be able to provide it correctly, because // - This is _ignoring_ viewports with the ImGuiViewportFlags_NoInputs flag (pass-through windows). // - This is _regardless_ of whether another viewport is focused or being dragged from. - // If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the back-end, imgui will ignore this field and infer the information by relying on the + // If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, imgui will ignore this field and infer the information by relying on the // rectangles and last focused time of every viewports it knows about. It will be unaware of foreign windows that may be sitting between or over your windows. if (HWND hovered_hwnd = ::WindowFromPoint(mouse_screen_pos)) if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)hovered_hwnd)) @@ -295,7 +299,7 @@ static void ImGui_ImplWin32_UpdateMonitors() void ImGui_ImplWin32_NewFrame() { ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); + IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame()."); // Setup display size (every frame to accommodate for window resizing) RECT rect; @@ -342,7 +346,7 @@ void ImGui_ImplWin32_NewFrame() // Win32 message handler (process Win32 mouse/keyboard inputs, etc.) // Call from your application's message handler. -// When implementing your own back-end, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs. +// When implementing your own backend, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs. // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. // Generally you may always pass all inputs to Dear ImGui, and hide them from your application based on those two flags. @@ -438,7 +442,7 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA //--------------------------------------------------------------------------------------------------------- // This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable. // ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically. -// If you are trying to implement your own back-end for your own engine, you may ignore that noise. +// If you are trying to implement your own backend for your own engine, you may ignore that noise. //--------------------------------------------------------------------------------------------------------- // Implement some of the functions and types normally declared in recent Windows SDK. @@ -563,7 +567,7 @@ static void ImGui_ImplWin32_SetImeInputPos(ImGuiViewport* viewport, ImVec2 pos) //-------------------------------------------------------------------------------------------------------- // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT -// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously. +// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- @@ -813,7 +817,7 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd, return MA_NOACTIVATE; break; case WM_NCHITTEST: - // Let mouse pass-through the window. This will allow the back-end to set io.MouseHoveredViewport properly (which is OPTIONAL). + // Let mouse pass-through the window. This will allow the backend 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. diff --git a/examples/imgui_impl_win32.h b/backends/imgui_impl_win32.h similarity index 86% rename from examples/imgui_impl_win32.h rename to backends/imgui_impl_win32.h index f1cfb912..5c319207 100644 --- a/examples/imgui_impl_win32.h +++ b/backends/imgui_impl_win32.h @@ -1,4 +1,4 @@ -// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications) +// dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) // Implemented features: @@ -8,6 +8,10 @@ // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. +// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs + #pragma once #include "imgui.h" // IMGUI_IMPL_API diff --git a/examples/example_glfw_vulkan/gen_spv.sh b/backends/vulkan/generate_spv.sh similarity index 55% rename from examples/example_glfw_vulkan/gen_spv.sh rename to backends/vulkan/generate_spv.sh index e0d7f3b0..948ef773 100755 --- a/examples/example_glfw_vulkan/gen_spv.sh +++ b/backends/vulkan/generate_spv.sh @@ -1,3 +1,6 @@ #!/bin/bash +## -V: create SPIR-V binary +## -x: save binary output as text-based 32-bit hexadecimal numbers +## -o: output file glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert diff --git a/examples/example_glfw_vulkan/glsl_shader.frag b/backends/vulkan/glsl_shader.frag similarity index 100% rename from examples/example_glfw_vulkan/glsl_shader.frag rename to backends/vulkan/glsl_shader.frag diff --git a/examples/example_glfw_vulkan/glsl_shader.vert b/backends/vulkan/glsl_shader.vert similarity index 100% rename from examples/example_glfw_vulkan/glsl_shader.vert rename to backends/vulkan/glsl_shader.vert diff --git a/docs/BACKENDS.md b/docs/BACKENDS.md new file mode 100644 index 00000000..87d54542 --- /dev/null +++ b/docs/BACKENDS.md @@ -0,0 +1,160 @@ +_(You may browse this at https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md or view this file with any Markdown viewer)_ + +## Dear ImGui: Backends + +**The backends/ folder contains backends for popular platforms/graphics API, which you can use in +your application or engine to easily integrate Dear ImGui.** Each backend is typically self-contained in a pair of files: imgui_impl_XXXX.cpp + imgui_impl_XXXX.h. + +- The 'Platform' backends are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
+ e.g. Windows ([imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp)), GLFW ([imgui_impl_glfw.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_glfw.cpp)), SDL2 ([imgui_impl_sdl.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_sdl.cpp)), etc. + +- The 'Renderer' backends are in charge of: creating atlas texture, rendering imgui draw data.
+ e.g. DirectX11 ([imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)), OpenGL/WebGL ([imgui_impl_opengl3.cpp]((https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_opengl3.cpp)), Vulkan ([imgui_impl_vulkan.cpp]((https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_vulkan.cpp)), etc. + +- For some high-level frameworks, a single backend usually handle both 'Platform' and 'Renderer' parts.
+ e.g. Allegro 5 ([imgui_impl_allegro5.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_allegro5.cpp)), Marmalade ([imgui_impl_marmalade.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_marmalade.cpp)). If you end up creating a custom backend for your engine, you may want to do the same. + +An application usually combines 1 Platform backend + 1 Renderer backend + main Dear ImGui sources. +For example, the [example_win32_directx11](https://github.com/ocornut/imgui/tree/master/examples/example_win32_directx11) application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp. See [EXAMPLES.MD](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md) for details. + + +### What are backends + +Dear ImGui is highly portable and only requires a few things to run and render, typically: + + - Required: providing mouse/keyboard inputs (fed into the `ImGuiIO` structure). + - Required: uploading the font atlas texture into graphics memory. + - Required: rendering indexed textured triangles with a clipping rectangle. + + Extra features are opt-in, our backends try to support as many as possible: + + - Optional: custom texture binding support. + - Optional: clipboard support. + - Optional: gamepad support. + - Optional: mouse cursor shape support. + - Optional: IME support. + - Optional: multi-viewports support. + etc. + +This is essentially what each backends are doing + obligatory portability cruft. + +It is important to understand the difference between the core Dear ImGui library (files in the root folder) +and backends which we are describing here (backends/ folder). + +- Some issues may only be backend or platform specific. +- You should be able to write backends for pretty much any platform and any 3D graphics API. + e.g. you can get creative and use software rendering or render remotely on a different machine. + + +### List of backends + +In the [backends/](https://github.com/ocornut/imgui/blob/master/backends) folder: + +List of Platforms Backends: + + imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/ + imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl backends) + imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org + imgui_impl_win32.cpp ; Win32 native API (Windows) + imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2020!) + +List of Renderer Backends: + + imgui_impl_dx9.cpp ; DirectX9 + imgui_impl_dx10.cpp ; DirectX10 + imgui_impl_dx11.cpp ; DirectX11 + imgui_impl_dx12.cpp ; DirectX12 + imgui_impl_metal.mm ; Metal (with ObjC) + imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context) + imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline) + imgui_impl_vulkan.cpp ; Vulkan + +List of high-level Frameworks Backends (combining Platform + Renderer): + + imgui_impl_allegro5.cpp + imgui_impl_marmalade.cpp + +Emscripten is also supported. +The [example_emscripten](https://github.com/ocornut/imgui/tree/master/examples/example_emscripten) app uses imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp, but other combos are possible. + +### Backends for third-party frameworks, graphics API or other languages + +See https://github.com/ocornut/imgui/wiki/Bindings +- AGS/Adventure Game Studio +- Amethyst +- bsf +- Cinder +- Cocos2d-x +- Diligent Engine +- Flexium, +- GML/Game Maker Studio2 +- GTK3+OpenGL3 +- Irrlicht Engine +- LÖVE+LUA +- Magnum +- NanoRT +- Nim Game Lib, +- Ogre +- openFrameworks +- OSG/OpenSceneGraph +- Orx +- px_render +- Qt/QtDirect3D +- SFML +- Sokol +- Unity +- Unreal Engine 4 +- vtk +- Win32 GDI +etc. + + +### Recommended Backends + +If you are not sure which backend to use, the recommended platform/frameworks for portable applications: + +|Library |Website |Backend |Note | +|--------|--------|--------|-----| +| GLFW | https://github.com/glfw/glfw | imgui_impl_glfw.cpp | | +| SDL2 | https://www.libsdl.org | imgui_impl_sdl.cpp | | +| Sokol | https://github.com/floooh/sokol | [util/sokol_imgui.h](https://github.com/floooh/sokol/blob/master/util/sokol_imgui.h) | Lower-level than GLFW/SDL | + + +### Using a custom engine? + +You will likely be tempted to start by rewrite your own backend using your own custom/high-level facilities...
+Think twice! + +If you are new to Dear ImGui, first try using the existing backends as-is. +You will save lots of time integrating the library. +You can LATER decide to rewrite yourself a custom backend if you really need to. +In most situations, custom backends have less features and more bugs than the standard backends we provide. +If you want portability, you can use multiple backends and choose between them either at compile time +or at runtime. + +**Example A**: your engine is built over Windows + DirectX11 but you have your own high-level rendering +system layered over DirectX11.
+Suggestion: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first. +Once it works, if you really need it you can replace the imgui_impl_dx11.cpp code with a +custom renderer using your own rendering functions, and keep using the standard Win32 code etc. + +**Example B**: your engine runs on Windows, Mac, Linux and uses DirectX11, Metal, Vulkan respectively.
+Suggestion: use multiple generic backends! +Once it works, if you really need it you can replace parts of backends with your own abstractions. + +**Example C**: your engine runs on platforms we can't provide public backends for (e.g. PS4/PS5, Switch), +and you have high-level systems everywhere.
+Suggestion: try using a non-portable backend first (e.g. win32 + underlying graphics API) to get +your desktop builds working first. This will get you running faster and get your acquainted with +how Dear ImGui works and is setup. You can then rewrite a custom backend using your own engine API. + +Also: +The [multi-viewports feature](https://github.com/ocornut/imgui/issues/1542) of the 'docking' branch allows +Dear ImGui windows to be seamlessly detached from the main application window. This is achieved using an +extra layer to the Platform and Renderer backends, which allows Dear ImGui to communicate platform-specific +requests such as: "create an additional OS window", "create a render context", "get the OS position of this +window" etc. See 'ImGuiPlatformIO' for details. +Supporting the multi-viewports feature correctly using 100% of your own abstractions is more difficult +than supporting single-viewport. +If you decide to use unmodified imgui_impl_XXXX.cpp files, you can automatically benefit from +improvements and fixes related to viewports and platform windows without extra work on your side. diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 6e4b8a25..4ccb5fa1 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -3,7 +3,7 @@ CHANGELOG This document holds the user-facing changelog that we also use in release notes. We generally fold multiple commits pertaining to the same topic as a single entry. -Changes to the examples/bindings are included within the individual .cpp files in the examples/ folder. +Changes to backends are also included within the individual .cpp files of each backend. RELEASE NOTES: https://github.com/ocornut/imgui/releases REPORT ISSUES, ASK QUESTIONS: https://github.com/ocornut/imgui/issues @@ -76,7 +76,7 @@ Other changes: (FIXME: This need a fuller explanation!) - Added ImGuiPlatformIO structure and GetPlatformIO(). - Similarly to ImGuiIO and GetIO(), this structure is the main point of communication for back-ends supporting multi-viewports. + Similarly to ImGuiIO and GetIO(), this structure is the main point of communication for backends supporting multi-viewports. - Added ImGuiPlatformMonitor to feed OS monitor information in the ImGuiPlatformIO::Monitors. - Added GetMainViewport(). - Added GetWindowViewport(), SetNextWindowViewport(). @@ -84,7 +84,7 @@ Other changes: - 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 FindViewportByID(), FindViewportByPlatformHandle() for usage by back-ends. +- Added FindViewportByID(), FindViewportByPlatformHandle() for usage by backends. - Added ImGuiConfigFlags_ViewportsEnable configuration flag and other viewport options. - Added io.ConfigViewportsNoAutoMerge, io.ConfigViewportsNoTaskBarIcon, io.ConfigViewportsNoDecoration, io.ConfigViewportsNoDefaultParent options. - Added ImGuiBackendFlags_PlatformHasViewports, ImGuiBackendFlags_RendererHasViewports, ImGuiBackendFlags_HasMouseHoveredViewport backend flags. @@ -100,6 +100,34 @@ Other changes: to make the examples main.cpp easier to read. +----------------------------------------------------------------------- + VERSION 1.80 (In Progress) +----------------------------------------------------------------------- + +Breaking Changes: + +- Backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/. (#3513) +- Removed redirecting functions/enums names that were marked obsolete in 1.60 (April 2017): + - io.RenderDrawListsFn pointer -> use ImGui::GetDrawData() value and call the render function of your backend + - ImGui::IsAnyWindowFocused() -> use ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) + - ImGui::IsAnyWindowHovered() -> use ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) + - ImGuiStyleVar_Count_ -> use ImGuiStyleVar_COUNT + - ImGuiMouseCursor_Count_ -> use ImGuiMouseCursor_COUNT +- Removed redirecting functions/enums names that were marked obsolete in 1.61 (May 2018): + - InputFloat (... int decimal_precision ...) -> use InputFloat (... const char* format ...) with format = "%.Xf" where X was value for decimal_precision. + - same for InputFloat2()/InputFloat3()/InputFloat4() variants taking a `int decimal_precision` parameter. +- If you were still using the old names, while you are cleaning up, considering enabling + IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h even temporarily to have a pass at finding + and removing up old API calls, if any remaining. + + +Other Changes: + +- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md improved them. +- Docs: Consistently renamed all occurences of "binding" and "back-end" to "backend" in comments and docs. +>>>>>>> master + + ----------------------------------------------------------------------- VERSION 1.79 (Released 2020-10-08) ----------------------------------------------------------------------- @@ -765,7 +793,7 @@ Other Changes: - Style: Attenuated default opacity of ImGuiCol_Separator in Classic and Light styles. - Style: Added style.ColorButtonPosition (left/right, defaults to ImGuiDir_Right) to move the color button of ColorEdit3/ColorEdit4 functions to either side of the inputs. -- IO: Added ImGuiKey_KeyPadEnter and support in various back-ends (previously back-ends would need to +- IO: Added ImGuiKey_KeyPadEnter and support in various backends (previously backends would need to specifically redirect key-pad keys to their regular counterpart). This is a temporary attenuating measure until we actually refactor and add whole sets of keys into the ImGuiKey enum. (#2677, #2005) [@amc522] - Misc: Made Button(), ColorButton() not trigger an "edited" event leading to IsItemDeactivatedAfterEdit() @@ -789,7 +817,7 @@ Other Changes: - Backends: OSX: Disabled default native Mac clipboard copy/paste implementation in core library (added in 1.71), because it needs application to be linked with '-framework ApplicationServices'. It can be explicitly enabled back by using '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h. Re-added - equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental back-end. (#2546) + equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental backend. (#2546) - Backends: SDL2: Added ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible. (#2482, #2632) [@josiahmanson] - Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm] @@ -840,7 +868,7 @@ Other Changes: - Nav: Fixed gamepad/keyboard moving of window affecting contents size incorrectly, sometimes leading to scrollbars appearing during the movement. - Nav: Fixed rare crash when e.g. releasing Alt-key while focusing a window with a menu at the same - frame as clearing the focus. This was in most noticeable in back-ends such as Glfw and SDL which + frame as clearing the focus. This was in most noticeable in backends such as Glfw and SDL which emits key release events when focusing another viewport, leading to Alt+clicking on void on another viewport triggering the issue. (#2609) - TreeNode, CollapsingHeader: Fixed highlight frame not covering horizontal area fully when using @@ -856,14 +884,14 @@ Other Changes: - Style: Made window close button cross slightly smaller. - Log/Capture: Fixed BeginTabItem() label not being included in a text log/capture. - ImDrawList: Added ImDrawCmd::VtxOffset value to support large meshes (64k+ vertices) using 16-bit indices. - The renderer back-end needs to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' to enable + The renderer backend needs to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' to enable this, and honor the ImDrawCmd::VtxOffset field. Otherwise the value will always be zero. (#2591) This has the advantage of preserving smaller index buffers and allowing to execute on hardware that do not - support 32-bit indices. Most examples back-ends have been modified to support the VtxOffset field. + support 32-bit indices. Most examples backends have been modified to support the VtxOffset field. - ImDrawList: Added ImDrawCmd::IdxOffset value, equivalent to summing element count for each draw command. This is provided for convenience and consistency with VtxOffset. (#2591) - ImDrawCallback: Allow to override the signature of ImDrawCallback by #define-ing it. This is meant to - facilitate custom rendering back-ends passing local render-specific data to the draw callback. + facilitate custom rendering backends passing local render-specific data to the draw callback. - ImFontAtlas: FreeType: Added RasterizerFlags::Monochrome flag to disable font anti-aliasing. Combine with RasterizerFlags::MonoHinting for best results. (#2545) [@HolyBlackCat] - ImFontGlyphRangesBuilder: Fixed unnecessarily over-sized buffer, which incidentally was also not @@ -873,7 +901,7 @@ Other Changes: dealing with Win32, and to facilitate integration in custom engines. (#2546) [@andrewwillmott] - Backends: OSX: imgui_impl_osx: Added mouse cursor support. (#2585, #1873) [@actboy168] - Examples/Backends: DirectX9/10/11/12, Metal, Vulkan, OpenGL3 (Desktop GL only): Added support for large meshes - (64k+ vertices) with 16-bit indices, enable 'ImGuiBackendFlags_RendererHasVtxOffset' in those back-ends. (#2591) + (64k+ vertices) with 16-bit indices, enable 'ImGuiBackendFlags_RendererHasVtxOffset' in those backends. (#2591) - Examples/Backends: Don't filter characters under 0x10000 before calling io.AddInputCharacter(), the filtering is done in io.AddInputCharacter() itself. This is in prevision for fuller Unicode support. (#2538, #2541) @@ -901,15 +929,15 @@ Breaking Changes: Other Changes: - ImDrawList: Added ImDrawCallback_ResetRenderState, a special ImDrawList::AddCallback() value - to request the renderer back-end to reset its render state. (#2037, #1639, #2452) - Examples: Added support for ImDrawCallback_ResetRenderState in all renderer back-ends. Each + to request the renderer backend to reset its render state. (#2037, #1639, #2452) + Examples: Added support for ImDrawCallback_ResetRenderState in all renderer backends. Each renderer code setting up initial render state has been moved to a function so it could be called at the start of rendering and when a ResetRenderState is requested. [@ocornut, @bear24rw] - InputText: Fixed selection background rendering one frame after the cursor movement when first transitioning from no-selection to has-selection. (Bug in 1.69) (#2436) [@Nazg-Gul] - InputText: Work-around for buggy standard libraries where isprint('\t') returns true. (#2467, #1336) - InputText: Fixed ImGuiInputTextFlags_AllowTabInput leading to two tabs characters being inserted - if the back-end provided both Key and Character input. (#2467, #1336) + if the backend provided both Key and Character input. (#2467, #1336) - Layout: Added SetNextItemWidth() helper to avoid using PushItemWidth/PopItemWidth() for single items. Note that SetNextItemWidth() currently only affect the same subset of items as PushItemWidth(), generally referred to as the large framed+labeled items. Because the new SetNextItemWidth() @@ -1066,7 +1094,7 @@ Other Changes: - ImDrawData: Added FramebufferScale field (currently a copy of the value from io.DisplayFramebufferScale). This is to allow render functions being written without pulling any data from ImGuiIO, allowing incoming multi-viewport feature to behave on Retina display and with multiple displays. - If you are not using a custom binding, please update your render function code ahead of time, + If you are not using a custom backend, please update your render function code ahead of time, and use draw_data->FramebufferScale instead of io.DisplayFramebufferScale. (#2306, #1676) - Added IsItemActivated() as an extension to the IsItemDeactivated/IsItemDeactivatedAfterEdit functions which are useful to implement variety of undo patterns. (#820, #956, #1875) @@ -1150,7 +1178,7 @@ Other Changes: - Window: Contents size is preserved while a window collapsed. Fix auto-resizing window losing their size for one frame when uncollapsed. - Window: Contents size is preserved while a window contents is hidden (unless it is hidden for resizing purpose). - Window: Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that - it only works _if_ the back-end sets ImGuiBackendFlags_HasMouseCursors, which the standard back-ends do. + it only works _if_ the backend sets ImGuiBackendFlags_HasMouseCursors, which the standard backends do. - Window: Added io.ConfigWindowsMoveFromTitleBarOnly option. This is ignored by window with no title bars (often popups). This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899) - Window: Fixed using SetNextWindowPos() on a child window (which wasn't really documented) position the cursor as expected @@ -1172,7 +1200,7 @@ Other Changes: - ImFontAtlas: FreeType: Fixed support for any values of TexGlyphPadding (not just only 1). - ImDrawList: Optimized some of the functions for performance of debug builds where non-inline function call cost are non-negligible. (Our test UI scene on VS2015 Debug Win64 with /RTC1 went ~5.9 ms -> ~4.9 ms. In Release same scene stays at ~0.3 ms.) -- IO: Added BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData void* for storage use by back-ends. +- IO: Added BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData void* for storage use by backends. - IO: Renamed InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead! - IO: AddInputCharacter() goes into a queue which can receive as many characters as needed during the frame. This is useful for automation to not have an upper limit on typing speed. Will later transition key/mouse to use the event queue later. @@ -1199,7 +1227,7 @@ Other Changes: - Demo: Added ShowAboutWindow() call, previously was only accessible from the demo window. - Demo: ShowAboutWindow() now display various Build/Config Information (compiler, os, etc.) that can easily be copied into bug reports. - Fixed build issue with osxcross and macOS. (#2218) [@dos1] -- Examples: Setting up 'io.BackendPlatformName'/'io.BackendRendererName' fields to the current back-end can be displayed in the About window. +- Examples: Setting up 'io.BackendPlatformName'/'io.BackendRendererName' fields to the current backend can be displayed in the About window. - Examples: SDL: changed the signature of ImGui_ImplSDL2_ProcessEvent() to use a const SDL_Event*. (#2187) @@ -1427,23 +1455,23 @@ Breaking Changes: Other Changes: -- Examples back-ends have been refactored to separate the platform code (e.g. Win32, Glfw, SDL2) from the renderer code (e.g. DirectX11, OpenGL3, Vulkan). - The "Platform" bindings are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, etc. - The "Renderer" bindings are in charge of: creating the main font texture, rendering imgui draw data. +- Examples backends have been refactored to separate the platform code (e.g. Win32, Glfw, SDL2) from the renderer code (e.g. DirectX11, OpenGL3, Vulkan). + The "Platform" backends are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, etc. + The "Renderer" backends are in charge of: creating the main font texture, rendering imgui draw data. before: imgui_impl_dx11.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx11.cpp before: imgui_impl_dx12.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx12.cpp before: imgui_impl_glfw_gl3.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp before: imgui_impl_glfw_vulkan.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl2.cpp before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp etc. - - The idea is what we can now easily combine and maintain back-ends and reduce code redundancy. Individual files are + - The idea is what we can now easily combine and maintain backends and reduce code redundancy. Individual files are smaller and more reusable. Integration of imgui into a new/custom engine may also be easier as there is less overlap between "windowing / inputs" and "rendering" code, so you may study or grab one half of the code and not the other. - This change was motivated by the fact that adding support for the upcoming multi-viewport feature requires more work - from the Platform and Renderer back-ends, and the amount of redundancy across files was becoming too difficult to - maintain. If you use default back-ends, you'll benefit from an easy update path to support multi-viewports later + from the Platform and Renderer backends, and the amount of redundancy across files was becoming too difficult to + maintain. If you use default backends, you'll benefit from an easy update path to support multi-viewports later (for future ImGui 1.7x). - - This is not strictly a breaking change if you keep your old bindings, but when you'll want to fully update your bindings, + - This is not strictly a breaking change if you keep your old backends, but when you'll want to fully update your backends, expect to have to reshuffle a few things. - Each example still has its own main.cpp which you may refer you to understand how to initialize and glue everything together. - Some frameworks (such as the Allegro, Marmalade) handle both the "platform" and "rendering" part, and your custom engine may as well. @@ -1470,20 +1498,20 @@ Other Changes: for icon fonts. (#1869) - ImFontAtlas: Added GetGlyphRangesChineseSimplifiedCommon() helper that returns a list of ~2500 most common Simplified Chinese characters. (#1859) [@JX-Master, @ocornut] -- Examples: OSX: Added imgui_impl_osx.mm binding to be used along with e.g. imgui_impl_opengl2.cpp. (#281, #1870) [@pagghiu, @itamago, @ocornut] +- Examples: OSX: Added imgui_impl_osx.mm backend to be used along with e.g. imgui_impl_opengl2.cpp. (#281, #1870) [@pagghiu, @itamago, @ocornut] - Examples: GLFW: Made it possible to Shutdown/Init the backend again (by reseting the time storage properly). (#1827) [@ice1000] - Examples: Win32: Fixed handling of mouse wheel messages to support sub-unit scrolling messages (typically sent by track-pads). (#1874) [@zx64] - Examples: SDL+Vulkan: Added SDL+Vulkan example. - Examples: Allegro5: Added support for ImGuiConfigFlags_NoMouseCursorChange flag. Added clipboard support. -- Examples: Allegro5: Unindexing buffers ourselves as Allegro indexed drawing primitives are buggy in the DirectX9 back-end +- Examples: Allegro5: Unindexing buffers ourselves as Allegro indexed drawing primitives are buggy in the DirectX9 backend (will be fixed in Allegro 5.2.5+). - Examples: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from ImGui_ImplDX12_NewFrame() to ImGui_ImplDX12_RenderDrawData() which makes a lots more sense. (#301) -- Examples: Vulkan: Reordered parameters ImGui_ImplVulkan_RenderDrawData() to be consistent with other bindings, +- Examples: Vulkan: Reordered parameters ImGui_ImplVulkan_RenderDrawData() to be consistent with other backends, a good occasion since we refactored the code. -- Examples: FreeGLUT: Added FreeGLUT bindings. Added FreeGLUT+OpenGL2 example. (#801) +- Examples: FreeGLUT: Added FreeGLUT backends. Added FreeGLUT+OpenGL2 example. (#801) - Examples: The functions in imgui_impl_xxx.cpp are prefixed with IMGUI_IMPL_API (which defaults to IMGUI_API) to facilitate some uses. (#1888) -- Examples: Fixed bindings to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile +- Examples: Fixed backends to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile with IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#1887) - Misc: Updated stb_textedit from 1.09 + patches to 1.12 + minor patches. - Internals: PushItemFlag() flags are inherited by BeginChild(). @@ -1559,9 +1587,9 @@ Other Changes: - Demo: Added demo for DragScalar(), InputScalar(), SliderScalar(). (#643) - Examples: Calling IMGUI_CHECKVERSION() in the main.cpp of every example application. - Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices). -- Examples: Allegro 5: Renamed bindings from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp. +- Examples: Allegro 5: Renamed backend from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp. - Examples: DirectX 9: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. (#1790, #1687) [@sr-tream] -- Examples: SDL: Fixed clipboard paste memory leak in the SDL binding code. (#1803) [@eliasdaler] +- Examples: SDL: Fixed clipboard paste memory leak in the SDL backend code. (#1803) [@eliasdaler] - Various minor fixes, tweaks, refactoring, comments. @@ -1592,7 +1620,7 @@ Breaking Changes: - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment. - Obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete). - Obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete). -- Renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, not used by core, and honored by some binding ahead of merging the Nav branch). +- Renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, not used by core, and honored by some backend ahead of merging the Nav branch). - Removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered style colors as the closing cross uses regular button colors now. - Renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData. - Removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it should be easy to replicate on your side (you can find the code in 1.53). @@ -1634,9 +1662,9 @@ Other Changes: - ImGuiConfigFlags_NoMouse: Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information passed by the backend. - ImGuiConfigFlags_IsSRGB, ImGuiConfigFlags_IsTouchScreen: Flags for general application use. - IO: Added io.BackendFlags for backend to store its capabilities (currently: _HasGamepad, _HasMouseCursors, _HasSetMousePos). This will be used more in the next version. -- IO: Added ImGuiKey_Insert, ImGuiKey_Space keys. Setup in all example bindings. (#1541) +- IO: Added ImGuiKey_Insert, ImGuiKey_Space keys. Setup in all example backends. (#1541) - IO: Added Horizontal Mouse Wheel support for horizontal scrolling. (#1463) [@tseeker] -- IO: Added IsAnyMouseDown() helper which is helpful for bindings to handle mouse capturing. +- IO: Added IsAnyMouseDown() helper which is helpful for backends to handle mouse capturing. - Window: Clicking on a window with the ImGuiWIndowFlags_NoMove flags takes an ActiveId so we can't hover something else when dragging afterwards. (#1381, #1337) - Window: IsWindowHovered(): Added ImGuiHoveredFlags_AnyWindow, ImGuiFocusedFlags_AnyWindow flags (See Breaking Changes). Added to demo. (#1382) - Window: Added SetNextWindowBgAlpha() helper. Particularly helpful since the legacy 5-parameters version of Begin() has been marked as obsolete in 1.53. (#1567) @@ -1702,7 +1730,7 @@ Other Changes: - Demo: Tweaked the Child demos, added a menu bar to the second child to test some navigation functions. - Demo: Console: Using ImGuiCol_Text to be more friendly to color changes. - Demo: Using IM_COL32() instead of ImColor() in ImDrawList centric contexts. Trying to phase out use of the ImColor helper whenever possible. -- Examples: Files in examples/ now include their own changelog so it is easier to occasionally update your bindings if needed. +- Examples: Files in examples/ now include their own changelog so it is easier to occasionally update your backends if needed. - Examples: Using Dark theme by default. (#707). Tweaked demo code. - Examples: Added support for horizontal mouse wheel for API that allows it. (#1463) [@tseeker] - Examples: All examples now setup the io.BackendFlags to signify they can honor mouse cursors, gamepad, etc. @@ -1713,7 +1741,7 @@ Other Changes: - Examples: OpenGL3+GLFW,SDL: Creating VAO in the render function so it can be more easily used by multiple shared OpenGL contexts. (#1217) - Examples: OpenGL3+GLFW: Using 3.2 context instead of 3.3. (#1466) - Examples: OpenGL: Setting up glPixelStorei() explicitly before uploading texture. -- Examples: OpenGL: Calls to glPolygonMode() are casting parameters as GLEnum to not fail with more strict bindings. (#1628) [@ilia-glushchenko] +- Examples: OpenGL: Calls to glPolygonMode() are casting parameters as GLEnum to not fail with more strict backends. (#1628) [@ilia-glushchenko] - Examples: Win32 (DirectX9,10,11,12): Added support for mouse cursor shapes. (#1495) - Examples: Win32 (DirectX9,10,11,12: Support for windows using the CS_DBLCLKS class flag by handling the double-click messages (WM_LBUTTONDBLCLK etc.). (#1538, #754) [@ndandoulakis] - Examples: Win32 (DirectX9,10,11,12): Made the Win32 proc handlers not assert if there is no active context yet, to be more flexible with creation order. (#1565) @@ -2108,7 +2136,7 @@ Other Changes: - Context: Support for #define-ing GImGui and IMGUI_SET_CURRENT_CONTEXT_FUNC to enable custom thread-based hackery (#586) - Updated stb_truetype.h to 1.14 (added OTF support, removed warnings). (#883, #976) - Updated stb_rect_pack.h to 0.10 (removed warnings). (#883) -- Added ImGuiMouseCursor_None enum value for convenient usage by app/binding. +- Added ImGuiMouseCursor_None enum value for convenient usage by app/backends. - Clipboard: Added a void* user_data parameter to Clipboard function handlers. (#875) (BREAKING API) - Internals: Refactor internal text alignment options to use ImVec2, removed ImGuiAlign. (#842, #222) - Internals: Renamed ImLoadFileToMemory to ImFileLoadToMemory to be consistent with ImFileOpen + fix mismatching .h name. (#917) diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md new file mode 100644 index 00000000..d318bd35 --- /dev/null +++ b/docs/EXAMPLES.md @@ -0,0 +1,235 @@ +_(You may browse this at https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md or view this file with any Markdown viewer)_ + +## Dear ImGui: Examples + +**The [examples/](https://github.com/ocornut/imgui/blob/master/examples) folder example applications (standalone, ready-to-build) for variety of +platforms and graphics APIs.** They all use standard backends from the [backends/](https://github.com/ocornut/imgui/blob/master/backends) folder. + +You can find Windows binaries for some of those example applications at: + http://www.dearimgui.org/binaries + + +### Getting Started + +Integration in a typical existing application, should take <20 lines when using standard backends. + + At initialization: + call ImGui::CreateContext() + call ImGui_ImplXXXX_Init() for each backend. + + At the beginning of your frame: + call ImGui_ImplXXXX_NewFrame() for each backend. + call ImGui::NewFrame() + + At the end of your frame: + call ImGui::Render() + call ImGui_ImplXXXX_RenderDrawData() for your Renderer backend. + + At shutdown: + call ImGui_ImplXXXX_Shutdown() for each backend. + call ImGui::DestroyContext() + +Example (using [backends/imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp) + [backends/imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)): + + // Create a Dear ImGui context, setup some options + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable some options + + // Initialize Platform + Renderer backends (here: using imgui_impl_win32.cpp + imgui_impl_dx11.cpp) + ImGui_ImplWin32_Init(my_hwnd); + ImGui_ImplDX11_Init(my_d3d_device, my_d3d_device_context); + + // Application main loop + while (true) + { + // Beginning of frame: update Renderer + Platform backend, start Dear ImGui frame + ImGui_ImplDX11_NewFrame(); + ImGui_ImplWin32_NewFrame(); + ImGui::NewFrame(); + + // Any application code here + ImGui::Text("Hello, world!"); + + // End of frame: render Dear ImGui + ImGui::Render(); + ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); + + // Swap + g_pSwapChain->Present(1, 0); + } + + // Shutdown + ImGui_ImplDX11_Shutdown(); + ImGui_ImplWin32_Shutdown(); + ImGui::DestroyContext(); + +Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. +Please read the comments and instruction at the top of each file. +Please read FAQ at http://www.dearimgui.org/faq + +If you are using of the backend provided here, you can add the backends/imgui_impl_xxxx(.cpp,.h) +files to your project and use as-in. Each imgui_impl_xxxx.cpp file comes with its own individual +Changelog, so if you want to update them later it will be easier to catch up with what changed. + + +### Examples Applications + +[example_allegro5/](https://github.com/ocornut/imgui/blob/master/examples/example_allegro5/)
+Allegro 5 example.
+= main.cpp + imgui_impl_allegro5.cpp + +[example_apple_metal/](https://github.com/ocornut/imgui/blob/master/examples/example_metal/)
+OSX & iOS + Metal example.
+= main.m + imgui_impl_osx.mm + imgui_impl_metal.mm
+It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. +(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends. +You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.) + +[example_apple_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_apple_opengl2/)
+OSX + OpenGL2 example.
+= main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp
+(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends. + You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.) + +[example_emscripten/](https://github.com/ocornut/imgui/blob/master/examples/example_emscripten/)
+Emcripten + SDL2 + OpenGL3+/ES2/ES3 example.
+= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
+Note that other examples based on SDL or GLFW + OpenGL could easily be modified to work with Emscripten. +We provide this to make the Emscripten differences obvious, and have them not pollute all other examples. + +[example_glfw_metal/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_metal/)
+GLFW (Mac) + Metal example.
+= main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm + +[example_glfw_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_opengl2/)
+GLFW + OpenGL2 example (legacy, fixed pipeline).
+= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
+**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
+**Prefer using OPENGL3 code (with gl3w/glew/glad/glad2/glbinding, you can replace the OpenGL function loader)**
+This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. +If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to +make things more complicated, will require your code to reset many OpenGL attributes to their initial +state, and might confuse your GPU driver. One star, not recommended. + +[example_glfw_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_opengl3/)
+GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline).
+= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
+This uses more modern OpenGL calls and custom shaders.
+Prefer using that if you are using modern OpenGL in your application (anything with shaders). +(Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent +source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different +from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.) + +[example_glfw_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_vulkan/)
+GLFW (Win32, Mac, Linux) + Vulkan example.
+= main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
+This is quite long and tedious, because: Vulkan. +For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp. + +[example_glut_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_glut_opengl2/)
+GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2 example.
+= main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
+Note that GLUT/FreeGLUT is largely obsolete software, prefer using GLFW or SDL. + +[example_marmalade/](https://github.com/ocornut/imgui/blob/master/examples/example_marmalade/)
+Marmalade example using IwGx.
+= main.cpp + imgui_impl_marmalade.cpp + +[example_null/](https://github.com/ocornut/imgui/blob/master/examples/example_null/)
+Null example, compile and link imgui, create context, run headless with no inputs and no graphics output.
+= main.cpp
+This is used to quickly test compilation of core imgui files in as many setups as possible. +Because this application doesn't create a window nor a graphic context, there's no graphics output. + +[example_sdl_directx11/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_directx11/)
+SDL2 + DirectX11 example, Windows only.
+= main.cpp + imgui_impl_sdl.cpp + imgui_impl_dx11.cpp
+This to demonstrate usage of DirectX with SDL. + +[example_sdl_metal/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_metal/)
+SDL2 (Mac) + Metal example.
+= main.mm + imgui_impl_sdl.cpp + imgui_impl_metal.mm + +[example_sdl_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_opengl2/)
+SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
+= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
+**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
+**Prefer using OPENGL3 code (with gl3w/glew/glad/glad2/glbinding, you can replace the OpenGL function loader)**
+This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. +If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to +make things more complicated, will require your code to reset many OpenGL attributes to their initial +state, and might confuse your GPU driver. One star, not recommended. + +[example_sdl_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_opengl3/)
+SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example.
+= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
+This uses more modern OpenGL calls and custom shaders.
+Prefer using that if you are using modern OpenGL in your application (anything with shaders). +(Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent +source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different +from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.) + +[example_sdl_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_vulkan/)
+SDL2 (Win32, Mac, Linux, etc.) + Vulkan example.
+= main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
+This is quite long and tedious, because: Vulkan.
+For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp. + +[example_win32_directx9/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx9/)
+DirectX9 example, Windows only.
+= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp + +[example_win32_directx10/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx10/)
+DirectX10 example, Windows only.
+= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp + +[example_win32_directx11/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx11/)
+DirectX11 example, Windows only.
+= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp + +[example_win32_directx12/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx12/)
+DirectX12 example, Windows only.
+= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp
+This is quite long and tedious, because: DirectX12. + + +### Miscallaneous + +**Building** + +Unfortunately in 2020 it is still tedious to create and maintain portable build files using external +libraries (the kind we're using here to create a window and render 3D triangles) without relying on +third party software. For most examples here we choose to provide: + - Makefiles for Linux/OSX + - Batch files for Visual Studio 2008+ + - A .sln project file for Visual Studio 2012+ + - Xcode project files for the Apple examples +Please let us know if they don't work with your setup! +You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those +directly with a command-line compiler. + +If you are interested in using Cmake to build and links examples, see: + https://github.com/ocornut/imgui/pull/1713 and https://github.com/ocornut/imgui/pull/3027 + +**About mouse cursor latency** + +Dear ImGui has no particular extra lag for most behaviors, +e.g. the value of 'io.MousePos' provided at the time of NewFrame() will result in windows being moved +to the right spot at the time of EndFrame()/Render(). At 60 FPS your experience should be pleasant. + +However, consider that OS mouse cursors are typically drawn through a very specific hardware accelerated +path and will feel smoother than the majority of contents rendered via regular graphics API (including, +but not limited to Dear ImGui windows). Because UI rendering and interaction happens on the same plane +as the mouse, that disconnect may be jarring to particularly sensitive users. +You may experiment with enabling the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor +using the regular graphics API, to help you visualize the difference between a "hardware" cursor and a +regularly rendered software cursor. +However, rendering a mouse cursor at 60 FPS will feel sluggish so you likely won't want to enable that at +all times. It might be beneficial for the user experience to switch to a software rendered cursor _only_ +when an interactive drag is in progress. + +Note that some setup or GPU drivers are likely to be causing extra display lag depending on their settings. +If you feel that dragging windows feels laggy and you are not sure what the cause is: try to build a simple +drawing a flat 2D shape directly under the mouse cursor! + diff --git a/docs/FAQ.md b/docs/FAQ.md index acc99ede..d474607c 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -50,6 +50,7 @@ or view this file with any Markdown viewer. **This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.** - Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them. - See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output. +- See documentation: [Backends](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md), [Examples](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md), [Fonts](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md). - See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h). - The [Wiki](https://github.com/ocornut/imgui/wiki) has many resources and links. - The [Glossary](https://github.com/ocornut/imgui/wiki/Glossary) page may be useful. @@ -91,8 +92,9 @@ You may merge in the [tables](https://github.com/ocornut/imgui/tree/tables) bran ### Q: How to get started? +Read [EXAMPLES.md](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md).
+Read [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md).
Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp). -Read [examples/README.txt](https://github.com/ocornut/imgui/tree/master/examples/README.txt). ##### [Return to Index](#index) @@ -126,7 +128,7 @@ e.g. `if (ImGui::GetIO().WantCaptureMouse) { ... }` ### Q: How can I enable keyboard or gamepad controls? - The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected! - Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable. -- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting back-end). +- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend). - See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for for PS4, XB1, Switch gamepads). - See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details. @@ -142,7 +144,7 @@ and portable source code (uSynergy.c/.h) for a small embeddable client that you to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer. Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols. - Game console users: consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback. -- You may also use a third party solution such as [Remote ImGui](https://github.com/JordiRos/remoteimgui) or [imgui-ws](https://github.com/ggerganov/imgui-ws) which sends the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine. See [Wiki](https://github.com/ocornut/imgui/wiki) index for most details. +- You may also use a third party solution such as [netImgui](https://github.com/sammyfreg/netImgui), [Remote ImGui](https://github.com/JordiRos/remoteimgui) or [imgui-ws](https://github.com/ggerganov/imgui-ws) which sends the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine. See [Wiki](https://github.com/ocornut/imgui/wiki) index for most details. - For touch inputs, you can increase the hit box of widgets (via the `style.TouchPadding` setting) to accommodate for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing for screen real-estate and precision. ##### [Return to Index](#index) @@ -151,7 +153,7 @@ Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-lik ### Q: I integrated Dear ImGui in my engine and little squares are showing instead of text.. This usually means that: your font texture wasn't uploaded into GPU, or your shader or other rendering state are not reading from the right texture (e.g. texture wasn't bound). -If this happens using the standard back-ends it is probably that the texture failed to upload, which could happens if for some reason your texture is too big. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md). +If this happens using the standard backends it is probably that the texture failed to upload, which could happens if for some reason your texture is too big. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md). ##### [Return to Index](#index) @@ -165,7 +167,7 @@ Rectangles provided by Dear ImGui are defined as `(x1=left,y1=top,x2=right,y2=bottom)` and **NOT** as `(x1,y1,width,height)` -Refer to rendering back-ends in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder for references of how to handle the `ClipRect` field. +Refer to rendering backends in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder for references of how to handle the `ClipRect` field. ##### [Return to Index](#index) @@ -325,7 +327,7 @@ Long explanation: We carry the information to identify a "texture" in the ImTextureID type. ImTextureID is nothing more that a void*, aka 4/8 bytes worth of data: just enough to store 1 pointer or 1 integer of your choice. Dear ImGui doesn't know or understand what you are storing in ImTextureID, it merely pass ImTextureID values until they reach your rendering function. -- In the [examples/](https://github.com/ocornut/imgui/tree/master/examples) bindings, for each graphics API binding we decided on a type that is likely to be a good representation for specifying an image from the end-user perspective. This is what the _examples_ rendering functions are using: +- In the [examples/](https://github.com/ocornut/imgui/tree/master/examples) backends, for each graphics API we decided on a type that is likely to be a good representation for specifying an image from the end-user perspective. This is what the _examples_ rendering functions are using: ``` OpenGL: - ImTextureID = GLuint @@ -346,11 +348,11 @@ DirectX12: - ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE - See ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp ``` -For example, in the OpenGL example binding we store raw OpenGL texture identifier (GLuint) inside ImTextureID. -Whereas in the DirectX11 example binding we store a pointer to ID3D11ShaderResourceView inside ImTextureID, which is a higher-level structure tying together both the texture and information about its format and how to read it. +For example, in the OpenGL example backend we store raw OpenGL texture identifier (GLuint) inside ImTextureID. +Whereas in the DirectX11 example backend we store a pointer to ID3D11ShaderResourceView inside ImTextureID, which is a higher-level structure tying together both the texture and information about its format and how to read it. - If you have a custom engine built over e.g. OpenGL, instead of passing GLuint around you may decide to use a high-level data type to carry information about the texture as well as how to display it (shaders, etc.). The decision of what to use as ImTextureID can always be made better knowing how your codebase is designed. If your engine has high-level data types for "textures" and "material" then you may want to use them. -If you are starting with OpenGL or DirectX or Vulkan and haven't built much of a rendering engine over them, keeping the default ImTextureID representation suggested by the example bindings is probably the best choice. +If you are starting with OpenGL or DirectX or Vulkan and haven't built much of a rendering engine over them, keeping the default ImTextureID representation suggested by the example backends is probably the best choice. (Advanced users may also decide to keep a low-level type in ImTextureID, and use ImDrawList callback and pass information to their renderer) User code may do: @@ -401,7 +403,7 @@ This way you'll be able to use your own types everywhere, e.g. passing `MyVector --- ### Q: How can I interact with standard C++ types (such as std::string and std::vector)? -- Being highly portable (bindings for several languages, frameworks, programming style, obscure or older platforms/compilers), and aiming for compatibility & performance suitable for every modern real-time game engines, dear imgui does not use any of std C++ types. We use raw types (e.g. char* instead of std::string) because they adapt to more use cases. +- Being highly portable (backends/bindings for several languages, frameworks, programming style, obscure or older platforms/compilers), and aiming for compatibility & performance suitable for every modern real-time game engines, dear imgui does not use any of std C++ types. We use raw types (e.g. char* instead of std::string) because they adapt to more use cases. - To use ImGui::InputText() with a std::string or any resizable string class, see [misc/cpp/imgui_stdlib.h](https://github.com/ocornut/imgui/blob/master/misc/cpp/imgui_stdlib.h). - To use combo boxes and list boxes with `std::vector` or any other data structure: the `BeginCombo()/EndCombo()` API lets you iterate and submit items yourself, so does the `ListBoxHeader()/ListBoxFooter()` API. @@ -633,7 +635,7 @@ A reasonably skinned application may look like (screenshot from [#2529](https:// Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience. -There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating binding to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings. +There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating bindings to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings. ##### [Return to Index](#index) diff --git a/docs/FONTS.md b/docs/FONTS.md index c2312fd5..87e6ee04 100644 --- a/docs/FONTS.md +++ b/docs/FONTS.md @@ -1,6 +1,6 @@ -## Dear ImGui: Using Fonts +_(You may browse this at https://github.com/ocornut/imgui/blob/master/docs/FONTS.md or view this file with any Markdown viewer)_ -(You may browse this document at https://github.com/ocornut/imgui/blob/master/docs/FONTS.md or view this file with any Markdown viewer.) +## Dear ImGui: Using Fonts The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer), a 13 pixels high, pixel-perfect font used by default. We embed it in the source code so you can use Dear ImGui without any file system access. ProggyClean does not scale smoothly, therefore it is recommended that you load your own file when using Dear ImGui in an application aiming to look nice and wanting to support multiple resolutions. @@ -226,7 +226,7 @@ io.Fonts->Build(); // Build the atlas while ## Using Custom Colorful Icons -**(This is a BETA api, use if you are familiar with dear imgui and with your rendering back-end)** +**(This is a BETA api, use if you are familiar with dear imgui and with your rendering backend)** - You can use the `ImFontAtlas::AddCustomRect()` and `ImFontAtlas::AddCustomRectFontGlyph()` api to register rectangles that will be packed into the font atlas texture. Register them before building the atlas, then call Build()`. - You can then use `ImFontAtlas::GetCustomRectByIndex(int)` to query the position/size of your rectangle within the texture, and blit/copy any graphics data of your choice into those rectangles. diff --git a/docs/README.md b/docs/README.md index 476540de..a946315f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -23,7 +23,7 @@ Dear ImGui is particularly suited to integration in games engine (for tooling), | [Usage](#usage) - [How it works](#how-it-works) - [Releases](#releases) - [Demo](#demo) - [Integration](#integration) | :----------------------------------------------------------: | | [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) | -| [Wiki](https://github.com/ocornut/imgui/wiki) - [Language & frameworks bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) | +| [Wiki](https://github.com/ocornut/imgui/wiki) - [Languages & frameworks backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) | ### Usage @@ -33,7 +33,7 @@ Dear ImGui is particularly suited to integration in games engine (for tooling), You will need a backend to integrate Dear ImGui in your app. The backend passes mouse/keyboard/gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices. -**Backends for a variety of graphics api and rendering platforms** are provided in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder, along with example applications. See the [Integration](#integration) section of this document for details. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui. +**Backends for a variety of graphics api and rendering platforms** are provided in the [backends/](https://github.com/ocornut/imgui/tree/master/backends) folder, along with example applications in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder. See the [Integration](#integration) section of this document for details. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui. After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop: @@ -110,16 +110,16 @@ The demo applications are not DPI aware so expect some blurriness on a 4K screen ### Integration -On most platforms and when using C++, **you should be able to use a combination of the [imgui_impl_xxxx](https://github.com/ocornut/imgui/tree/master/examples) files without modification** (e.g. `imgui_impl_win32.cpp` + `imgui_impl_dx11.cpp`). If your engine supports multiple platforms, consider using more of the imgui_impl_xxxx files instead of rewriting them: this will be less work for you and you can get Dear ImGui running immediately. You can _later_ decide to rewrite a custom binding using your custom engine functions if you wish so. +On most platforms and when using C++, **you should be able to use a combination of the [imgui_impl_xxxx](https://github.com/ocornut/imgui/tree/master/examples) files without modification** (e.g. `imgui_impl_win32.cpp` + `imgui_impl_dx11.cpp`). If your engine supports multiple platforms, consider using more of the imgui_impl_xxxx files instead of rewriting them: this will be less work for you and you can get Dear ImGui running immediately. You can _later_ decide to rewrite a custom backend using your custom engine functions if you wish so. Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading one texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer at ease with those concepts, it should take you less than two hours to integrate Dear ImGui in your custom engine. **Make sure to spend time reading the [FAQ](https://www.dearimgui.org/faq), comments, and some of the examples/ application!** -Officially maintained bindings (in repository): +Officially maintained backends/bindings (in repository): - Renderers: DirectX9, DirectX10, DirectX11, DirectX12, OpenGL (legacy), OpenGL3/ES/ES2 (modern), Vulkan, Metal. - Platforms: GLFW, SDL2, Win32, Glut, OSX. - Frameworks: Emscripten, Allegro5, Marmalade. -Third-party bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page): +Third-party backends/bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page): - Languages: C, C# and: Beef, ChaiScript, Crystal, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift... - Frameworks: AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, Godot, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, nCine, Nim Game Lib, Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, SFML, Sokol, Unity, Unreal Engine 4, vtk, Win32 GDI, WxWidgets. - Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages. diff --git a/docs/TODO.txt b/docs/TODO.txt index b0cbe928..67973e98 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -6,7 +6,7 @@ The list below consist mostly of ideas noted down before they are requested/disc It's mostly a bunch of personal notes, probably incomplete. Feel free to query if you have any questions. - doc/test: add a proper documentation+regression testing system (#435) - - doc/test: checklist app to verify binding/integration of imgui (test inputs, rendering, callback, etc.). + - doc/test: checklist app to verify backends/integration of imgui (test inputs, rendering, callback, etc.). - doc/tips: tips of the day: website? applet in imgui_club? - doc/wiki: work on the wiki https://github.com/ocornut/imgui/wiki @@ -412,7 +412,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808) - inputs/scrolling: support for smooth scrolling (#2462, #2569) - - misc: idle: expose "woken up" boolean (set by inputs) and/or animation time (for cursor blink) for back-end to be able stop refreshing easily. + - misc: idle: expose "woken up" boolean (set by inputs) and/or animation time (for cursor blink) for backend to be able stop refreshing easily. - misc: idle: if cursor blink if the _only_ visible animation, core imgui could rewrite vertex alpha to avoid CPU pass on ImGui:: calls. - misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost. - misc: no way to run a root-most GetID() with ImGui:: api since there's always a Debug window in the stack. (mentioned in #2960) diff --git a/examples/README.txt b/examples/README.txt index d899fd89..ed16dd9f 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -1,299 +1 @@ ------------------------------------------------------------------------ - dear imgui, v1.79 ------------------------------------------------------------------------ - examples/README.txt - (This is the README file for the examples/ folder. See docs/ for more documentation) ------------------------------------------------------------------------ - -Dear ImGui is highly portable and only requires a few things to run and render: - - - Providing mouse/keyboard inputs - - Uploading the font atlas texture into graphics memory - - Providing a render function to render indexed textured triangles - - Optional: clipboard support, mouse cursor supports, Windows IME support, etc. - - Optional (Advanced,Beta): platform window API to use multi-viewport. - -This is essentially what the example bindings in this folder are providing + obligatory portability cruft. - -It is important to understand the difference between the core Dear ImGui library (files in the root folder) -and examples bindings which we are describing here (examples/ folder). -You should be able to write bindings for pretty much any platform and any 3D graphics API. With some extra -effort you can even perform the rendering remotely, on a different machine than the one running the logic. - -This folder contains two things: - - - Example bindings for popular platforms/graphics API, which you can use as is or adapt for your own use. - They are the imgui_impl_XXXX files found in the examples/ folder. - - - Example applications (standalone, ready-to-build) using the aforementioned bindings. - They are the in the XXXX_example/ sub-folders. - -You can find binaries of some of those example applications at: - http://www.dearimgui.org/binaries - - ---------------------------------------- - GETTING STARTED ---------------------------------------- - - - Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. - Please read the comments and instruction at the top of each file. - Please read FAQ at http://www.dearimgui.org/faq - - - If you are using of the backend provided here, you can add the imgui_impl_xxx.cpp/h files - to your project and use them unmodified. Each imgui_impl_xxxx.cpp comes with its own individual - Changelog at the top of the .cpp files, so if you want to update them later it will be easier to - catch up with what changed. - - - Dear ImGui has no particular extra lag for most behaviors, e.g. the value of 'io.MousePos' provided in - NewFrame() will result at the time of EndFrame()/Render() in a moved windows rendered following that mouse - movement. At 60 FPS your experience should be pleasant. - However, consider that OS mouse cursors are typically drawn through a very specific hardware accelerated - path and will feel smoother than the majority of contents rendererd via regular graphics API (including, - but not limited to Dear ImGui windows). Because UI rendering and interaction happens on the same plane as - the mouse, that disconnect may be jarring to particularly sensitive users. - You may experiment with enabling the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor - using the regular graphics API, to help you visualize the difference between a "hardware" cursor and a - regularly rendered software cursor. - However, rendering a mouse cursor at 60 FPS will feel sluggish so you likely won't want to enable that at - all times. It might be beneficial for the user experience to switch to a software rendered cursor _only_ - when an interactive drag is in progress. - Note that some setup or GPU drivers are likely to be causing extra display lag depending on their settings. - If you feel that dragging windows feels laggy and you are not sure what the cause is: try to build a simple - drawing a flat 2D shape directly under the mouse cursor. - - ---------------------------------------- - EXAMPLE BINDINGS ---------------------------------------- - -Most the example bindings are split in 2 parts: - - - The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing. - Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp), etc. - - - The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data. - Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp), etc. - - - The example _applications_ usually combine 1 platform + 1 renderer binding to create a working program. - Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp. - - - Some bindings for higher level frameworks carry both "Platform" and "Renderer" parts in one file. - This is the case for Allegro 5 (imgui_impl_allegro5.cpp), Marmalade (imgui_impl_marmalade5.cpp). - - - If you use your own engine, you may decide to use some of existing bindings and/or rewrite some using - your own API. As a recommendation, if you are new to Dear ImGui, try using the existing binding as-is - first, before moving on to rewrite some of the code. Although it is tempting to rewrite both of the - imgui_impl_xxxx files to fit under your coding style, consider that it is not necessary! - In fact, if you are new to Dear ImGui, rewriting them will almost always be harder. - - Example: your engine is built over Windows + DirectX11 but you have your own high-level rendering - system layered over DirectX11. - Suggestion: step 1: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first. - Once this work, _if_ you want you can replace the imgui_impl_dx11.cpp code with a custom renderer - using your own functions, etc. - Please consider using the bindings to the lower-level platform/graphics API as-is. - - Example: your engine is multi-platform (consoles, phones, etc.), you have high-level systems everywhere. - Suggestion: step 1: try using a non-portable binding first (e.g. win32 + underlying graphics API)! - This is counter-intuitive, but this will get you running faster! Once you better understand how imgui - works and is bound, you can rewrite the code using your own systems. - - - Road-map: Dear ImGui 1.80 (WIP currently in the "docking" branch) will allows imgui windows to be - seamlessly detached from the main application window. This is achieved using an extra layer to the - platform and renderer bindings, which allows Dear ImGui to communicate platform-specific requests such as - "create an additional OS window", "create a render context", "get the OS position of this window" etc. - When using this feature, the coupling with your OS/renderer becomes much tighter than a regular imgui - integration. It is also much more complicated and require more work to integrate correctly. - If you are new to imgui and you are trying to integrate it into your application, first try to ignore - everything related to Viewport and Platform Windows. You'll be able to come back to it later! - Note that if you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit - from improvements and fixes related to viewports and platform windows without extra work on your side. - See 'ImGuiPlatformIO' for details. - - -List of Platforms Bindings in this repository: - - imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/ - imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl back-ends) - imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org - imgui_impl_win32.cpp ; Win32 native API (Windows) - imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2020!) - -List of Renderer Bindings in this repository: - - imgui_impl_dx9.cpp ; DirectX9 - imgui_impl_dx10.cpp ; DirectX10 - imgui_impl_dx11.cpp ; DirectX11 - imgui_impl_dx12.cpp ; DirectX12 - imgui_impl_metal.mm ; Metal (with ObjC) - imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context) - imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline) - imgui_impl_vulkan.cpp ; Vulkan - -List of high-level Frameworks Bindings in this repository: (combine Platform + Renderer) - - imgui_impl_allegro5.cpp - imgui_impl_marmalade.cpp - -Note that Dear ImGui works with Emscripten. The examples_emscripten/ app uses imgui_impl_sdl.cpp and -imgui_impl_opengl3.cpp, but other combinations are possible. - -Third-party framework, graphics API and languages bindings are listed at: - - https://github.com/ocornut/imgui/wiki/Bindings - -Including backends for: - - AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, - GML/Game Maker Studio2, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, NanoRT, Nim Game Lib, - Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, px_render, Qt/QtDirect3D, SFML, Sokol, - Unreal Engine 4, vtk, Win32 GDI, etc. - -Not sure which to use? -Recommended platform/frameworks: - - GLFW https://github.com/glfw/glfw Use imgui_impl_glfw.cpp - SDL2 https://www.libsdl.org Use imgui_impl_sdl.cpp - Sokol https://github.com/floooh/sokol Use util/sokol_imgui.h in Sokol repository. - -Those will allow you to create portable applications and will solve and abstract away many issues. - - ---------------------------------------- - EXAMPLE APPLICATIONS ---------------------------------------- - -Building: - Unfortunately in 2020 it is still tedious to create and maintain portable build files using external - libraries (the kind we're using here to create a window and render 3D triangles) without relying on - third party software. For most examples here we choose to provide: - - Makefiles for Linux/OSX - - Batch files for Visual Studio 2008+ - - A .sln project file for Visual Studio 2012+ - - Xcode project files for the Apple examples - Please let us know if they don't work with your setup! - You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those - directly with a command-line compiler. - - If you are interested in using Cmake to build and links examples, see: - https://github.com/ocornut/imgui/pull/1713 and https://github.com/ocornut/imgui/pull/3027 - - -example_allegro5/ - Allegro 5 example. - = main.cpp + imgui_impl_allegro5.cpp - -example_apple_metal/ - OSX & iOS + Metal. - = main.m + imgui_impl_osx.mm + imgui_impl_metal.mm - It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. - (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends. - You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.) - -example_apple_opengl2/ - OSX + OpenGL2. - = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp - (NB: imgui_impl_osx.mm is currently not as feature complete as other platforms back-ends. - You may prefer to use the GLFW Or SDL back-ends, which will also support Windows and Linux.) - -example_empscripten: - Emcripten + SDL2 + OpenGL3+/ES2/ES3 example. - = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp - Note that other examples based on SDL or GLFW + OpenGL could easily be modified to work with Emscripten. - We provide this to make the Emscripten differences obvious, and have them not pollute all other examples. - -example_glfw_metal/ - GLFW (Mac) + Metal example. - = main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm - -example_glfw_opengl2/ - GLFW + OpenGL2 example (legacy, fixed pipeline). - = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp - **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** - **Prefer using OPENGL3 code (with gl3w/glew/glad/glad2/glbinding, you can replace the OpenGL function loader)** - This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. - If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to - make things more complicated, will require your code to reset many OpenGL attributes to their initial - state, and might confuse your GPU driver. One star, not recommended. - -example_glfw_opengl3/ - GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline). - = main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp - This uses more modern OpenGL calls and custom shaders. - Prefer using that if you are using modern OpenGL in your application (anything with shaders). - (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent - source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different - from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.) - -example_glfw_vulkan/ - GLFW (Win32, Mac, Linux) + Vulkan example. - = main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp - This is quite long and tedious, because: Vulkan. - For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp. - -example_glut_opengl2/ - GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2. - = main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp - Note that GLUT/FreeGLUT is largely obsolete software, prefer using GLFW or SDL. - -example_marmalade/ - Marmalade example using IwGx. - = main.cpp + imgui_impl_marmalade.cpp - -example_null - Null example, compile and link imgui, create context, run headless with no inputs and no graphics output. - = main.cpp - This is used to quickly test compilation of core imgui files in as many setups as possible. - Because this application doesn't create a window nor a graphic context, there's no graphics output. - -example_sdl_directx11/ - SDL2 + DirectX11 example, Windows only. - = main.cpp + imgui_impl_sdl.cpp + imgui_impl_dx11.cpp - This to demonstrate usage of DirectX with SDL. - -example_sdl_metal/ - SDL2 (Mac) + Metal example. - = main.mm + imgui_impl_sdl.cpp + imgui_impl_metal.mm - -example_sdl_opengl2/ - SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline). - = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp - **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** - **Prefer using OPENGL3 code (with gl3w/glew/glad/glad2/glbinding, you can replace the OpenGL function loader)** - This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. - If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to - make things more complicated, will require your code to reset many OpenGL attributes to their initial - state, and might confuse your GPU driver. One star, not recommended. - -example_sdl_opengl3/ - SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. - = main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp - This uses more modern OpenGL calls and custom shaders. - Prefer using that if you are using modern OpenGL in your application (anything with shaders). - (Please be mindful that accessing OpenGL3+ functions requires a function loader, which are a frequent - source for confusion for new users. We use a loader in imgui_impl_opengl3.cpp which may be different - from the one your app normally use. Read imgui_impl_opengl3.h for details and how to change it.) - -example_sdl_vulkan/ - SDL2 (Win32, Mac, Linux, etc.) + Vulkan example. - = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp - This is quite long and tedious, because: Vulkan. - For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp. - -example_win32_directx9/ - DirectX9 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp - -example_win32_directx10/ - DirectX10 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp - -example_win32_directx11/ - DirectX11 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp - -example_win32_directx12/ - DirectX12 example, Windows only. - = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp - This is quite long and tedious, because: DirectX12. +See EXAMPLES and BACKENDS files in the docs/ folder. diff --git a/examples/example_allegro5/README.md b/examples/example_allegro5/README.md index 10d9d6e9..0e27f5f6 100644 --- a/examples/example_allegro5/README.md +++ b/examples/example_allegro5/README.md @@ -5,14 +5,14 @@ Dear ImGui outputs 16-bit vertex indices by default. Allegro doesn't support them natively, so we have two solutions: convert the indices manually in imgui_impl_allegro5.cpp, or compile dear imgui with 32-bit indices. You can either modify imconfig.h that comes with Dear ImGui (easier), or set a C++ preprocessor option IMGUI_USER_CONFIG to find to a filename. We are providing `imconfig_allegro5.h` that enables 32-bit indices. -Note that the back-end supports _BOTH_ 16-bit and 32-bit indices, but 32-bit indices will be slightly faster as they won't require a manual conversion. +Note that the backend supports _BOTH_ 16-bit and 32-bit indices, but 32-bit indices will be slightly faster as they won't require a manual conversion. # How to Build ### On Ubuntu 14.04+ and macOS ```bash -g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ../imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_main -lallegro_primitives -o allegro5_example +g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ../../backends/imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_main -lallegro_primitives -o allegro5_example ``` On macOS, install Allegro with homebrew: `brew install allegro`. @@ -31,5 +31,5 @@ cd vcpkg Build: ``` set ALLEGRODIR=path_to_your_allegro5_folder -cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. main.cpp ..\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib +cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. main.cpp ..\..\backends\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib ``` diff --git a/examples/example_allegro5/example_allegro5.vcxproj b/examples/example_allegro5/example_allegro5.vcxproj index f5fadc37..d50318a9 100644 --- a/examples/example_allegro5/example_allegro5.vcxproj +++ b/examples/example_allegro5/example_allegro5.vcxproj @@ -90,7 +90,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%(AdditionalIncludeDirectories) true @@ -104,7 +104,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%(AdditionalIncludeDirectories) true @@ -120,7 +120,7 @@ MaxSpeed true true - ..\..;..;$(SolutionDir)\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;$(SolutionDir)\libs\gl3w;%(AdditionalIncludeDirectories) false @@ -140,7 +140,7 @@ MaxSpeed true true - ..\..;..;$(SolutionDir)\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;$(SolutionDir)\libs\gl3w;%(AdditionalIncludeDirectories) false @@ -159,7 +159,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -176,4 +176,4 @@ - \ No newline at end of file + diff --git a/examples/example_allegro5/example_allegro5.vcxproj.filters b/examples/example_allegro5/example_allegro5.vcxproj.filters index 8019ebfd..9abb67e7 100644 --- a/examples/example_allegro5/example_allegro5.vcxproj.filters +++ b/examples/example_allegro5/example_allegro5.vcxproj.filters @@ -22,7 +22,7 @@ sources - + sources @@ -42,7 +42,7 @@ imgui - + sources @@ -52,4 +52,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_allegro5/main.cpp b/examples/example_allegro5/main.cpp index a9026c2e..e228e6ab 100644 --- a/examples/example_allegro5/main.cpp +++ b/examples/example_allegro5/main.cpp @@ -1,5 +1,6 @@ -// dear imgui: standalone example application for Allegro 5 -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for Allegro 5 +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include #include @@ -33,7 +34,7 @@ int main(int, char**) ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplAllegro5_Init(display); // Load Fonts diff --git a/examples/example_apple_metal/Shared/Renderer.mm b/examples/example_apple_metal/Shared/Renderer.mm index 3f7e32d1..c121f692 100644 --- a/examples/example_apple_metal/Shared/Renderer.mm +++ b/examples/example_apple_metal/Shared/Renderer.mm @@ -35,7 +35,7 @@ ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); - // Setup Renderer bindings + // Setup Renderer backend ImGui_ImplMetal_Init(_device); // Load Fonts diff --git a/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj b/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj index f1c10494..38c45cfd 100644 --- a/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj +++ b/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj @@ -54,8 +54,8 @@ 8307E7E320E9F9C900473790 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8307E7E520E9F9C900473790 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = ""; }; 8307E7E620E9F9C900473790 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 836D2A2C20EE208D0098E909 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../imgui_impl_osx.h; sourceTree = ""; }; - 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../imgui_impl_osx.mm; sourceTree = ""; }; + 836D2A2C20EE208D0098E909 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../../backends/imgui_impl_osx.h; sourceTree = ""; }; + 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../../backends/imgui_impl_osx.mm; sourceTree = ""; }; 836D2A2F20EE4A180098E909 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 836D2A3120EE4A900098E909 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; 83BBE9E420EB46B900295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; }; @@ -64,8 +64,8 @@ 83BBE9EA20EB471700295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; 83BBE9EB20EB471700295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; 83BBE9EE20EB471C00295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = System/Library/Frameworks/ModelIO.framework; sourceTree = SDKROOT; }; - 83BBE9FC20EB54D800295997 /* imgui_impl_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal.h; path = ../../imgui_impl_metal.h; sourceTree = ""; }; - 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_metal.mm; path = ../../imgui_impl_metal.mm; sourceTree = ""; }; + 83BBE9FC20EB54D800295997 /* imgui_impl_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal.h; path = ../../../backends/imgui_impl_metal.h; sourceTree = ""; }; + 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_metal.mm; path = ../../../backends/imgui_impl_metal.mm; sourceTree = ""; }; 83BBEA0020EB54E700295997 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; }; 83BBEA0120EB54E700295997 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; }; 83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; }; diff --git a/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj b/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj index 5bdf74b5..204b68a9 100644 --- a/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj +++ b/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj @@ -34,10 +34,10 @@ 07A82EDA213941D00078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = ""; }; 4080A96B20B029B00036BA46 /* example_osx_opengl2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = example_osx_opengl2; sourceTree = BUILT_PRODUCTS_DIR; }; 4080A98A20B02CD90036BA46 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = SOURCE_ROOT; }; - 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl2.cpp; path = ../imgui_impl_opengl2.cpp; sourceTree = ""; }; - 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../imgui_impl_osx.mm; sourceTree = ""; }; - 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl2.h; path = ../imgui_impl_opengl2.h; sourceTree = ""; }; - 4080A9A120B034280036BA46 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../imgui_impl_osx.h; sourceTree = ""; }; + 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl2.cpp; path = ../../backends/imgui_impl_opengl2.cpp; sourceTree = ""; }; + 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../backends/imgui_impl_osx.mm; sourceTree = ""; }; + 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl2.h; path = ../../backends/imgui_impl_opengl2.h; sourceTree = ""; }; + 4080A9A120B034280036BA46 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../backends/imgui_impl_osx.h; sourceTree = ""; }; 4080A9A520B0343C0036BA46 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = ""; }; 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; }; 4080A9A720B0343C0036BA46 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; }; diff --git a/examples/example_apple_opengl2/main.mm b/examples/example_apple_opengl2/main.mm index ae621ba2..5843d67b 100644 --- a/examples/example_apple_opengl2/main.mm +++ b/examples/example_apple_opengl2/main.mm @@ -1,9 +1,10 @@ -// dear imgui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" -#include "../imgui_impl_osx.h" -#include "../imgui_impl_opengl2.h" +#include "../../backends/imgui_impl_osx.h" +#include "../../backends/imgui_impl_opengl2.h" #include #import #import @@ -138,7 +139,7 @@ animationTimer = nil; } -// Forward Mouse/Keyboard events to dear imgui OSX back-end. It returns true when imgui is expecting to use the event. +// Forward Mouse/Keyboard events to dear imgui OSX backend. It returns true when imgui is expecting to use the event. -(void)keyUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } -(void)keyDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } -(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } @@ -255,7 +256,7 @@ ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplOSX_Init(); ImGui_ImplOpenGL2_Init(); diff --git a/examples/example_emscripten/Makefile b/examples/example_emscripten/Makefile index 9833270e..967d61fb 100644 --- a/examples/example_emscripten/Makefile +++ b/examples/example_emscripten/Makefile @@ -16,9 +16,10 @@ CC = emcc CXX = em++ EXE = example_emscripten.html +IMGUI_DIR = ../.. SOURCES = main.cpp -SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) @@ -51,7 +52,7 @@ endif ## FINAL BUILD FLAGS ##--------------------------------------------------------------------- -CPPFLAGS += -I../ -I../../ +CPPFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends #CPPFLAGS += -g CPPFLAGS += -Wall -Wformat -Os CPPFLAGS += $(EMS) @@ -65,10 +66,10 @@ LDFLAGS += --shell-file shell_minimal.html %.o:%.cpp $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< %.o:../libs/gl3w/GL/%.c diff --git a/examples/example_emscripten/README.md b/examples/example_emscripten/README.md index 42bab014..01a4e35e 100644 --- a/examples/example_emscripten/README.md +++ b/examples/example_emscripten/README.md @@ -16,5 +16,5 @@ _"Unfortunately several browsers (including Chrome, Safari, and Internet Explore ## Obsolete features: -- Emscripten 2.0 (August 2020) obsoleted the fastcomp back-end, only llvm is supported. +- Emscripten 2.0 (August 2020) obsoleted the fastcomp backend, only llvm is supported. - Emscripten 1.39.0 (October 2019) obsoleted the `BINARYEN_TRAP_MODE=clamp` compilation flag which was required with version older than 1.39.0 to avoid rendering artefacts. See [#2877](https://github.com/ocornut/imgui/issues/2877) for details. If you use an older version, uncomment this line in the Makefile: `#EMS += -s BINARYEN_TRAP_MODE=clamp` diff --git a/examples/example_emscripten/main.cpp b/examples/example_emscripten/main.cpp index 742d9be3..21282de7 100644 --- a/examples/example_emscripten/main.cpp +++ b/examples/example_emscripten/main.cpp @@ -1,10 +1,11 @@ -// dear imgui: standalone example application for Emscripten, using SDL2 + OpenGL3 +// Dear ImGui: standalone example application for Emscripten, using SDL2 + OpenGL3 +// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs + // This is mostly the same code as the SDL2 + OpenGL3 example, simply with the modifications needed to run on Emscripten. // It is possible to combine both code into a single source file that will compile properly on Desktop and using Emscripten. // See https://github.com/ocornut/imgui/pull/2492 as an example on how to do just that. -// -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. -// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/) #include "imgui.h" #include "imgui_impl_sdl.h" @@ -73,7 +74,7 @@ int main(int, char**) ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplSDL2_InitForOpenGL(g_Window, g_GLContext); ImGui_ImplOpenGL3_Init(glsl_version); diff --git a/examples/example_glfw_metal/Makefile b/examples/example_glfw_metal/Makefile index 35f17737..4b7599eb 100644 --- a/examples/example_glfw_metal/Makefile +++ b/examples/example_glfw_metal/Makefile @@ -7,33 +7,34 @@ #CXX = clang++ EXE = example_glfw_metal +IMGUI_DIR = ../.. SOURCES = main.mm -SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_metal.mm -SOURCES += ../../imgui.cpp ../../imgui_widgets.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_metal.mm OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore LIBS += -L/usr/local/lib -lglfw -CXXFLAGS = -I../ -I../../ -I/usr/local/include +CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include CXXFLAGS += -Wall -Wformat CFLAGS = $(CXXFLAGS) %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.mm - $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< - %.o:%.mm $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< +%.o:$(IMGUI_DIR)/backends/%.mm + $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< + all: $(EXE) @echo Build complete diff --git a/examples/example_glfw_metal/main.mm b/examples/example_glfw_metal/main.mm index d6f9ae3f..d818dba0 100644 --- a/examples/example_glfw_metal/main.mm +++ b/examples/example_glfw_metal/main.mm @@ -1,6 +1,7 @@ -// dear imgui: standalone example application for GLFW + Metal, using programmable pipeline -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for GLFW + Metal, using programmable pipeline // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_glfw.h" @@ -22,7 +23,7 @@ static void glfw_error_callback(int error, const char* description) int main(int, char**) { - // Setup Dear ImGui binding + // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; @@ -62,6 +63,7 @@ int main(int, char**) id device = MTLCreateSystemDefaultDevice();; id commandQueue = [device newCommandQueue]; + // Setup Platform/Renderer backends ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplMetal_Init(device); diff --git a/examples/example_glfw_opengl2/Makefile b/examples/example_glfw_opengl2/Makefile index 38f865ba..6bcbca5e 100644 --- a/examples/example_glfw_opengl2/Makefile +++ b/examples/example_glfw_opengl2/Makefile @@ -15,13 +15,14 @@ #CXX = clang++ EXE = example_glfw_opengl2 +IMGUI_DIR = ../.. SOURCES = main.cpp -SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_opengl2.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) -CXXFLAGS = -I../ -I../../ +CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends CXXFLAGS += -g -Wall -Wformat LIBS = @@ -63,10 +64,10 @@ endif %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< all: $(EXE) diff --git a/examples/example_glfw_opengl2/build_win32.bat b/examples/example_glfw_opengl2/build_win32.bat index 538d9a52..ce08445d 100644 --- a/examples/example_glfw_opengl2/build_win32.bat +++ b/examples/example_glfw_opengl2/build_win32.bat @@ -1,3 +1,3 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include *.cpp ..\imgui_impl_opengl2.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_opengl2.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_opengl2.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib diff --git a/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj b/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj index b265fea0..35ffdfd9 100644 --- a/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj +++ b/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj @@ -90,7 +90,7 @@ Level4 Disabled - ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) true @@ -104,7 +104,7 @@ Level4 Disabled - ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) true @@ -120,7 +120,7 @@ MaxSpeed true true - ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) false @@ -140,7 +140,7 @@ MaxSpeed true true - ..\..;..;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) false @@ -159,16 +159,16 @@ - - + + - - + + @@ -177,4 +177,4 @@ - \ No newline at end of file + diff --git a/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters b/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters index b7a37e68..4b4dd526 100644 --- a/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters +++ b/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters @@ -22,15 +22,15 @@ imgui - - sources - - - sources - imgui + + sources + + + sources + @@ -42,10 +42,10 @@ imgui - + sources - + sources @@ -55,4 +55,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_glfw_opengl2/main.cpp b/examples/example_glfw_opengl2/main.cpp index 46c651cc..f9eaf682 100644 --- a/examples/example_glfw_opengl2/main.cpp +++ b/examples/example_glfw_opengl2/main.cpp @@ -1,6 +1,7 @@ -// dear imgui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** // **Prefer using the code in the example_glfw_opengl2/ folder** @@ -62,7 +63,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL2_Init(); diff --git a/examples/example_glfw_opengl3/Makefile b/examples/example_glfw_opengl3/Makefile index 0e7faa12..1524ac6f 100644 --- a/examples/example_glfw_opengl3/Makefile +++ b/examples/example_glfw_opengl3/Makefile @@ -15,13 +15,14 @@ #CXX = clang++ EXE = example_glfw_opengl3 +IMGUI_DIR = ../.. SOURCES = main.cpp -SOURCES += ../imgui_impl_glfw.cpp ../imgui_impl_opengl3.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) -CXXFLAGS = -I../ -I../../ +CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends CXXFLAGS += -g -Wall -Wformat LIBS = @@ -93,10 +94,10 @@ endif %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< %.o:../libs/gl3w/GL/%.c diff --git a/examples/example_glfw_opengl3/build_win32.bat b/examples/example_glfw_opengl3/build_win32.bat index e5c15c53..eb755d61 100644 --- a/examples/example_glfw_opengl3/build_win32.bat +++ b/examples/example_glfw_opengl3/build_win32.bat @@ -1,3 +1,3 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I ..\libs\gl3w *.cpp ..\imgui_impl_glfw.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_glfw_opengl3.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I ..\libs\gl3w *.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_glfw_opengl3.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib diff --git a/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj b/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj index 47d25380..9c823935 100644 --- a/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj +++ b/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj @@ -90,7 +90,7 @@ Level4 Disabled - ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) true @@ -104,7 +104,7 @@ Level4 Disabled - ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) true @@ -120,7 +120,7 @@ MaxSpeed true true - ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) false @@ -140,7 +140,7 @@ MaxSpeed true true - ..\..;..;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;..\libs\glfw\include;..\libs\gl3w;%(AdditionalIncludeDirectories) false @@ -159,8 +159,8 @@ - - + + @@ -168,8 +168,8 @@ - - + + @@ -180,4 +180,4 @@ - \ No newline at end of file + diff --git a/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters b/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters index efb570ce..000e8d28 100644 --- a/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters +++ b/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters @@ -28,15 +28,15 @@ imgui - - sources - - - sources - imgui + + sources + + + sources + @@ -54,10 +54,10 @@ imgui - + sources - + sources @@ -67,4 +67,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_glfw_opengl3/main.cpp b/examples/example_glfw_opengl3/main.cpp index b3d19f49..6fa93d13 100644 --- a/examples/example_glfw_opengl3/main.cpp +++ b/examples/example_glfw_opengl3/main.cpp @@ -1,6 +1,7 @@ -// dear imgui: standalone example application for GLFW + OpenGL 3, using programmable pipeline -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for GLFW + OpenGL 3, using programmable pipeline // (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_glfw.h" @@ -126,7 +127,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init(glsl_version); diff --git a/examples/example_glfw_vulkan/CMakeLists.txt b/examples/example_glfw_vulkan/CMakeLists.txt index 023d791b..22e17a20 100644 --- a/examples/example_glfw_vulkan/CMakeLists.txt +++ b/examples/example_glfw_vulkan/CMakeLists.txt @@ -39,5 +39,5 @@ include_directories(${GLFW_DIR}/deps) file(GLOB sources *.cpp) -add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/examples/imgui_impl_glfw.cpp ${IMGUI_DIR}/examples/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_widgets.cpp) +add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp ${IMGUI_DIR}/backends/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_widgets.cpp) target_link_libraries(example_glfw_vulkan ${LIBRARIES}) diff --git a/examples/example_glfw_vulkan/build_win32.bat b/examples/example_glfw_vulkan/build_win32.bat index 0d991b9d..ad53cb07 100644 --- a/examples/example_glfw_vulkan/build_win32.bat +++ b/examples/example_glfw_vulkan/build_win32.bat @@ -1,7 +1,7 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib mkdir Release -cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib +cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib diff --git a/examples/example_glfw_vulkan/build_win64.bat b/examples/example_glfw_vulkan/build_win64.bat index ddedf597..d6b24b5b 100644 --- a/examples/example_glfw_vulkan/build_win64.bat +++ b/examples/example_glfw_vulkan/build_win64.bat @@ -1,7 +1,7 @@ @REM Build for Visual Studio compiler. Run your copy of amd64/vcvars32.bat to setup 64-bit command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib mkdir Release -cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\imgui_impl_vulkan.cpp ..\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib +cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib diff --git a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj index 9e2c9b38..d9418579 100644 --- a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj +++ b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj @@ -90,7 +90,7 @@ Level4 Disabled - ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) true @@ -104,7 +104,7 @@ Level4 Disabled - ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) true @@ -120,7 +120,7 @@ MaxSpeed true true - ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) false @@ -140,7 +140,7 @@ MaxSpeed true true - ..\..;..;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) false @@ -159,16 +159,16 @@ - - + + - - + + @@ -177,4 +177,4 @@ - \ No newline at end of file + diff --git a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters index 98a445d4..43f5f5b6 100644 --- a/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters +++ b/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters @@ -10,6 +10,9 @@ + + sources + imgui @@ -19,18 +22,15 @@ imgui - - sources - - - sources - - - sources - imgui + + sources + + + sources + @@ -42,10 +42,10 @@ imgui - + sources - + sources @@ -55,4 +55,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_glfw_vulkan/main.cpp b/examples/example_glfw_vulkan/main.cpp index 08307be6..baad2195 100644 --- a/examples/example_glfw_vulkan/main.cpp +++ b/examples/example_glfw_vulkan/main.cpp @@ -1,11 +1,12 @@ -// dear imgui: standalone example application for Glfw + Vulkan -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for Glfw + Vulkan +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. // - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering back-end in your engine/app. +// You will use those if you want to use this rendering backend in your engine/app. // - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. +// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. // Read comments in imgui_impl_vulkan.h. #include "imgui.h" @@ -393,7 +394,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplGlfw_InitForVulkan(window, true); ImGui_ImplVulkan_InitInfo init_info = {}; init_info.Instance = g_Instance; diff --git a/examples/example_glut_opengl2/Makefile b/examples/example_glut_opengl2/Makefile index 70576b8f..21984cec 100644 --- a/examples/example_glut_opengl2/Makefile +++ b/examples/example_glut_opengl2/Makefile @@ -10,13 +10,14 @@ #CXX = clang++ EXE = example_glut_opengl2 +IMGUI_DIR = ../.. SOURCES = main.cpp -SOURCES += ../imgui_impl_glut.cpp ../imgui_impl_opengl2.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glut.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) -CXXFLAGS = -I../ -I../../ +CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends CXXFLAGS += -g -Wall -Wformat LIBS = @@ -58,10 +59,10 @@ endif %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< all: $(EXE) diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj index 9a239516..736e6e7a 100644 --- a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj +++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj @@ -159,16 +159,16 @@ - - + + - - + + @@ -177,4 +177,4 @@ - \ No newline at end of file + diff --git a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters index 290d43d7..8f8fd955 100644 --- a/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters +++ b/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters @@ -22,15 +22,15 @@ imgui - - sources - - - sources - imgui + + sources + + + sources + @@ -42,10 +42,10 @@ imgui - + sources - + sources diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp index 73a57216..6ce1e706 100644 --- a/examples/example_glut_opengl2/main.cpp +++ b/examples/example_glut_opengl2/main.cpp @@ -1,5 +1,6 @@ -// dear imgui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! // !!! If someone or something is teaching you GLUT in 2020, you are being abused. Please show some resistance. !!! @@ -116,7 +117,7 @@ int main(int argc, char** argv) ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplGLUT_Init(); ImGui_ImplGLUT_InstallFuncs(); ImGui_ImplOpenGL2_Init(); diff --git a/examples/example_marmalade/main.cpp b/examples/example_marmalade/main.cpp index 7260cda0..09c67d4d 100644 --- a/examples/example_marmalade/main.cpp +++ b/examples/example_marmalade/main.cpp @@ -1,5 +1,6 @@ -// dear imgui: standalone example application for Marmalade -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for Marmalade +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // Copyright (C) 2015 by Giovanni Zito // This file is part of Dear ImGui @@ -27,7 +28,7 @@ int main(int, char**) ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_Marmalade_Init(true); // Load Fonts diff --git a/examples/example_marmalade/marmalade_example.mkb b/examples/example_marmalade/marmalade_example.mkb index 34315b9a..bf5d1b86 100644 --- a/examples/example_marmalade/marmalade_example.mkb +++ b/examples/example_marmalade/marmalade_example.mkb @@ -17,8 +17,8 @@ options includepaths { - .. ../.. + ../../backends } subprojects @@ -38,9 +38,9 @@ files ../../imgui.h ../../imgui_internal.h - ["imgui","Marmalade binding"] - ../imgui_impl_marmalade.h - ../imgui_impl_marmalade.cpp + ["imgui","Marmalade backend"] + ../../backends/imgui_impl_marmalade.h + ../../backends/imgui_impl_marmalade.cpp main.cpp } diff --git a/examples/example_null/Makefile b/examples/example_null/Makefile index 15c547a5..25cecd82 100644 --- a/examples/example_null/Makefile +++ b/examples/example_null/Makefile @@ -2,7 +2,7 @@ # Cross Platform Makefile # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X # -# Important: This is a "null back-end" application, with no visible output or interaction! +# Important: This is a "null backend" application, with no visible output or interaction! # This is used for testing purpose and continuous integration, and has little use for end-user. # @@ -11,12 +11,13 @@ WITH_EXTRA_WARNINGS ?= 0 WITH_FREETYPE ?= 0 EXE = example_null +IMGUI_DIR = ../.. SOURCES = main.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) -CXXFLAGS += -I../ -I../../ +CXXFLAGS += -I$(IMGUI_DIR) CXXFLAGS += -g -Wall -Wformat LIBS = @@ -28,7 +29,7 @@ endif # We use the WITH_FREETYPE flag on our CI setup to test compiling misc/freetype/imgui_freetype.cpp # (only supported on Linux, and note that the imgui_freetype code currently won't be executed) ifeq ($(WITH_FREETYPE), 1) - SOURCES += ../../misc/freetype/imgui_freetype.cpp + SOURCES += $(IMGUI_DIR)/misc/freetype/imgui_freetype.cpp CXXFLAGS += $(shell pkg-config --cflags freetype2) LIBS += $(shell pkg-config --libs freetype2) endif @@ -71,13 +72,13 @@ endif %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../misc/freetype/%.cpp +%.o:$(IMGUI_DIR)/misc/freetype/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< all: $(EXE) diff --git a/examples/example_sdl_directx11/build_win32.bat b/examples/example_sdl_directx11/build_win32.bat index 8fc702bb..b0b4d88a 100644 --- a/examples/example_sdl_directx11/build_win32.bat +++ b/examples/example_sdl_directx11/build_win32.bat @@ -2,7 +2,7 @@ set OUT_DIR=Debug set OUT_EXE=example_sdl_directx11 set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" -set SOURCES=main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_dx11.cpp ..\..\imgui*.cpp +set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib mkdir %OUT_DIR% cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/examples/example_sdl_directx11/example_sdl_directx11.vcxproj b/examples/example_sdl_directx11/example_sdl_directx11.vcxproj index 804bd500..690c660d 100644 --- a/examples/example_sdl_directx11/example_sdl_directx11.vcxproj +++ b/examples/example_sdl_directx11/example_sdl_directx11.vcxproj @@ -91,7 +91,7 @@ Level4 Disabled - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) true @@ -105,7 +105,7 @@ Level4 Disabled - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) true @@ -121,7 +121,7 @@ MaxSpeed true true - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) false @@ -141,7 +141,7 @@ MaxSpeed true true - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) false @@ -160,16 +160,16 @@ - - + + - - + + @@ -178,4 +178,4 @@ - \ No newline at end of file + diff --git a/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters b/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters index 879f0dbe..d1f0876e 100644 --- a/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters +++ b/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters @@ -18,10 +18,10 @@ imgui - + sources - + sources @@ -38,13 +38,13 @@ imgui - - sources - imgui - + + sources + + sources @@ -54,4 +54,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_sdl_directx11/main.cpp b/examples/example_sdl_directx11/main.cpp index ab9ca296..11dc8a0a 100644 --- a/examples/example_sdl_directx11/main.cpp +++ b/examples/example_sdl_directx11/main.cpp @@ -1,6 +1,7 @@ -// dear imgui: standalone example application for SDL2 + DirectX 11 -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for SDL2 + DirectX 11 // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_sdl.h" @@ -72,7 +73,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplSDL2_InitForD3D(window); ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); diff --git a/examples/example_sdl_metal/Makefile b/examples/example_sdl_metal/Makefile index 9d0d5e0f..53c8aabb 100644 --- a/examples/example_sdl_metal/Makefile +++ b/examples/example_sdl_metal/Makefile @@ -7,16 +7,17 @@ #CXX = clang++ EXE = example_sdl_metal +IMGUI_DIR = ../.. SOURCES = main.mm -SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_metal.mm -SOURCES += ../../imgui.cpp ../../imgui_widgets.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_metal.mm OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore LIBS += `sdl2-config --libs` LIBS += -L/usr/local/lib -CXXFLAGS = -I../ -I../../ -I/usr/local/include +CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include CXXFLAGS += `sdl2-config --cflags` CXXFLAGS += -Wall -Wformat CFLAGS = $(CXXFLAGS) @@ -24,18 +25,18 @@ CFLAGS = $(CXXFLAGS) %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.mm - $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< - %.o:%.mm $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< +%.o:$(IMGUI_DIR)/backends/%.mm + $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< + all: $(EXE) @echo Build complete diff --git a/examples/example_sdl_metal/main.mm b/examples/example_sdl_metal/main.mm index 3cb1ea4d..1f33503d 100644 --- a/examples/example_sdl_metal/main.mm +++ b/examples/example_sdl_metal/main.mm @@ -1,6 +1,7 @@ // Dear ImGui: standalone example application for SDL2 + Metal -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_sdl.h" @@ -13,7 +14,7 @@ int main(int, char**) { - // Setup Dear ImGui binding + // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; @@ -65,6 +66,7 @@ int main(int, char**) return -3; } + // Setup Platform/Renderer backends CAMetalLayer* layer = (__bridge CAMetalLayer*)SDL_RenderGetMetalLayer(renderer); layer.pixelFormat = MTLPixelFormatBGRA8Unorm; ImGui_ImplMetal_Init(layer.device); diff --git a/examples/example_sdl_opengl2/Makefile b/examples/example_sdl_opengl2/Makefile index 9c57337e..2da745d7 100644 --- a/examples/example_sdl_opengl2/Makefile +++ b/examples/example_sdl_opengl2/Makefile @@ -15,13 +15,14 @@ #CXX = clang++ EXE = example_sdl_opengl2 +IMGUI_DIR = ../.. SOURCES = main.cpp -SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) -CXXFLAGS = -I../ -I../../ +CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends CXXFLAGS += -g -Wall -Wformat LIBS = @@ -62,10 +63,10 @@ endif %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< all: $(EXE) diff --git a/examples/example_sdl_opengl2/README.md b/examples/example_sdl_opengl2/README.md index 60a5e377..00900638 100644 --- a/examples/example_sdl_opengl2/README.md +++ b/examples/example_sdl_opengl2/README.md @@ -5,21 +5,21 @@ ``` set SDL2_DIR=path_to_your_sdl2_folder -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console # ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries # or for 64-bit: -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console ``` - On Linux and similar Unixes ``` -c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL +c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL ``` - On Mac OS X ``` brew install sdl2 -c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl +c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl ``` diff --git a/examples/example_sdl_opengl2/build_win32.bat b/examples/example_sdl_opengl2/build_win32.bat index d209b2a2..71157f5f 100644 --- a/examples/example_sdl_opengl2/build_win32.bat +++ b/examples/example_sdl_opengl2/build_win32.bat @@ -2,7 +2,7 @@ set OUT_DIR=Debug set OUT_EXE=example_sdl_opengl2 set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include -set SOURCES=main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl2.cpp ..\..\imgui*.cpp +set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib mkdir %OUT_DIR% cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj index 83a6a8a0..b8eb9219 100644 --- a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj +++ b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj @@ -90,7 +90,7 @@ Level4 Disabled - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) true @@ -104,7 +104,7 @@ Level4 Disabled - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) true @@ -120,7 +120,7 @@ MaxSpeed true true - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) false @@ -140,7 +140,7 @@ MaxSpeed true true - ..\..;..;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) false @@ -159,16 +159,16 @@ - - + + - - + + @@ -177,4 +177,4 @@ - \ No newline at end of file + diff --git a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters index e0c1bf2e..65acfe43 100644 --- a/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters +++ b/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters @@ -22,15 +22,15 @@ sources - - sources - - - sources - imgui + + sources + + + sources + @@ -42,10 +42,10 @@ imgui - + sources - + sources @@ -55,4 +55,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_sdl_opengl2/main.cpp b/examples/example_sdl_opengl2/main.cpp index 61b1dc9e..388512cc 100644 --- a/examples/example_sdl_opengl2/main.cpp +++ b/examples/example_sdl_opengl2/main.cpp @@ -1,6 +1,7 @@ -// dear imgui: standalone example application for SDL2 + OpenGL -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for SDL2 + OpenGL // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** // **Prefer using the code in the example_sdl_opengl3/ folder** @@ -60,7 +61,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplSDL2_InitForOpenGL(window, gl_context); ImGui_ImplOpenGL2_Init(); diff --git a/examples/example_sdl_opengl3/Makefile b/examples/example_sdl_opengl3/Makefile index e8009a4c..b408ce35 100644 --- a/examples/example_sdl_opengl3/Makefile +++ b/examples/example_sdl_opengl3/Makefile @@ -15,13 +15,14 @@ #CXX = clang++ EXE = example_sdl_opengl3 +IMGUI_DIR = ../.. SOURCES = main.cpp -SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp -SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_widgets.cpp +SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) -CXXFLAGS = -I../ -I../../ +CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends CXXFLAGS += -g -Wall -Wformat LIBS = @@ -92,10 +93,10 @@ endif %.o:%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../%.cpp +%.o:$(IMGUI_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< -%.o:../../%.cpp +%.o:$(IMGUI_DIR)/backends/%.cpp $(CXX) $(CXXFLAGS) -c -o $@ $< %.o:../libs/gl3w/GL/%.c diff --git a/examples/example_sdl_opengl3/README.md b/examples/example_sdl_opengl3/README.md index ec21fb78..edeafec3 100644 --- a/examples/example_sdl_opengl3/README.md +++ b/examples/example_sdl_opengl3/README.md @@ -5,21 +5,21 @@ ``` set SDL2_DIR=path_to_your_sdl2_folder -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console # ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries # or for 64-bit: -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console +cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console ``` - On Linux and similar Unixes ``` -c++ `sdl2-config --cflags` -I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -ldl +c++ `sdl2-config --cflags` -I .. -I ../.. -I ../libs/gl3w main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -ldl ``` - On Mac OS X ``` brew install sdl2 -c++ `sdl2-config --cflags` -I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -framework OpenGl -framework CoreFoundation +c++ `sdl2-config --cflags` -I .. -I ../.. -I ../libs/gl3w main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -framework OpenGl -framework CoreFoundation ``` diff --git a/examples/example_sdl_opengl3/build_win32.bat b/examples/example_sdl_opengl3/build_win32.bat index ce105602..d13cc940 100644 --- a/examples/example_sdl_opengl3/build_win32.bat +++ b/examples/example_sdl_opengl3/build_win32.bat @@ -2,7 +2,7 @@ set OUT_DIR=Debug set OUT_EXE=example_sdl_opengl3 set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w -set SOURCES=main.cpp ..\imgui_impl_sdl.cpp ..\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c +set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib mkdir %OUT_DIR% cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj index 54aaa796..c8d67f98 100644 --- a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj +++ b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj @@ -90,7 +90,7 @@ Level4 Disabled - ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) true @@ -104,7 +104,7 @@ Level4 Disabled - ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) true @@ -120,7 +120,7 @@ MaxSpeed true true - ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) false @@ -140,7 +140,7 @@ MaxSpeed true true - ..\..;..;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%SDL2_DIR%\include;..\libs\gl3w;%(AdditionalIncludeDirectories) false @@ -159,8 +159,8 @@ - - + + @@ -168,8 +168,8 @@ - - + + diff --git a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters index fbef18ac..ade2c96c 100644 --- a/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters +++ b/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters @@ -28,10 +28,10 @@ gl3w - + sources - + sources @@ -54,10 +54,10 @@ gl3w - + sources - + sources @@ -67,4 +67,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_sdl_opengl3/main.cpp b/examples/example_sdl_opengl3/main.cpp index 0779157d..4b1896ac 100644 --- a/examples/example_sdl_opengl3/main.cpp +++ b/examples/example_sdl_opengl3/main.cpp @@ -1,7 +1,8 @@ -// dear imgui: standalone example application for SDL2 + OpenGL -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for SDL2 + OpenGL // (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) // (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.) +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_sdl.h" @@ -121,7 +122,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplSDL2_InitForOpenGL(window, gl_context); ImGui_ImplOpenGL3_Init(glsl_version); diff --git a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj index ac701a2a..84cc94b4 100644 --- a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj +++ b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj @@ -90,7 +90,7 @@ Level4 Disabled - ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) true @@ -104,7 +104,7 @@ Level4 Disabled - ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) true @@ -120,7 +120,7 @@ MaxSpeed true true - ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) false @@ -140,7 +140,7 @@ MaxSpeed true true - ..\..;..;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) false @@ -159,16 +159,16 @@ - - + + - - + + diff --git a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters index 6f082524..8a6b48e3 100644 --- a/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters +++ b/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters @@ -19,13 +19,13 @@ imgui - + sources sources - + sources @@ -42,10 +42,10 @@ imgui - + sources - + sources diff --git a/examples/example_sdl_vulkan/main.cpp b/examples/example_sdl_vulkan/main.cpp index 9b8ac52f..59827fb0 100644 --- a/examples/example_sdl_vulkan/main.cpp +++ b/examples/example_sdl_vulkan/main.cpp @@ -1,11 +1,12 @@ -// dear imgui: standalone example application for SDL2 + Vulkan -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for SDL2 + Vulkan +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. // - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering back-end in your engine/app. +// You will use those if you want to use this rendering backend in your engine/app. // - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the back-end itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. +// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. // Read comments in imgui_impl_vulkan.h. #include "imgui.h" @@ -385,7 +386,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplSDL2_InitForVulkan(window); ImGui_ImplVulkan_InitInfo init_info = {}; init_info.Instance = g_Instance; diff --git a/examples/example_win32_directx10/build_win32.bat b/examples/example_win32_directx10/build_win32.bat index d79cb8f7..75cb837e 100644 --- a/examples/example_win32_directx10/build_win32.bat +++ b/examples/example_win32_directx10/build_win32.bat @@ -1,4 +1,4 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_win32.cpp ..\imgui_impl_dx10.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx10.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\backends\imgui_impl_dx10.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx10.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib diff --git a/examples/example_win32_directx10/example_win32_directx10.vcxproj b/examples/example_win32_directx10/example_win32_directx10.vcxproj index 5c3aa69f..4a24dc1b 100644 --- a/examples/example_win32_directx10/example_win32_directx10.vcxproj +++ b/examples/example_win32_directx10/example_win32_directx10.vcxproj @@ -86,7 +86,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); true @@ -99,7 +99,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); true @@ -114,7 +114,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); false @@ -132,7 +132,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); false @@ -148,16 +148,16 @@ - - + + - - + + diff --git a/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters b/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters index 97620028..16107c9c 100644 --- a/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters +++ b/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters @@ -18,10 +18,10 @@ imgui - + sources - + sources @@ -38,10 +38,10 @@ imgui - + sources - + sources diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index c475b80f..49589536 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -1,5 +1,6 @@ -// dear imgui: standalone example application for DirectX 10 -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for DirectX 10 +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_win32.h" @@ -68,7 +69,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplWin32_Init(hwnd); ImGui_ImplDX10_Init(g_pd3dDevice); diff --git a/examples/example_win32_directx11/build_win32.bat b/examples/example_win32_directx11/build_win32.bat index 05e6a6f6..cbe96b04 100644 --- a/examples/example_win32_directx11/build_win32.bat +++ b/examples/example_win32_directx11/build_win32.bat @@ -1,4 +1,4 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx11.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx11.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx11.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib diff --git a/examples/example_win32_directx11/example_win32_directx11.vcxproj b/examples/example_win32_directx11/example_win32_directx11.vcxproj index bcb71bc4..e9945db9 100644 --- a/examples/example_win32_directx11/example_win32_directx11.vcxproj +++ b/examples/example_win32_directx11/example_win32_directx11.vcxproj @@ -85,7 +85,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); true @@ -98,7 +98,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); true @@ -113,7 +113,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); false @@ -131,7 +131,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories); + ..\..;..\..\backends;%(AdditionalIncludeDirectories); false @@ -147,16 +147,16 @@ - - + + - - + + @@ -166,4 +166,4 @@ - \ No newline at end of file + diff --git a/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters b/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters index 1df6a0c4..6956b586 100644 --- a/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters +++ b/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters @@ -18,10 +18,10 @@ imgui - + sources - + sources @@ -38,15 +38,15 @@ imgui - - sources - - - sources - imgui + + sources + + + sources + @@ -54,4 +54,4 @@ sources - \ No newline at end of file + diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index 1062d6fd..e6a098d6 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -1,5 +1,6 @@ -// dear imgui - standalone example application for DirectX 11 -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for DirectX 11 +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_win32.h" @@ -75,7 +76,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplWin32_Init(hwnd); ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); diff --git a/examples/example_win32_directx12/build_win32.bat b/examples/example_win32_directx12/build_win32.bat index 85a52b70..5556dfef 100644 --- a/examples/example_win32_directx12/build_win32.bat +++ b/examples/example_win32_directx12/build_win32.bat @@ -1,5 +1,5 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@REM Important: to build on 32-bit systems, the DX12 back-ends needs '#define ImTextureID ImU64', so we pass it here. +@REM Important: to build on 32-bit systems, the DX12 backends needs '#define ImTextureID ImU64', so we pass it here. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /D ImTextureID=ImU64 /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx12.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx12.exe /FoDebug/ /link d3d12.lib d3dcompiler.lib dxgi.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /D ImTextureID=ImU64 /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_dx12.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx12.exe /FoDebug/ /link d3d12.lib d3dcompiler.lib dxgi.lib diff --git a/examples/example_win32_directx12/example_win32_directx12.vcxproj b/examples/example_win32_directx12/example_win32_directx12.vcxproj index f03bf760..452328ce 100644 --- a/examples/example_win32_directx12/example_win32_directx12.vcxproj +++ b/examples/example_win32_directx12/example_win32_directx12.vcxproj @@ -86,7 +86,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%(AdditionalIncludeDirectories) ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -100,7 +100,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%(AdditionalIncludeDirectories) ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -116,7 +116,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%(AdditionalIncludeDirectories) ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -134,7 +134,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories) + ..\..;..\..\backends;%(AdditionalIncludeDirectories) ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -150,16 +150,16 @@ - - + + - - + + diff --git a/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters b/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters index 28a25572..754c2954 100644 --- a/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters +++ b/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters @@ -18,10 +18,10 @@ imgui - + sources - + sources @@ -38,10 +38,10 @@ imgui - + sources - + sources diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index 690ae67c..f711602a 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -1,5 +1,6 @@ -// dear imgui: standalone example application for DirectX 12 -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for DirectX 12 +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs // FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)) #include "imgui.h" @@ -97,7 +98,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplWin32_Init(hwnd); ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT, DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap, diff --git a/examples/example_win32_directx9/build_win32.bat b/examples/example_win32_directx9/build_win32.bat index 4db27653..13781036 100644 --- a/examples/example_win32_directx9/build_win32.bat +++ b/examples/example_win32_directx9/build_win32.bat @@ -1,3 +1,3 @@ @REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. mkdir Debug -cl /nologo /Zi /MD /I .. /I ..\.. /I "%DXSDK_DIR%/Include" /D UNICODE /D _UNICODE *.cpp ..\imgui_impl_dx9.cpp ..\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx9.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib +cl /nologo /Zi /MD /I .. /I ..\.. /I "%DXSDK_DIR%/Include" /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_dx9.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx9.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib diff --git a/examples/example_win32_directx9/example_win32_directx9.vcxproj b/examples/example_win32_directx9/example_win32_directx9.vcxproj index 25bdd859..a33833b3 100644 --- a/examples/example_win32_directx9/example_win32_directx9.vcxproj +++ b/examples/example_win32_directx9/example_win32_directx9.vcxproj @@ -86,7 +86,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; + ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; true @@ -99,7 +99,7 @@ Level4 Disabled - ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; + ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; true @@ -114,7 +114,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; + ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; false @@ -132,7 +132,7 @@ MaxSpeed true true - ..\..;..;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; + ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; false @@ -149,16 +149,16 @@ - - + + - - + + diff --git a/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters b/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters index 914cd260..2a684553 100644 --- a/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters +++ b/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters @@ -22,10 +22,10 @@ imgui - + sources - + sources @@ -42,10 +42,10 @@ imgui - + sources - + sources diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index 665cff00..c7da3211 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -1,5 +1,6 @@ -// dear imgui: standalone example application for DirectX 9 -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. +// Dear ImGui: standalone example application for DirectX 9 +// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. +// Read online: https://github.com/ocornut/imgui/tree/master/docs #include "imgui.h" #include "imgui_impl_dx9.h" @@ -66,7 +67,7 @@ int main(int, char**) style.Colors[ImGuiCol_WindowBg].w = 1.0f; } - // Setup Platform/Renderer bindings + // Setup Platform/Renderer backends ImGui_ImplWin32_Init(hwnd); ImGui_ImplDX9_Init(g_pd3dDevice); diff --git a/imconfig.h b/imconfig.h index 6b87dd6c..280d1436 100644 --- a/imconfig.h +++ b/imconfig.h @@ -76,12 +76,12 @@ */ //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. -// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices). +// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. //#define ImDrawIdx unsigned int -//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly) +//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) //struct ImDrawList; //struct ImDrawCmd; //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); diff --git a/imgui.cpp b/imgui.cpp index 6c7ca4b8..b9ebd0d5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 +// dear imgui, v1.80 WIP // (main code and documentation) // Help: @@ -169,21 +169,21 @@ CODE GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE --------------------------------------------------------------- - Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library. - - In the majority of cases you should be able to use unmodified back-ends files available in the examples/ folder. - - Add the Dear ImGui source files + selected back-end source files to your projects or using your preferred build system. + - In the majority of cases you should be able to use unmodified backends files available in the examples/ folder. + - Add the Dear ImGui source files + selected backend source files to your projects or using your preferred build system. It is recommended you build and statically link the .cpp files as part of your project and NOT as shared library (DLL). - You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating Dear ImGui types with your own maths types. - When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them. - Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide. Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases of your own application. All rendering information are stored into command-lists that you will retrieve after calling ImGui::Render(). - - Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code. + - Refer to the backends and demo applications in the examples/ folder for instruction on how to setup your code. - If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder. HOW A SIMPLE APPLICATION MAY LOOK LIKE -------------------------------------- - EXHIBIT 1: USING THE EXAMPLE BINDINGS (= imgui_impl_XXX.cpp files from the examples/ folder). + EXHIBIT 1: USING THE EXAMPLE BACKENDS (= imgui_impl_XXX.cpp files from the backends/ folder). The sub-folders in examples/ contains examples applications following this structure. // Application init: create a dear imgui context, setup some options, load fonts @@ -193,7 +193,7 @@ CODE // TODO: Fill optional fields of the io structure later. // TODO: Load TTF/OTF fonts if you don't want to use the default font. - // Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32.cpp and imgui_impl_dx11.cpp) + // Initialize helper Platform and Renderer backends (here we are using imgui_impl_win32.cpp and imgui_impl_dx11.cpp) ImGui_ImplWin32_Init(hwnd); ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); @@ -219,7 +219,7 @@ CODE ImGui_ImplWin32_Shutdown(); ImGui::DestroyContext(); - EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE + EXHIBIT 2: IMPLEMENTING CUSTOM BACKEND / CUSTOM ENGINE // Application init: create a dear imgui context, setup some options, load fonts ImGui::CreateContext(); @@ -244,7 +244,7 @@ CODE while (true) { // Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc. - // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform bindings) + // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform Backends) io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds) io.DisplaySize.x = 1920.0f; // set the current display width io.DisplaySize.y = 1280.0f; // set the current display height here @@ -280,7 +280,7 @@ CODE HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE --------------------------------------------- - The bindings in impl_impl_XXX.cpp files contains many working implementations of a rendering function. + The backends in impl_impl_XXX.cpp files contains many working implementations of a rendering function. void void MyImGuiRenderFunction(ImDrawData* draw_data) { @@ -359,7 +359,7 @@ CODE - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag. Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements. When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved. - When that happens your back-end NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the binding in examples/ do that. + When that happens your backend NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the backends in examples/ do that. (If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse as moving back and forth!) (In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want to set a boolean to ignore your other external mouse positions until the external source is moved again.) @@ -382,6 +382,16 @@ CODE - 2020/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api. + - 2020/10/14 (1.80) - backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/. + - 2020/10/12 (1.80) - removed redirecting functions/enums that were marked obsolete in 1.60 (April 2018): + - io.RenderDrawListsFn pointer -> use ImGui::GetDrawData() value and call the render function of your backend + - ImGui::IsAnyWindowFocused() -> use ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) + - ImGui::IsAnyWindowHovered() -> use ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) + - ImGuiStyleVar_Count_ -> use ImGuiStyleVar_COUNT + - ImGuiMouseCursor_Count_ -> use ImGuiMouseCursor_COUNT + - removed redirecting functions names that were marked obsolete in 1.61 (May 2018): + - InputFloat (... int decimal_precision ...) -> use InputFloat (... const char* format ...) with format = "%.Xf" where X is your value for decimal_precision. + - same for InputFloat2()/InputFloat3()/InputFloat4() variants taking a `int decimal_precision` parameter. - 2020/10/05 (1.79) - removed ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed). - 2020/09/25 (1.79) - renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete sooner because previous name was added recently). - 2020/09/25 (1.79) - renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. @@ -464,10 +474,10 @@ CODE - 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency. - 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time. - 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete). - - 2018/06/08 (1.62) - examples: the imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.). - old bindings will still work as is, however prefer using the separated bindings as they will be updated to support multi-viewports. - when adopting new bindings follow the main.cpp code of your preferred examples/ folder to know which functions to call. - in particular, note that old bindings called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function. + - 2018/06/08 (1.62) - examples: the imgui_impl_XXX files have been split to separate platform (Win32, GLFW, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.). + old backends will still work as is, however prefer using the separated backends as they will be updated to support multi-viewports. + when adopting new backends follow the main.cpp code of your preferred examples/ folder to know which functions to call. + in particular, note that old backends called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function. - 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set. - 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details. - 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more. @@ -477,7 +487,7 @@ CODE - 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format", consistent with other functions. Kept redirection functions (will obsolete). - 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value. - - 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some binding ahead of merging the Nav branch). + - 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some backend ahead of merging the Nav branch). - 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now. - 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. - 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums. @@ -521,7 +531,7 @@ CODE - 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete). - 2017/09/26 (1.52) - renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete). - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete). - - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)". + - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your backend if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)". - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)! - renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete). - renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete). @@ -568,7 +578,7 @@ CODE you need to render your textured triangles with bilinear filtering to benefit from sub-pixel positioning of text. - 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost. this necessary change will break your rendering function! the fix should be very easy. sorry for that :( - - if you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update your copy and you can ignore the rest. + - if you are using a vanilla copy of one of the imgui_impl_XXX.cpp provided in the example, you just need to update your copy and you can ignore the rest. - the signature of the io.RenderDrawListsFn handler has changed! old: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) new: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data). @@ -819,7 +829,7 @@ CODE static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear -// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end) +// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by backend) static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow(). static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time. static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved. @@ -979,7 +989,7 @@ ImGuiStyle::ImGuiStyle() DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. - AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require back-end to render with bilinear filtering. + AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering. AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.). CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. CircleSegmentMaxError = 1.60f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. @@ -1075,10 +1085,6 @@ ImGuiIO::ImGuiIO() SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; ClipboardUserData = NULL; -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - RenderDrawListsFn = NULL; -#endif - // Input (NB: we already have memset zero the entire structure!) MousePos = ImVec2(-FLT_MAX, -FLT_MAX); MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX); @@ -3368,6 +3374,24 @@ void ImGui::DestroyContext(ImGuiContext* ctx) IM_DELETE(ctx); } +// No specific ordering/dependency support, will see as needed +void ImGui::AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook) +{ + ImGuiContext& g = *ctx; + IM_ASSERT(hook->Callback != NULL); + g.Hooks.push_back(*hook); +} + +// Call context hooks (used by e.g. test engine) +// We assume a small number of hooks so all stored in same array +void ImGui::CallContextHooks(ImGuiContext* ctx, ImGuiContextHookType hook_type) +{ + ImGuiContext& g = *ctx; + for (int n = 0; n < g.Hooks.Size; n++) + if (g.Hooks[n].Type == hook_type) + g.Hooks[n].Callback(&g, &g.Hooks[n]); +} + ImGuiIO& ImGui::GetIO() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); @@ -3380,7 +3404,7 @@ ImGuiPlatformIO& ImGui::GetPlatformIO() return GImGui->PlatformIO; } -// Same value as passed to the old io.RenderDrawListsFn function. Valid after Render() and until the next call to NewFrame() +// Pass this to your backend rendering function! Valid after Render() and until the next call to NewFrame() ImDrawData* ImGui::GetDrawData() { ImGuiContext& g = *GImGui; @@ -3903,9 +3927,7 @@ void ImGui::NewFrame() IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); ImGuiContext& g = *GImGui; -#ifdef IMGUI_ENABLE_TEST_ENGINE - ImGuiTestEngineHook_PreNewFrame(&g); -#endif + CallContextHooks(&g, ImGuiContextHookType_NewFramePre); // Check and assert for various common IO and Configuration mistakes g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame; @@ -4088,9 +4110,7 @@ void ImGui::NewFrame() Begin("Debug##Default"); IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true); -#ifdef IMGUI_ENABLE_TEST_ENGINE - ImGuiTestEngineHook_PostNewFrame(&g); -#endif + CallContextHooks(&g, ImGuiContextHookType_NewFramePost); } // [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack. @@ -4186,7 +4206,7 @@ void ImGui::Shutdown(ImGuiContext* context) if (g.SettingsLoaded && g.IO.IniFilename != NULL) { ImGuiContext* backup_context = GImGui; - SetCurrentContext(context); + SetCurrentContext(&g); SaveIniSettingsToDisk(g.IO.IniFilename); SetCurrentContext(backup_context); } @@ -4200,10 +4220,7 @@ void ImGui::Shutdown(ImGuiContext* context) // Shutdown extensions DockContextShutdown(&g); - // Notify hooked test engine, if any -#ifdef IMGUI_ENABLE_TEST_ENGINE - ImGuiTestEngineHook_Shutdown(context); -#endif + CallContextHooks(&g, ImGuiContextHookType_Shutdown); // Clear everything else for (int i = 0; i < g.Windows.Size; i++) @@ -4302,11 +4319,11 @@ static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* d // - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds. // Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics window to inspect draw list contents. // - If you want large meshes with more than 64K vertices, you can either: - // (A) Handle the ImDrawCmd::VtxOffset value in your renderer back-end, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'. - // Most example back-ends already support this from 1.71. Pre-1.71 back-ends won't. + // (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'. + // Most example backends already support this from 1.71. Pre-1.71 backends won't. // Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them. - // (B) Or handle 32-bit indices in your renderer back-end, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h. - // Most example back-ends already support this. For example, the OpenGL example code detect index size at compile-time: + // (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h. + // Most example backends already support this. For example, the OpenGL example code detect index size at compile-time: // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); // Your own engine or render API may use different parameters or function calls to specify index sizes. // 2 and 4 bytes indices are generally supported by most graphics API. @@ -4359,7 +4376,7 @@ void ImDrawDataBuilder::FlattenIntoSingleLayer() static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector* draw_lists) { // When minimized, we report draw_data->DisplaySize as zero to be consistent with non-viewport mode, - // and to allow applications/back-ends to easily skip rendering. + // and to allow applications/backends to easily skip rendering. // FIXME: Note that we however do NOT attempt to report "zero drawlist / vertices" into the ImDrawData structure. // This is because the work has been done already, and its wasted! We should fix that and add optimizations for // it earlier in the pipeline, rather than pretend to hide the data at the end of the pipeline. @@ -4474,6 +4491,8 @@ void ImGui::EndFrame() return; IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?"); + CallContextHooks(&g, ImGuiContextHookType_EndFramePre); + ErrorCheckEndFrameSanityChecks(); // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) @@ -4550,6 +4569,8 @@ void ImGui::EndFrame() g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f; g.IO.InputQueueCharacters.resize(0); memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs)); + + CallContextHooks(&g, ImGuiContextHookType_EndFramePost); } void ImGui::Render() @@ -4562,6 +4583,8 @@ void ImGui::Render() g.FrameCountRendered = g.FrameCount; g.IO.MetricsRenderWindows = 0; + CallContextHooks(&g, ImGuiContextHookType_RenderPre); + // Add background ImDrawList (for each active viewport) for (int n = 0; n != g.Viewports.Size; n++) { @@ -4614,11 +4637,7 @@ void ImGui::Render() g.IO.MetricsRenderIndices += viewport->DrawData->TotalIdxCount; } - // (Legacy) Call the Render callback function. The current prefer way is to let the user retrieve GetDrawData() and call the render function themselves. -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - if (g.Viewports[0]->DrawData->CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL) - g.IO.RenderDrawListsFn(g.Viewports[0]->DrawData); -#endif + CallContextHooks(&g, ImGuiContextHookType_RenderPost); } // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. @@ -4740,7 +4759,7 @@ int ImGui::GetKeyIndex(ImGuiKey imgui_key) } // Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]! -// Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]! +// Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]! bool ImGui::IsKeyDown(int user_key_index) { if (user_key_index < 0) @@ -4896,7 +4915,7 @@ bool ImGui::IsAnyMouseDown() // Return the delta from the initial clicking position while the mouse button is clicked or was just released. // This is locked and return 0.0f until the mouse moves past a distance threshold at least once. -// NB: This is only valid if IsMousePosValid(). Back-ends in theory should always keep mouse position valid when dragging even outside the client window. +// NB: This is only valid if IsMousePosValid(). backends in theory should always keep mouse position valid when dragging even outside the client window. ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) { ImGuiContext& g = *GImGui; @@ -5485,7 +5504,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s // Clip mouse interaction rectangles within the viewport rectangle (in practice the narrowing is going to happen most of the time). // - Not narrowing would mostly benefit the situation where OS windows _without_ decoration have a threshold for hovering when outside their limits. - // This is however not the case with current back-ends under Win32, but a custom borderless window implementation would benefit from it. + // This is however not the case with current backends under Win32, but a custom borderless window implementation would benefit from it. // - When decoration are enabled we typically benefit from that distance, but then our resize elements would be conflicting with OS resize elements, so we also narrow. // - Note that we are unable to tell if the platform setup allows hovering with a distance threshold (on Win32, decorated window have such threshold). // We only clip interaction so we overwrite window->ClipRect, cannot call PushClipRect() yet as DrawList is not yet setup. @@ -6283,7 +6302,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (window->WindowClass.ViewportFlagsOverrideClear) viewport_flags &= ~window->WindowClass.ViewportFlagsOverrideClear; - // We also tell the back-end that clearing the platform window won't be necessary, as our window is filling the viewport and we have disabled BgAlpha + // We also tell the backend that clearing the platform window won't be necessary, as our window is filling the viewport and we have disabled BgAlpha if (!(flags & ImGuiWindowFlags_NoBackground)) viewport_flags &= ~ImGuiViewportFlags_NoRendererClear; @@ -7559,7 +7578,7 @@ static void ImGui::ErrorCheckNewFrameSanityChecks() if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation."); - // Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly. + // Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires backend to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly. if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors)) g.IO.ConfigWindowsResizeFromEdges = false; @@ -7585,13 +7604,10 @@ static void ImGui::ErrorCheckNewFrameSanityChecks() IM_ASSERT((g.Viewports[0]->PlatformUserData != NULL || g.Viewports[0]->PlatformHandle != NULL) && "Platform init didn't setup main viewport."); if (g.IO.ConfigDockingTransparentPayload && (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)) IM_ASSERT(g.PlatformIO.Platform_SetWindowAlpha != NULL && "Platform_SetWindowAlpha handler is required to use io.ConfigDockingTransparent!"); -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - IM_ASSERT(g.IO.RenderDrawListsFn == NULL); // Call ImGui::Render() then pass ImGui::GetDrawData() yourself to your render function! -#endif } else { - // Disable feature, our back-ends do not support it + // Disable feature, our backends do not support it g.IO.ConfigFlags &= ~ImGuiConfigFlags_ViewportsEnable; } @@ -7611,7 +7627,7 @@ static void ImGui::ErrorCheckEndFrameSanityChecks() ImGuiContext& g = *GImGui; // Verify that io.KeyXXX fields haven't been tampered with. Key mods should not be modified between NewFrame() and EndFrame() - // One possible reason leading to this assert is that your back-ends update inputs _AFTER_ NewFrame(). + // One possible reason leading to this assert is that your backends update inputs _AFTER_ NewFrame(). const ImGuiKeyModFlags expected_key_mod_flags = GetMergedKeyModFlags(); IM_ASSERT(g.IO.KeyMods == expected_key_mod_flags && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); IM_UNUSED(expected_key_mod_flags); @@ -9299,7 +9315,7 @@ static ImVec2 ImGui::NavCalcPreferredRefPos() const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer]; ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight())); ImRect visible_rect = g.NavWindow->Viewport->GetMainRect(); - return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta. + return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta. } } @@ -9941,7 +9957,7 @@ static void ImGui::NavUpdateWindowing() } // Keyboard: Press and Release ALT to toggle menu layer - // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of back-end clearing releases all keys on ALT-TAB + // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of backend clearing releases all keys on ALT-TAB if (IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Pressed)) g.NavWindowingToggleLayer = true; if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && g.NavWindowingToggleLayer && IsNavInputTest(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released)) @@ -11083,9 +11099,9 @@ void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale) } } -// If the back-end doesn't set MouseLastHoveredViewport or doesn't honor ImGuiViewportFlags_NoInputs, we do a search ourselves. +// If the backend doesn't set MouseLastHoveredViewport or doesn't honor ImGuiViewportFlags_NoInputs, we do a search ourselves. // A) It won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window. -// B) It requires Platform_GetWindowFocus to be implemented by back-end. +// B) It requires Platform_GetWindowFocus to be implemented by backend. static ImGuiViewportP* FindHoveredViewportFromPlatformWindowStack(const ImVec2 mouse_platform_pos) { ImGuiContext& g = *GImGui; @@ -11127,7 +11143,7 @@ static void ImGui::UpdateViewportsNewFrame() } // Create/update main viewport with current platform position. - // FIXME-VIEWPORT: Size is driven by back-end/user code for backward-compatibility but we should aim to make this more consistent. + // FIXME-VIEWPORT: Size is driven by backend/user code for backward-compatibility but we should aim to make this more consistent. ImGuiViewportP* main_viewport = g.Viewports[0]; IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID); IM_ASSERT(main_viewport->Window == NULL); @@ -11241,14 +11257,14 @@ static void ImGui::UpdateViewportsNewFrame() viewport_hovered = g.IO.MouseHoveredViewport ? (ImGuiViewportP*)FindViewportByID(g.IO.MouseHoveredViewport) : NULL; if (viewport_hovered && (viewport_hovered->Flags & ImGuiViewportFlags_NoInputs)) { - // Back-end failed at honoring its contract if it returned a viewport with the _NoInputs flag. + // Backend failed at honoring its contract if it returned a viewport with the _NoInputs flag. IM_ASSERT(0); viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos); } } else { - // If the back-end doesn't know how to honor ImGuiViewportFlags_NoInputs, we do a search ourselves. Note that this search: + // If the backend doesn't know how to honor ImGuiViewportFlags_NoInputs, we do a search ourselves. Note that this search: // A) won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window. // B) uses LastFrameAsRefViewport as a flawed replacement for the last time a window was focused (we could/should fix that by introducing Focus functions in PlatformIO) viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos); @@ -11369,7 +11385,7 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window) ImGuiWindowFlags flags = window->Flags; window->ViewportAllowPlatformMonitorExtend = -1; - // Restore main viewport if multi-viewport is not supported by the back-end + // Restore main viewport if multi-viewport is not supported by the backend ImGuiViewportP* main_viewport = g.Viewports[0]; if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)) { @@ -11535,7 +11551,7 @@ void ImGui::UpdatePlatformWindows() viewport->PlatformWindowCreated = true; } - // Apply Position and Size (from ImGui to Platform/Renderer back-ends) + // Apply Position and Size (from ImGui to Platform/Renderer backends) if ((viewport->LastPlatformPos.x != viewport->Pos.x || viewport->LastPlatformPos.y != viewport->Pos.y) && !viewport->PlatformRequestMove) g.PlatformIO.Platform_SetWindowPos(viewport, viewport->Pos); if ((viewport->LastPlatformSize.x != viewport->Size.x || viewport->LastPlatformSize.y != viewport->Size.y) && !viewport->PlatformRequestResize) @@ -11566,7 +11582,7 @@ void ImGui::UpdatePlatformWindows() g.PlatformIO.Platform_SetWindowAlpha(viewport, viewport->Alpha); viewport->LastAlpha = viewport->Alpha; - // Optional, general purpose call to allow the back-end to perform general book-keeping even if things haven't changed. + // Optional, general purpose call to allow the backend to perform general book-keeping even if things haven't changed. if (g.PlatformIO.Platform_UpdateWindow) g.PlatformIO.Platform_UpdateWindow(viewport); @@ -11589,8 +11605,8 @@ void ImGui::UpdatePlatformWindows() viewport->ClearRequestFlags(); } - // Update our implicit z-order knowledge of platform windows, which is used when the back-end cannot provide io.MouseHoveredViewport. - // When setting Platform_GetWindowFocus, it is expected that the platform back-end can handle calls without crashing if it doesn't have data stored. + // Update our implicit z-order knowledge of platform windows, which is used when the backend cannot provide io.MouseHoveredViewport. + // When setting Platform_GetWindowFocus, it is expected that the platform backend can handle calls without crashing if it doesn't have data stored. // FIXME-VIEWPORT: We should use this information to also set dear imgui-side focus, allowing us to handle os-level alt+tab. if (g.PlatformIO.Platform_GetWindowFocus != NULL) { @@ -11707,7 +11723,7 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL); // Don't clear PlatformWindowCreated for the main viewport, as we initially set that up to true in Initialize() - // The right-er way may be to leave it to the back-end to set this flag all-together, and made the flag public. + // The righter way may be to leave it to the backend to set this flag all-together, and made the flag public. if (viewport->ID != IMGUI_VIEWPORT_DEFAULT_ID) viewport->PlatformWindowCreated = false; } @@ -11721,11 +11737,11 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) void ImGui::DestroyPlatformWindows() { - // We call the destroy window on every viewport (including the main viewport, index 0) to give a chance to the back-end + // We call the destroy window on every viewport (including the main viewport, index 0) to give a chance to the backend // to clear any data they may have stored in e.g. PlatformUserData, RendererUserData. - // It is convenient for the platform back-end code to store something in the main viewport, in order for e.g. the mouse handling + // It is convenient for the platform backend code to store something in the main viewport, in order for e.g. the mouse handling // code to operator a consistent manner. - // It is expected that the back-end can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without + // It is expected that the backend can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without // crashing if it doesn't have data stored. ImGuiContext& g = *GImGui; for (int i = 0; i < g.Viewports.Size; i++) diff --git a/imgui.h b/imgui.h index fd6a219e..b89a11b3 100644 --- a/imgui.h +++ b/imgui.h @@ -1,4 +1,4 @@ -// dear imgui, v1.79 +// dear imgui, v1.80 WIP // (headers) // Help: @@ -60,14 +60,14 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) -#define IMGUI_VERSION "1.79" -#define IMGUI_VERSION_NUM 17900 +#define IMGUI_VERSION "1.80 WIP" +#define IMGUI_VERSION_NUM 17905 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch #define IMGUI_HAS_DOCK 1 // Docking WIP branch // Define attributes of all API symbols declarations (e.g. for DLL under Windows) -// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default bindings files (imgui_impl_xxx.h) +// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default backends files (imgui_impl_xxx.h) // Using dear imgui via a shared library is not recommended, because we don't guarantee backward nor forward ABI compatibility (also function call overhead, as dear imgui is a call-heavy API) #ifndef IMGUI_API #define IMGUI_API @@ -133,7 +133,7 @@ struct ImGuiInputTextCallbackData; // Shared state of InputText() when using cu struct ImGuiListClipper; // Helper to manually clip large list of items struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro struct ImGuiPayload; // User data payload for drag and drop operations -struct ImGuiPlatformIO; // Multi-viewport support: interface for Platform/Renderer back-ends + viewports to render +struct ImGuiPlatformIO; // Multi-viewport support: interface for Platform/Renderer backends + viewports to render struct ImGuiPlatformMonitor; // Multi-viewport support: user-provided bounds for each connected monitor/display. Used when positioning popups and tooltips to avoid them straddling monitors struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use) struct ImGuiStorage; // Helper for key->value storage @@ -141,7 +141,7 @@ struct ImGuiStyle; // Runtime data for styling/colors struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder) struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]") struct ImGuiViewport; // Viewport (generally ~1 per window to output to at the OS level. Need per-platform support to use multiple viewports) -struct ImGuiWindowClass; // Window class (rare/advanced uses: provide hints to the platform back-end via altered viewport flags and parent/child info) +struct ImGuiWindowClass; // Window class (rare/advanced uses: provide hints to the platform backend via altered viewport flags and parent/child info) // Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file) // - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists! @@ -181,7 +181,7 @@ typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: f // Other types #ifndef ImTextureID // ImTextureID [configurable type: override in imconfig.h with '#define ImTextureID xxx'] -typedef void* ImTextureID; // User data for rendering back-end to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details. +typedef void* ImTextureID; // User data for rendering backend to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details. #endif typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string. typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); @@ -260,7 +260,7 @@ namespace ImGui IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame! IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame(). IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all! - IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can get call GetDrawData() to obtain it and run your rendering function (up to v1.60, this used to call io.RenderDrawListsFn(). Nowadays, we allow and prefer calling your render function yourself.) + IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData(). IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render. // Demo, Debug, Information @@ -682,7 +682,7 @@ namespace ImGui IMGUI_API void DockSpace(ImGuiID id, const ImVec2& size = ImVec2(0, 0), ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL); IMGUI_API ImGuiID DockSpaceOverViewport(ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL); IMGUI_API void SetNextWindowDockID(ImGuiID dock_id, ImGuiCond cond = 0); // set next window dock id (FIXME-DOCK) - IMGUI_API void SetNextWindowClass(const ImGuiWindowClass* window_class); // set next window class (rare/advanced uses: provide hints to the platform back-end via altered viewport flags and parent/child info) + IMGUI_API void SetNextWindowClass(const ImGuiWindowClass* window_class); // set next window class (rare/advanced uses: provide hints to the platform backend via altered viewport flags and parent/child info) IMGUI_API ImGuiID GetWindowDockID(); IMGUI_API bool IsWindowDocked(); // is current window docked into another window? @@ -763,7 +763,7 @@ namespace ImGui IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); // Inputs Utilities: Keyboard - // - For 'int user_key_index' you can use your own indices/enums according to how your back-end/engine stored them in io.KeysDown[]. + // - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[]. // - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index. IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key] IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. @@ -818,13 +818,13 @@ namespace ImGui // (Optional) Platform/OS interface for multi-viewport support // Read comments around the ImGuiPlatformIO structure for more details. // 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 ImGuiPlatformIO& GetPlatformIO(); // platform/renderer functions, for backend 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 DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from backend 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 backends. + IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // this is a helper for backends. the type platform_handle is decided by the backend (e.g. HWND, MyWindow*, GLFWwindow* etc.) } // namespace ImGui @@ -872,8 +872,7 @@ enum ImGuiWindowFlags_ ImGuiWindowFlags_DockNodeHost = 1 << 29 // Don't use! For internal use by Begin()/NewFrame() // [Obsolete] - //ImGuiWindowFlags_ShowBorders = 1 << 7, // --> Set style.FrameBorderSize=1.0f or style.WindowBorderSize=1.0f to enable borders around items or windows. - //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by back-end (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) + //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by backend (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) }; // Flags for ImGui::InputText() @@ -1125,7 +1124,7 @@ enum ImGuiKey_ ImGuiKey_COUNT }; -// To test io.KeyMods (which is a combination of individual fields io.KeyCtrl, io.KeyShift, io.KeyAlt set by user/back-end) +// To test io.KeyMods (which is a combination of individual fields io.KeyCtrl, io.KeyShift, io.KeyAlt set by user/backend) enum ImGuiKeyModFlags_ { ImGuiKeyModFlags_None = 0, @@ -1137,7 +1136,7 @@ enum ImGuiKeyModFlags_ // Gamepad/Keyboard navigation // Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. -// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Back-end: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame(). +// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Backend: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame(). // Read instructions in imgui.cpp for more details. Download PNG/PSD at http://goo.gl/9LgVZW. enum ImGuiNavInput_ { @@ -1175,39 +1174,39 @@ enum ImGuiConfigFlags_ { ImGuiConfigFlags_None = 0, ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeysDown[]. - ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[]. Back-end also needs to set ImGuiBackendFlags_HasGamepad. - ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth. + ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui backend to fill io.NavInputs[]. Backend also needs to set ImGuiBackendFlags_HasGamepad. + ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth. ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set. - ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the back-end. - ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct back-end to not alter mouse cursor shape and visibility. Use if the back-end cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead. + ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the backend. + ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead. // [BETA] Docking ImGuiConfigFlags_DockingEnable = 1 << 6, // Docking enable flags. // [BETA] Viewports // When using viewports it is recommended that your default value for ImGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable. - ImGuiConfigFlags_ViewportsEnable = 1 << 10, // Viewport enable flags (require both ImGuiBackendFlags_PlatformHasViewports + ImGuiBackendFlags_RendererHasViewports set by the respective back-ends) + ImGuiConfigFlags_ViewportsEnable = 1 << 10, // Viewport enable flags (require both ImGuiBackendFlags_PlatformHasViewports + ImGuiBackendFlags_RendererHasViewports set by the respective backends) ImGuiConfigFlags_DpiEnableScaleViewports= 1 << 14, // [BETA: Don't use] FIXME-DPI: Reposition and resize imgui windows when the DpiScale of a viewport changed (mostly useful for the main viewport hosting other window). Note that resizing the main window itself is up to your application. ImGuiConfigFlags_DpiEnableScaleFonts = 1 << 15, // [BETA: Don't use] FIXME-DPI: Request bitmap-scaled fonts to match DpiScale. This is a very low-quality workaround. The correct way to handle DPI is _currently_ to replace the atlas and/or fonts in the Platform_OnChangedViewport callback, but this is all early work in progress. - // User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core Dear ImGui) + // User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core Dear ImGui) ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware. ImGuiConfigFlags_IsTouchScreen = 1 << 21 // Application is using a touch screen instead of a mouse. }; -// Back-end capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom back-end. +// Backend capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom backend. enum ImGuiBackendFlags_ { ImGuiBackendFlags_None = 0, - ImGuiBackendFlags_HasGamepad = 1 << 0, // Back-end Platform supports gamepad and currently has one connected. - ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Back-end Platform supports honoring GetMouseCursor() value to change the OS cursor shape. - ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Back-end Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set). - ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Back-end Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices. + ImGuiBackendFlags_HasGamepad = 1 << 0, // Backend Platform supports gamepad and currently has one connected. + ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape. + ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set). + ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices. // [BETA] Viewports - ImGuiBackendFlags_PlatformHasViewports = 1 << 10, // Back-end Platform supports multiple viewports. - ImGuiBackendFlags_HasMouseHoveredViewport=1 << 11, // Back-end Platform supports setting io.MouseHoveredViewport to the viewport directly under the mouse _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag and _REGARDLESS_ of whether another viewport is focused and may be capturing the mouse. This information is _NOT EASY_ to provide correctly with most high-level engines! Don't set this without studying how the examples/ back-end handle it! - ImGuiBackendFlags_RendererHasViewports = 1 << 12 // Back-end Renderer supports multiple viewports. + ImGuiBackendFlags_PlatformHasViewports = 1 << 10, // Backend Platform supports multiple viewports. + ImGuiBackendFlags_HasMouseHoveredViewport=1 << 11, // Backend Platform supports setting io.MouseHoveredViewport to the viewport directly under the mouse _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag and _REGARDLESS_ of whether another viewport is focused and may be capturing the mouse. This information is _NOT EASY_ to provide correctly with most high-level engines! Don't set this without studying _carefully_ how the backends handle ImGuiViewportFlags_NoInputs! + ImGuiBackendFlags_RendererHasViewports = 1 << 12 // Backend Renderer supports multiple viewports. }; // Enumeration for PushStyleColor() / PopStyleColor() @@ -1268,7 +1267,6 @@ enum ImGuiCol_ // Obsolete names (will be removed) #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS , ImGuiCol_ModalWindowDarkening = ImGuiCol_ModalWindowDimBg // [renamed in 1.63] - //, ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered// [unused since 1.60+] the close button now uses regular button colors. #endif }; @@ -1306,11 +1304,6 @@ enum ImGuiStyleVar_ ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign ImGuiStyleVar_COUNT - - // Obsolete names (will be removed) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiStyleVar_Count_ = ImGuiStyleVar_COUNT // [renamed in 1.60] -#endif }; // Flags for InvisibleButton() [extended in imgui_internal.h] @@ -1400,7 +1393,7 @@ enum ImGuiMouseButton_ }; // Enumeration for GetMouseCursor() -// User code may request binding to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here +// User code may request backend to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here enum ImGuiMouseCursor_ { ImGuiMouseCursor_None = -1, @@ -1414,11 +1407,6 @@ enum ImGuiMouseCursor_ ImGuiMouseCursor_Hand, // (Unused by Dear ImGui functions. Use for e.g. hyperlinks) ImGuiMouseCursor_NotAllowed, // When hovering something with disallowed interaction. Usually a crossed circle. ImGuiMouseCursor_COUNT - - // Obsolete names (will be removed) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiMouseCursor_Count_ = ImGuiMouseCursor_COUNT // [renamed in 1.60] -#endif }; // Enumeration for ImGui::SetWindow***(), SetNextWindow***(), SetNextItem***() functions @@ -1562,7 +1550,7 @@ struct ImGuiStyle ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly! float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later. bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList). - bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require back-end to render with bilinear filtering. Latched at the beginning of the frame (copied to ImDrawList). + bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering. Latched at the beginning of the frame (copied to ImDrawList). bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList). float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. float CircleSegmentMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. @@ -1585,7 +1573,7 @@ struct ImGuiIO //------------------------------------------------------------------ ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc. - ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by back-end (imgui_impl_xxx files or custom back-end) to communicate features supported by the back-end. + ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by backend (imgui_impl_xxx files or custom backend) to communicate features supported by the backend. ImVec2 DisplaySize; // // Main display size, in pixels. This is for the default viewport. float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds. @@ -1615,10 +1603,10 @@ struct ImGuiIO bool ConfigViewportsNoAutoMerge; // = false; // Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport. bool ConfigViewportsNoTaskBarIcon; // = false // Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it. bool ConfigViewportsNoDecoration; // = true // [BETA] Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size). - bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = , expecting the platform back-end to setup a parent/child relationship between the OS windows (some back-end may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows. + bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = , expecting the platform backend to setup a parent/child relationship between the OS windows (some backend may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows. // Miscellaneous options - bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by back-end implementations. + bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations. bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl (was called io.OptMacOSXBehaviors prior to 1.63) bool ConfigInputTextCursorBlink; // = true // Set to false to disable blinking cursor, for users who consider it distracting. (was called: io.OptCursorBlink prior to 1.63) bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be a per-window ImGuiWindowFlags_ResizeFromAnySide flag) @@ -1627,15 +1615,15 @@ struct ImGuiIO //------------------------------------------------------------------ // Platform Functions - // (the imgui_impl_xxxx back-end files are setting those up for you) + // (the imgui_impl_xxxx backend files are setting those up for you) //------------------------------------------------------------------ - // Optional: Platform/Renderer back-end name (informational only! will be displayed in About Window) + User data for back-end/wrappers to store their own stuff. + // Optional: Platform/Renderer backend name (informational only! will be displayed in About Window) + User data for backend/wrappers to store their own stuff. const char* BackendPlatformName; // = NULL const char* BackendRendererName; // = NULL - void* BackendPlatformUserData; // = NULL // User data for platform back-end - void* BackendRendererUserData; // = NULL // User data for renderer back-end - void* BackendLanguageUserData; // = NULL // User data for non C++ programming language back-end + void* BackendPlatformUserData; // = NULL // User data for platform backend + void* BackendRendererUserData; // = NULL // User data for renderer backend + void* BackendLanguageUserData; // = NULL // User data for non C++ programming language backend // Optional: Access OS clipboard // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) @@ -1643,15 +1631,6 @@ struct ImGuiIO void (*SetClipboardTextFn)(void* user_data, const char* text); void* ClipboardUserData; -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - // [OBSOLETE since 1.60+] Rendering function, will be automatically called in Render(). Please call your rendering function yourself now! - // You can obtain the ImDrawData* by calling ImGui::GetDrawData() after Render(). See example applications if you are unsure of how to implement this. - void (*RenderDrawListsFn)(ImDrawData* data); -#else - // This is only here to keep ImGuiIO the same size/layout, so that IMGUI_DISABLE_OBSOLETE_FUNCTIONS can exceptionally be used outside of imconfig.h. - void* RenderDrawListsFnUnused; -#endif - //------------------------------------------------------------------ // Input - Fill before calling NewFrame() //------------------------------------------------------------------ @@ -1659,7 +1638,7 @@ struct ImGuiIO ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.) bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. - float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all back-ends. + float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all backends. ImGuiID MouseHoveredViewport; // (Optional) When using multiple viewports: viewport the OS mouse cursor is hovering _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag, and _REGARDLESS_ of whether another viewport is focused. Set io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport if you can provide this info. If you don't imgui will infer the value using the rectangles and last focused time of the viewports it knows about (ignoring other OS windows). bool KeyCtrl; // Keyboard modifier pressed: Control bool KeyShift; // Keyboard modifier pressed: Shift @@ -1683,7 +1662,7 @@ struct ImGuiIO bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.). bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.). bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). - bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. + bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving! bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events). @@ -1718,7 +1697,7 @@ struct ImGuiIO float NavInputsDownDurationPrev[ImGuiNavInput_COUNT]; float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui. ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16 - ImVector InputQueueCharacters; // Queue of _characters_ input (obtained by platform back-end). Fill using AddInputCharacter() helper. + ImVector InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper. IMGUI_API ImGuiIO(); }; @@ -1779,13 +1758,13 @@ struct ImGuiSizeCallbackData // Important: the content of this class is still highly WIP and likely to change and be refactored // before we stabilize Docking features. Please be mindful if using this. // Provide hints: -// - To the platform back-end via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.) -// - To the platform back-end for OS level parent/child relationships of viewport. +// - To the platform backend via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.) +// - To the platform backend for OS level parent/child relationships of viewport. // - To the docking system for various options and filtering. struct ImGuiWindowClass { ImGuiID ClassId; // User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others. - ImGuiID ParentViewportId; // Hint for the platform back-end. If non-zero, the platform back-end can create a parent<>child relationship between the platform windows. Not conforming back-ends are free to e.g. parent every viewport to the main viewport or not. + ImGuiID ParentViewportId; // Hint for the platform backend. If non-zero, the platform backend can create a parent<>child relationship between the platform windows. Not conforming backends are free to e.g. parent every viewport to the main viewport or not. ImGuiViewportFlags ViewportFlagsOverrideSet; // Viewport flags to set when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis. ImGuiViewportFlags ViewportFlagsOverrideClear; // Viewport flags to clear when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis. ImGuiDockNodeFlags DockNodeFlagsOverrideSet; // [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!) @@ -1857,14 +1836,6 @@ namespace ImGui static inline void SetScrollHere(float center_ratio=0.5f){ SetScrollHereY(center_ratio); } // OBSOLETED in 1.63 (between Aug 2018 and Sept 2018) static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); } - // OBSOLETED in 1.61 (between Apr 2018 and Aug 2018) - IMGUI_API bool InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags flags = 0); // Use the 'const char* format' version instead of 'decimal_precision'! - IMGUI_API bool InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags flags = 0); - // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018) - static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } - static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } } typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData; @@ -2087,13 +2058,13 @@ struct ImColor // A) Change your GPU render state, // B) render a complex 3D scene inside a UI element without an intermediate texture/render target, etc. // The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) { cmd.UserCallback(parent_list, cmd); } else { RenderTriangles() }' -// If you want to override the signature of ImDrawCallback, you can simply use e.g. '#define ImDrawCallback MyDrawCallback' (in imconfig.h) + update rendering back-end accordingly. +// If you want to override the signature of ImDrawCallback, you can simply use e.g. '#define ImDrawCallback MyDrawCallback' (in imconfig.h) + update rendering backend accordingly. #ifndef ImDrawCallback typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); #endif -// Special Draw callback value to request renderer back-end to reset the graphics/render state. -// The renderer back-end needs to handle this special value, otherwise it will crash trying to call a function at this address. +// Special Draw callback value to request renderer backend to reset the graphics/render state. +// The renderer backend needs to handle this special value, otherwise it will crash trying to call a function at this address. // This is useful for example if you submitted callbacks which you know have altered the render state and you want it to be restored. // It is not done by default because they are many perfectly useful way of altering render state for imgui contents (e.g. changing shader/blending settings before an Image call). #define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1) @@ -2101,7 +2072,7 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c // Typically, 1 command = 1 GPU draw call (unless command is a callback) // - VtxOffset/IdxOffset: When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' is enabled, // those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices. -// Pre-1.71 back-ends will typically ignore the VtxOffset/IdxOffset fields. +// Pre-1.71 backends will typically ignore the VtxOffset/IdxOffset fields. // - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for). struct ImDrawCmd { @@ -2117,7 +2088,7 @@ struct ImDrawCmd }; // Vertex index, default to 16-bit -// To allow large meshes with 16-bit indices: set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset in the renderer back-end (recommended). +// To allow large meshes with 16-bit indices: set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset in the renderer backend (recommended). // To use 32-bit indices: override with '#define ImDrawIdx unsigned int' in imconfig.h. #ifndef ImDrawIdx typedef unsigned short ImDrawIdx; @@ -2183,7 +2154,7 @@ enum ImDrawListFlags_ { ImDrawListFlags_None = 0, ImDrawListFlags_AntiAliasedLines = 1 << 0, // Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines thin enough to be drawn using textures, otherwise *3 the number of triangles) - ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require back-end to render with bilinear filtering. + ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require backend to render with bilinear filtering. ImDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles). ImDrawListFlags_AllowVtxOffset = 1 << 3 // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled. }; @@ -2581,7 +2552,7 @@ struct ImFont // // This feature allows you to seamlessly drag Dear ImGui windows outside of your application viewport. // This is achieved by creating new Platform/OS windows on the fly, and rendering into them. -// Dear ImGui manages the viewport structures, and the back-end create and maintain one Platform/OS window for each of those viewports. +// Dear ImGui manages the viewport structures, and the backend create and maintain one Platform/OS window for each of those viewports. // // See Glossary https://github.com/ocornut/imgui/wiki/Glossary for details about some of the terminology. // See Thread https://github.com/ocornut/imgui/issues/1542 for gifs, news and questions about this evolving feature. @@ -2591,18 +2562,18 @@ struct ImFont // - So e.g. ImGui::SetNextWindowPos(ImVec2(0,0)) will position a window relative to your primary monitor! // - If you want to position windows relative to your main application viewport, use ImGui::GetMainViewport()->Pos as a base position. // -// Steps to use multi-viewports in your application, when using a default back-end from the examples/ folder: +// Steps to use multi-viewports in your application, when using a default backend 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. +// - Backend: The backend 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: 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: +// Steps to use multi-viewports in your application, when using a custom backend: // - Important: THIS IS NOT EASY TO DO and comes with many subtleties not described here! // It's also an experimental feature, so some of the requirements may evolve. -// Consider using default back-ends if you can. Either way, carefully follow and refer to examples/ back-ends for details. +// Consider using default backends if you can. Either way, carefully follow and refer to examples/ backends for details. // - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. -// - Back-end: Hook ImGuiPlatformIO's Platform_* and Renderer_* callbacks (see below). +// - Backend: Hook ImGuiPlatformIO's Platform_* and Renderer_* callbacks (see below). // Set 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports'. // Update ImGuiPlatformIO's Monitors list every frame. // Update MousePos every frame, in absolute coordinates. @@ -2611,7 +2582,7 @@ struct ImFont // - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls. // // About ImGui::RenderPlatformWindowsDefault(): -// - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default back-ends. +// - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default backends. // - 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() @@ -2626,7 +2597,7 @@ struct ImFont struct ImGuiPlatformIO { //------------------------------------------------------------------ - // Input - Back-end interface/functions + Monitor List + // Input - Backend interface/functions + Monitor List //------------------------------------------------------------------ // (Optional) Platform functions (e.g. Win32, GLFW, SDL2) @@ -2639,7 +2610,7 @@ struct ImGuiPlatformIO // The general idea is that NewFrame() we will read the current Platform/OS state, and UpdatePlatformWindows() 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. + // Custom engine backends will often provide both Platform and Renderer interfaces and so may not need to use all functions. // Platform functions are typically called before their Renderer counterpart, apart from Destroy which are called the other way. // Platform function --------------------------------------------------- Called by ----- @@ -2655,11 +2626,11 @@ 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_UpdateWindow)(ImGuiViewport* vp); // . . U . . // (Optional) Called by UpdatePlatformWindows(). Optional hook to allow the platform backend 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(). 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_OnChangedViewport)(ImGuiViewport* vp); // . F . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Called during Begin() every time the viewport we are outputting into changes, so backend 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. int (*Platform_CreateVkSurface)(ImGuiViewport* vp, ImU64 vk_inst, const void* vk_allocators, ImU64* out_vk_surface); // (Optional) For a Vulkan Renderer to call into Platform code (since the surface creation needs to tie them both). @@ -2671,7 +2642,7 @@ struct ImGuiPlatformIO void (*Renderer_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to RenderPlatformWindowsDefault(). // (Optional) Monitor list - // - Updated by: app/back-end. Update every frame to dynamically support changing monitor or DPI configuration. + // - Updated by: app/backend. Update every frame to dynamically support changing monitor or DPI configuration. // - Used by: dear imgui to query DPI info, clamp popups/tooltips within same monitor and not have them straddle monitors. ImVector Monitors; @@ -2696,7 +2667,7 @@ struct ImGuiPlatformMonitor ImGuiPlatformMonitor() { MainPos = MainSize = WorkPos = WorkSize = ImVec2(0, 0); DpiScale = 1.0f; } }; -// Flags stored in ImGuiViewport::Flags, giving indications to the platform back-ends. +// Flags stored in ImGuiViewport::Flags, giving indications to the platform backends. enum ImGuiViewportFlags_ { ImGuiViewportFlags_None = 0, @@ -2712,7 +2683,7 @@ enum ImGuiViewportFlags_ ImGuiViewportFlags_CanHostOtherWindows = 1 << 9 // Main viewport: can host multiple imgui windows (secondary viewports are associated to a single window). }; -// The viewports created and managed by Dear ImGui. The role of the platform back-end is to create the platform/OS windows corresponding to each viewport. +// The viewports created and managed by Dear ImGui. The role of the platform backend is to create the platform/OS windows corresponding to each viewport. // - Main Area = entire viewport. // - Work Area = entire viewport minus sections optionally used by menu bars, status bars. Some positioning code will prefer to use this. Window are also trying to stay within this area. struct ImGuiViewport @@ -2725,12 +2696,12 @@ struct ImGuiViewport ImVec2 WorkOffsetMax; // Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). float DpiScale; // 1.0f = 96 DPI = No extra scale. ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame(). - ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows. + ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows. - // Our design separate the Renderer and Platform back-ends to facilitate combining default back-ends with each others. - // When our create your own back-end for a custom engine, it is possible that both Renderer and Platform will be handled + // Our design separate the Renderer and Platform backends to facilitate combining default backends with each others. + // When our create your own backend for a custom engine, it is possible that both Renderer and Platform will be handled // by the same system and you may not need to use all the UserData/Handle fields. - // The library never uses those fields, they are merely storage to facilitate back-end implementation. + // The library never uses those fields, they are merely storage to facilitate backend implementation. void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function. void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function. void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 5384ccd5..5aacd7c3 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 +// dear imgui, v1.80 WIP // (demo code) // Help: @@ -400,7 +400,7 @@ void ImGui::ShowDemoWindow(bool* p_open) { ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int*)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard); ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int*)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad); - ImGui::SameLine(); HelpMarker("Required back-end to feed in gamepad inputs in io.NavInputs[] and set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details."); + ImGui::SameLine(); HelpMarker("Required backend to feed in gamepad inputs in io.NavInputs[] and set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details."); ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int*)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos); ImGui::SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos."); ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", (unsigned int*)&io.ConfigFlags, ImGuiConfigFlags_NoMouse); @@ -417,7 +417,7 @@ void ImGui::ShowDemoWindow(bool* p_open) io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse; } ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int*)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange); - ImGui::SameLine(); HelpMarker("Instruct back-end to not alter mouse cursor shape and visibility."); + ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility."); ImGui::CheckboxFlags("io.ConfigFlags: DockingEnable", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_DockingEnable); ImGui::SameLine(); HelpMarker(io.ConfigDockingWithShift ? "[beta] Use SHIFT to dock window into each others." : "[beta] Drag from title bar to dock windows into each others."); @@ -443,11 +443,11 @@ void ImGui::ShowDemoWindow(bool* p_open) ImGui::Checkbox("io.ConfigViewportsNoAutoMerge", &io.ConfigViewportsNoAutoMerge); ImGui::SameLine(); HelpMarker("Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it."); ImGui::Checkbox("io.ConfigViewportsNoTaskBarIcon", &io.ConfigViewportsNoTaskBarIcon); - ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the task bar icon state right away)."); + ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the task bar icon state right away)."); ImGui::Checkbox("io.ConfigViewportsNoDecoration", &io.ConfigViewportsNoDecoration); - ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the decoration right away)."); + ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the decoration right away)."); ImGui::Checkbox("io.ConfigViewportsNoDefaultParent", &io.ConfigViewportsNoDefaultParent); - ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the parenting right away)."); + ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the parenting right away)."); ImGui::Unindent(); } @@ -466,9 +466,10 @@ void ImGui::ShowDemoWindow(bool* p_open) if (ImGui::TreeNode("Backend Flags")) { HelpMarker( - "Those flags are set by the back-ends (imgui_impl_xxx files) to specify their capabilities.\n" - "Here we expose then as read-only fields to avoid breaking interactions with your back-end."); - // Make a local copy to avoid modifying actual back-end flags. + "Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n" + "Here we expose then as read-only fields to avoid breaking interactions with your backend."); + + // Make a local copy to avoid modifying actual backend flags. ImGuiBackendFlags backend_flags = io.BackendFlags; ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int*)&backend_flags, ImGuiBackendFlags_HasGamepad); ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int*)&backend_flags, ImGuiBackendFlags_HasMouseCursors); @@ -957,8 +958,8 @@ static void ShowDemoWindowWidgets() // Below we are displaying the font texture because it is the only texture we have access to inside the demo! // Remember that ImTextureID is just storage for whatever you want it to be. It is essentially a value that - // will be passed to the rendering back-end via the ImDrawCmd structure. - // If you use one of the default imgui_impl_XXXX.cpp rendering back-end, they all have comments at the top + // will be passed to the rendering backend via the ImDrawCmd structure. + // If you use one of the default imgui_impl_XXXX.cpp rendering backend, they all have comments at the top // of their respective source file to specify what they expect to be stored in ImTextureID, for example: // - The imgui_impl_dx11.cpp renderer expect a 'ID3D11ShaderResourceView*' pointer // - The imgui_impl_opengl3.cpp renderer expect a GLuint OpenGL texture identifier, etc. @@ -4135,7 +4136,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) ImGui::Checkbox("Anti-aliased lines use texture", &style.AntiAliasedLinesUseTex); ImGui::SameLine(); - HelpMarker("Faster lines using texture data. Require back-end to render with bilinear filtering (not point/nearest filtering)."); + HelpMarker("Faster lines using texture data. Require backend to render with bilinear filtering (not point/nearest filtering)."); ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill); ImGui::PushItemWidth(100); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index d98af051..48ee2980 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 +// dear imgui, v1.80 WIP // (drawing and font code) /* diff --git a/imgui_internal.h b/imgui_internal.h index c975092b..5a9e9fc2 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1,4 +1,4 @@ -// dear imgui, v1.79 +// dear imgui, v1.80 WIP // (internal structures/api) // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! @@ -19,16 +19,17 @@ Index of this file: // [SECTION] ImDrawList support // [SECTION] Widgets support: flags, enums, data structures // [SECTION] Columns support -// [SECTION] Settings support // [SECTION] Multi-select support // [SECTION] Docking support // [SECTION] Viewport support +// [SECTION] Settings support +// [SECTION] Generic context hooks // [SECTION] ImGuiContext (main imgui context) // [SECTION] ImGuiWindowTempData, ImGuiWindow // [SECTION] Tab bar, Tab item support // [SECTION] Table support // [SECTION] Internal API -// [SECTION] Test Engine Hooks (imgui_test_engine) +// [SECTION] Test Engine specific hooks (imgui_test_engine) */ @@ -93,6 +94,7 @@ struct ImGuiColorMod; // Stacked color modifier, backup of modifie struct ImGuiColumnData; // Storage data for a single column struct ImGuiColumns; // Storage data for a columns set struct ImGuiContext; // Main Dear ImGui context +struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum struct ImGuiDockContext; // Docking system context struct ImGuiDockRequest; // Docking system dock/undock queued request @@ -1261,6 +1263,23 @@ struct ImGuiSettingsHandler ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); } }; +//----------------------------------------------------------------------------- +// [SECTION] Generic context hooks +//----------------------------------------------------------------------------- + +typedef void (*ImGuiContextHookCallback)(ImGuiContext* ctx, ImGuiContextHook* hook); +enum ImGuiContextHookType { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown }; + +struct ImGuiContextHook +{ + ImGuiContextHookType Type; + ImGuiID Owner; + ImGuiContextHookCallback Callback; + void* UserData; + + ImGuiContextHook() { memset(this, 0, sizeof(*this)); } +}; + //----------------------------------------------------------------------------- // [SECTION] ImGuiContext (main imgui context) //----------------------------------------------------------------------------- @@ -1477,6 +1496,7 @@ struct ImGuiContext ImGuiTextBuffer SettingsIniData; // In memory .ini settings ImVector SettingsHandlers; // List of .ini settings handlers ImChunkStream SettingsWindows; // ImGuiWindow .ini settings entries + ImVector Hooks; // Hooks for extensions (e.g. test engine) // Capture/Logging bool LogEnabled; // Currently capturing @@ -2028,11 +2048,15 @@ namespace ImGui IMGUI_API void UpdateMouseMovingWindowNewFrame(); IMGUI_API void UpdateMouseMovingWindowEndFrame(); + // Generic context hooks + IMGUI_API void AddContextHook(ImGuiContext* context, const ImGuiContextHook* hook); + IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type); + // 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 ShowViewportThumbnails(); + 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 ShowViewportThumbnails(); // Settings IMGUI_API void MarkIniSettingsDirty(); @@ -2319,13 +2343,10 @@ IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned cha IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride); //----------------------------------------------------------------------------- -// [SECTION] Test Engine Hooks (imgui_test_engine) +// [SECTION] Test Engine specific hooks (imgui_test_engine) //----------------------------------------------------------------------------- #ifdef IMGUI_ENABLE_TEST_ENGINE -extern void ImGuiTestEngineHook_Shutdown(ImGuiContext* ctx); -extern void ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx); -extern void ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx); extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id); extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags); extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id); @@ -2344,6 +2365,8 @@ extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const cha #define IMGUI_TEST_ENGINE_ID_INFO2(_ID,_TYPE,_DATA,_DATA2) do { } while (0) #endif +//----------------------------------------------------------------------------- + #if defined(__clang__) #pragma clang diagnostic pop #elif defined(__GNUC__) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 3aed17c1..f6813593 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1,4 +1,4 @@ -// dear imgui, v1.79 +// dear imgui, v1.80 WIP // (widgets code) /* @@ -3370,41 +3370,6 @@ bool ImGui::InputFloat4(const char* label, float v[4], const char* format, ImGui return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags); } -// Prefer using "const char* format" directly, which is more flexible and consistent with other API. -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags flags) -{ - char format[16] = "%f"; - if (decimal_precision >= 0) - ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); - return InputFloat(label, v, step, step_fast, format, flags); -} - -bool ImGui::InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags flags) -{ - char format[16] = "%f"; - if (decimal_precision >= 0) - ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); - return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags); -} - -bool ImGui::InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags flags) -{ - char format[16] = "%f"; - if (decimal_precision >= 0) - ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); - return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags); -} - -bool ImGui::InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags flags) -{ - char format[16] = "%f"; - if (decimal_precision >= 0) - ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision); - return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags); -} -#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS - bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags flags) { // Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes. @@ -4046,7 +4011,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ if (state->SelectedAllMouseLock && !io.MouseDown[0]) state->SelectedAllMouseLock = false; - // It is ill-defined whether the back-end needs to send a \t character when pressing the TAB keys. + // It is ill-defined whether the backend needs to send a \t character when pressing the TAB keys. // Win32 and GLFW naturally do it but not SDL. const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper); if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressedMap(ImGuiKey_Tab) && !ignore_char_inputs && !io.KeyShift && !is_readonly)