From 9d3190f78d39b56803237d9360623e546339cf84 Mon Sep 17 00:00:00 2001 From: Peter Li Date: Sat, 19 Apr 2025 18:05:16 -0700 Subject: [PATCH] saving --- engine/imgui/src/imgui.zig | 1 + engine/imgui/src/sgpu/backend_impl.zig | 37 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 engine/imgui/src/sgpu/backend_impl.zig diff --git a/engine/imgui/src/imgui.zig b/engine/imgui/src/imgui.zig index 0eb703a..df8f726 100644 --- a/engine/imgui/src/imgui.zig +++ b/engine/imgui/src/imgui.zig @@ -1,6 +1,7 @@ const std = @import("std"); pub const core = @import("core"); pub const cimgui = @import("cimgui"); +const rend = @import("rend"); pub const Module: core.ModuleDescription = .{ .name = "imgui", diff --git a/engine/imgui/src/sgpu/backend_impl.zig b/engine/imgui/src/sgpu/backend_impl.zig new file mode 100644 index 0000000..6d62058 --- /dev/null +++ b/engine/imgui/src/sgpu/backend_impl.zig @@ -0,0 +1,37 @@ +pub const ImguiImpl = struct { + allocator: std.mem.Allocator, + device: *gpu.GPUDevice, + + // renderer plugin + pub fn create(device: *gpu.GPUDevice, allocator: std.mem.Allocator, settings: struct {}) !*@This() { + const self = try allocator.create(@This()); + + self.* = .{ + .allocator = allocator, + .device = device, + }; + _ = settings; + + return self; + } + + pub fn preTick(_: *@This(), _: f64) core.EngineDataEventError!void { + c.ImGui_ImplGlfw_NewFrame(); + c.cImGui_vk_NewFrame(); + c.igNewFrame(); + } + + // renderer plugin + pub fn destroy(p: *anyopaque) void { + const self: *@This() = @ptrCast(@alignCast(p)); + + self.allocator.destroy(self); + } +}; +const c = @import("cimgui").c; +const ig = @import("cimgui").cimgui; +const sdl3 = @import("sdl3"); +const gpu = sdl3.gpu; +const rend = @import("rend"); +const std = @import("std"); +const core = @import("core");