easy comptime hooks
This commit is contained in:
@@ -12,6 +12,8 @@ const Window = @import("Window.zig");
|
||||
const im = @import("cimgui");
|
||||
pub usingnamespace im;
|
||||
|
||||
pub const Options = struct {};
|
||||
|
||||
pub fn loader_wrapper(procname: [*c]const u8, _: ?*anyopaque) callconv(.C) vk.PfnVoidFunction {
|
||||
return au.glfwGetInstanceProcAddress(au.I.handle, procname);
|
||||
}
|
||||
@@ -75,34 +77,30 @@ pub fn init() !void {
|
||||
if (!im.impl.ImGui_ImplVulkan_CreateFontsTexture()) {
|
||||
return error.igVulkanFontTextureFailed;
|
||||
}
|
||||
|
||||
try Render.add_present_callback(present);
|
||||
errdefer Render.remove_present_callback(present);
|
||||
}
|
||||
|
||||
pub fn frame() void {
|
||||
pub fn nu_frame() !void {
|
||||
im.impl.ImGui_ImplGlfw_NewFrame();
|
||||
im.impl.ImGui_ImplVulkan_NewFrame();
|
||||
im.igNewFrame();
|
||||
|
||||
im.igShowDemoWindow(null);
|
||||
try nu.invoke_hook("nu_imgui_frame", .{});
|
||||
|
||||
im.igEndFrame();
|
||||
im.igRender();
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
Render.remove_present_callback(present);
|
||||
im.impl.ImGui_ImplVulkan_Shutdown();
|
||||
au.D.destroyDescriptorPool(descriptor_pool, null);
|
||||
im.impl.ImGui_ImplGlfw_Shutdown();
|
||||
im.igDestroyContext(ctx);
|
||||
}
|
||||
|
||||
pub fn present(cmd: au.CommandBufferProxy) void {
|
||||
pub fn nu_render_present(cmd: au.CommandBufferProxy) void {
|
||||
im.impl.ImGui_ImplVulkan_RenderDrawData(
|
||||
@ptrCast(im.igGetDrawData()),
|
||||
@ptrFromInt(@intFromEnum(cmd.handle)),
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
im.impl.ImGui_ImplVulkan_Shutdown();
|
||||
au.D.destroyDescriptorPool(descriptor_pool, null);
|
||||
im.impl.ImGui_ImplGlfw_Shutdown();
|
||||
im.igDestroyContext(ctx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user