Skip to content

Upgrade to 1.92.1 #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Easy to use, hand-crafted API with default arguments, named parameters and Zig s

## Versions

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

## Getting started
Expand Down
37 changes: 19 additions & 18 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,28 @@ pub fn build(b: *std.Build) void {
"-Wno-availability",
};

const imgui = if (options.shared) blk: {
const lib = b.addSharedLibrary(.{
.name = "imgui",
const imgui = b.addLibrary(.{
.name = "imgui",
.linkage = if (options.shared) .dynamic else .static,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
});
}),
});

imgui.root_module.addCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS", "");

if (options.shared) {
if (target.result.os.tag == .windows) {
lib.root_module.addCMacro("IMGUI_API", "__declspec(dllexport)");
lib.root_module.addCMacro("IMPLOT_API", "__declspec(dllexport)");
lib.root_module.addCMacro("ZGUI_API", "__declspec(dllexport)");
imgui.root_module.addCMacro("IMGUI_API", "__declspec(dllexport)");
imgui.root_module.addCMacro("IMPLOT_API", "__declspec(dllexport)");
imgui.root_module.addCMacro("ZGUI_API", "__declspec(dllexport)");
}

if (target.result.os.tag == .macos) {
lib.linker_allow_shlib_undefined = true;
imgui.linker_allow_shlib_undefined = true;
}

break :blk lib;
} else b.addStaticLibrary(.{
.name = "imgui",
.target = target,
.optimize = optimize,
});
}

b.installArtifact(imgui);

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

const tests = b.addTest(.{
.name = "zgui-tests",
.root_source_file = b.path("src/gui.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/gui.zig"),
.target = target,
.optimize = optimize,
}),
});
b.installArtifact(tests);

Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .zgui,
.fingerprint = 0xe78160e64acbef8,
.version = "0.6.0-dev",
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.0-dev.1177+9abc3232a",
.paths = .{
"build.zig",
"build.zig.zon",
Expand Down
359 changes: 226 additions & 133 deletions libs/imgui/backends/imgui_impl_dx12.cpp

Large diffs are not rendered by default.

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

Expand All @@ -24,21 +25,18 @@
#include <dxgiformat.h> // DXGI_FORMAT
#include <d3d12.h> // D3D12_CPU_DESCRIPTOR_HANDLE

// FIX(zig-gamedev)
extern "C" {

// Initialization data, for ImGui_ImplDX12_Init()
struct ImGui_ImplDX12_InitInfo
{
ID3D12Device* Device;
ID3D12CommandQueue* CommandQueue;
ID3D12CommandQueue* CommandQueue; // Command queue used for queuing texture uploads.
int NumFramesInFlight;
DXGI_FORMAT RTVFormat; // RenderTarget format.
DXGI_FORMAT DSVFormat; // DepthStencilView format.
void* UserData;

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

// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* info);


IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);

// FIX(zig-gamedev)
#if 0
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// Legacy initialization API Obsoleted in 1.91.5
// 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'
// - 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'
// - When we introduced the ImGui_ImplDX12_InitInfo struct we also added a 'ID3D12CommandQueue* CommandQueue' field.
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);
#endif

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

}
// (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.
IMGUI_IMPL_API void ImGui_ImplDX12_UpdateTexture(ImTextureData* tex);

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