Skip to content

Commit 3c2a845

Browse files
committed
- Upgrade to 1.92.1
- Add TextureRef and update related APIs - Set IMGUI_DISABLE_OBSOLETE_FUNCTIONS and remove usage of deprecated functions - Fixup deprecated API usages (callconv, alignment)
1 parent b2f29f1 commit 3c2a845

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+11692
-7250
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Easy to use, hand-crafted API with default arguments, named parameters and Zig s
1616

1717
## Versions
1818

19-
* [ImGui](https://github.com/ocornut/imgui/tree/v1.91.8-docking) `1.91.8-docking`
19+
* [ImGui](https://github.com/ocornut/imgui/tree/v1.91.8-docking) `1.92.1-docking`
2020
* [ImGui test engine](https://github.com/ocornut/imgui_test_engine/tree/v1.91.8) `1.91.8`
2121
* [ImPlot](https://github.com/epezent/implot) `O.17`
22-
* [ImGuizmo](https://github.com/CedricGuillemet/ImGuizmo) `1.89 WIP`
22+
* [ImGuizmo](https://github.com/CedricGuillemet/ImGuizmo) `1.91.3 WIP`
2323
* [ImGuiNodeEditor](https://github.com/thedmd/imgui-node-editor/tree/v0.9.3) `O.9.3`
2424

2525
## Getting started

build.zig

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,28 @@ pub fn build(b: *std.Build) void {
9191
"-Wno-availability",
9292
};
9393

94-
const imgui = if (options.shared) blk: {
95-
const lib = b.addSharedLibrary(.{
96-
.name = "imgui",
94+
const imgui = b.addLibrary(.{
95+
.name = "imgui",
96+
.linkage = if (options.shared) .dynamic else .static,
97+
.root_module = b.createModule(.{
9798
.target = target,
9899
.optimize = optimize,
99-
});
100+
}),
101+
});
100102

103+
imgui.root_module.addCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS", "");
104+
105+
if (options.shared) {
101106
if (target.result.os.tag == .windows) {
102-
lib.root_module.addCMacro("IMGUI_API", "__declspec(dllexport)");
103-
lib.root_module.addCMacro("IMPLOT_API", "__declspec(dllexport)");
104-
lib.root_module.addCMacro("ZGUI_API", "__declspec(dllexport)");
107+
imgui.root_module.addCMacro("IMGUI_API", "__declspec(dllexport)");
108+
imgui.root_module.addCMacro("IMPLOT_API", "__declspec(dllexport)");
109+
imgui.root_module.addCMacro("ZGUI_API", "__declspec(dllexport)");
105110
}
106111

107112
if (target.result.os.tag == .macos) {
108-
lib.linker_allow_shlib_undefined = true;
113+
imgui.linker_allow_shlib_undefined = true;
109114
}
110-
111-
break :blk lib;
112-
} else b.addStaticLibrary(.{
113-
.name = "imgui",
114-
.target = target,
115-
.optimize = optimize,
116-
});
115+
}
117116

118117
b.installArtifact(imgui);
119118

@@ -397,9 +396,11 @@ pub fn build(b: *std.Build) void {
397396

398397
const tests = b.addTest(.{
399398
.name = "zgui-tests",
400-
.root_source_file = b.path("src/gui.zig"),
401-
.target = target,
402-
.optimize = optimize,
399+
.root_module = b.createModule(.{
400+
.root_source_file = b.path("src/gui.zig"),
401+
.target = target,
402+
.optimize = optimize,
403+
}),
403404
});
404405
b.installArtifact(tests);
405406

libs/imgui/backends/imgui_impl_dx12.cpp

Lines changed: 226 additions & 133 deletions
Large diffs are not rendered by default.

libs/imgui/backends/imgui_impl_dx12.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
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 ImTextureID!
5+
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
66
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
7+
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
78
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
89
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
910

@@ -24,21 +25,18 @@
2425
#include <dxgiformat.h> // DXGI_FORMAT
2526
#include <d3d12.h> // D3D12_CPU_DESCRIPTOR_HANDLE
2627

27-
// FIX(zig-gamedev)
28-
extern "C" {
29-
3028
// Initialization data, for ImGui_ImplDX12_Init()
3129
struct ImGui_ImplDX12_InitInfo
3230
{
3331
ID3D12Device* Device;
34-
ID3D12CommandQueue* CommandQueue;
32+
ID3D12CommandQueue* CommandQueue; // Command queue used for queuing texture uploads.
3533
int NumFramesInFlight;
3634
DXGI_FORMAT RTVFormat; // RenderTarget format.
3735
DXGI_FORMAT DSVFormat; // DepthStencilView format.
3836
void* UserData;
3937

4038
// Allocating SRV descriptors for textures is up to the application, so we provide callbacks.
41-
// (current version of the backend will only allocate one descriptor, future versions will need to allocate more)
39+
// (current version of the backend will only allocate one descriptor, from 1.92 the backend will need to allocate more)
4240
ID3D12DescriptorHeap* SrvDescriptorHeap;
4341
void (*SrvDescriptorAllocFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_desc_handle);
4442
void (*SrvDescriptorFreeFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE gpu_desc_handle);
@@ -52,24 +50,23 @@ struct ImGui_ImplDX12_InitInfo
5250

5351
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
5452
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* info);
55-
56-
5753
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
5854
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
5955
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
6056

61-
// FIX(zig-gamedev)
62-
#if 0
57+
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
6358
// Legacy initialization API Obsoleted in 1.91.5
64-
// 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, they must be in 'srv_descriptor_heap'
59+
// - 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, they must be in 'srv_descriptor_heap'
60+
// - When we introduced the ImGui_ImplDX12_InitInfo struct we also added a 'ID3D12CommandQueue* CommandQueue' field.
6561
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* srv_descriptor_heap, D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
6662
#endif
6763

6864
// Use if you want to reset your rendering device without losing Dear ImGui state.
6965
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
7066
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
7167

72-
}
68+
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
69+
IMGUI_IMPL_API void ImGui_ImplDX12_UpdateTexture(ImTextureData* tex);
7370

7471
// [BETA] Selected render state data shared with callbacks.
7572
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplDX12_RenderDrawData() call.

0 commit comments

Comments
 (0)