Skip to content

Commit 4aea400

Browse files
authored
Merge pull request #970 from dragonzkiller/master
Update ImGui to 1.91.1
2 parents ae1cd01 + 2891124 commit 4aea400

File tree

12 files changed

+2113
-533
lines changed

12 files changed

+2113
-533
lines changed

src/Utils.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ bool IsLuaCData(const sol::object& acpObject)
177177

178178
float GetAlignedItemWidth(const int64_t acItemsCount)
179179
{
180-
return (ImGui::GetWindowContentRegionWidth() - static_cast<float>(acItemsCount - 1) * ImGui::GetStyle().ItemSpacing.x) / static_cast<float>(acItemsCount);
180+
return (ImGui::GetContentRegionAvail().x - static_cast<float>(acItemsCount - 1) * ImGui::GetStyle().ItemSpacing.x) /
181+
static_cast<float>(acItemsCount);
181182
}
182183

183184
float GetCenteredOffsetForText(const char* acpText)

src/d3d12/D3D12_Functions.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ bool D3D12::ResetState(const bool acClearDownlevelBackbuffers, const bool acDest
1919
{
2020
for (auto i = 0; i < drawData.CmdListsCount; ++i)
2121
IM_DELETE(drawData.CmdLists[i]);
22-
delete[] drawData.CmdLists;
23-
drawData.CmdLists = nullptr;
2422
drawData.Clear();
2523
}
2624

@@ -497,16 +495,16 @@ void D3D12::PrepareUpdate()
497495

498496
for (auto i = 0; i < drawData.CmdListsCount; ++i)
499497
IM_DELETE(drawData.CmdLists[i]);
500-
delete[] drawData.CmdLists;
501-
drawData.CmdLists = nullptr;
502498
drawData.Clear();
503499

504500
drawData = *ImGui::GetDrawData();
505501

506-
auto** copiedDrawLists = new ImDrawList*[drawData.CmdListsCount];
502+
ImVector<ImDrawList*> copiedDrawLists;
503+
copiedDrawLists.resize(drawData.CmdListsCount);
504+
507505
for (auto i = 0; i < drawData.CmdListsCount; ++i)
508506
copiedDrawLists[i] = drawData.CmdLists[i]->CloneOutput();
509-
drawData.CmdLists = copiedDrawLists;
507+
drawData.CmdLists = std::move(copiedDrawLists);
510508

511509
std::swap(m_imguiDrawDataBuffers[1], m_imguiDrawDataBuffers[2]);
512510
}

src/imgui_impl/dx12.cpp

+591-198
Large diffs are not rendered by default.

src/imgui_impl/dx12.h

+26-19
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,46 @@
22
// This needs to be used along with a Platform Backend (e.g. Win32)
33

44
// Implemented features:
5-
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about
6-
// ImTextureID! [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
5+
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
6+
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
7+
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
78

89
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
9-
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
10-
// This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your
11-
// imconfig.h file.
10+
// See imgui_impl_dx12.cpp file for details.
1211

13-
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
14-
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
15-
// Read online: https://github.com/ocornut/imgui/tree/master/docs
12+
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
13+
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
14+
// Learn about Dear ImGui:
15+
// - FAQ https://dearimgui.com/faq
16+
// - Getting Started https://dearimgui.com/getting-started
17+
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
18+
// - Introduction, links and more at the top of imgui.cpp
1619

1720
#pragma once
18-
#include "imgui.h" // IMGUI_IMPL_API
21+
#include "imgui.h" // IMGUI_IMPL_API
22+
#ifndef IMGUI_DISABLE
23+
#include <dxgiformat.h> // DXGI_FORMAT
1924

2025
struct ID3D12Device;
2126
struct ID3D12DescriptorHeap;
2227
struct ID3D12GraphicsCommandList;
2328
struct D3D12_CPU_DESCRIPTOR_HANDLE;
2429
struct D3D12_GPU_DESCRIPTOR_HANDLE;
2530

31+
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
32+
2633
// cmd_list is the command list that the implementation will use to render imgui draw lists.
2734
// Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate
2835
// render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle.
29-
// font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal
30-
// font texture.
31-
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(
32-
ID3D12Device* apDevice, int aNumFramesInFlight, DXGI_FORMAT aRTVFormat, ID3D12DescriptorHeap* apSRVHeapDesc, D3D12_CPU_DESCRIPTOR_HANDLE aFontSRVDescCPU,
33-
D3D12_GPU_DESCRIPTOR_HANDLE aFontSRVDescGPU);
34-
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
35-
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(ID3D12CommandQueue* apCommandQueue);
36-
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* apDrawData, ID3D12GraphicsCommandList* apCommandLists);
36+
// font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture.
37+
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
38+
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
39+
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
40+
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(ID3D12CommandQueue* apCommandQueue);
41+
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
3742

3843
// Use if you want to reset your rendering device without losing Dear ImGui state.
39-
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
40-
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(ID3D12CommandQueue* apCommandQueue);
44+
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
45+
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(ID3D12CommandQueue* apCommandQueue);
46+
47+
#endif // #ifndef IMGUI_DISABLE

src/imgui_impl/imgui_user_config.h

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// global declaration "Enable ImGui Assertions"
44
extern bool g_ImGuiAssertionsEnabled;
55

6+
#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
7+
68
// runtime assertions which can be enabled/disabled inside CET options
79
void ImGuiAssert(wchar_t const* acpMessage, wchar_t const* acpFile, unsigned aLine);
810

0 commit comments

Comments
 (0)