clean up hook invocation
This commit is contained in:
@@ -5,32 +5,34 @@ const std = @import("std");
|
||||
const vk = @import("vk");
|
||||
const nu = @import("../nu.zig");
|
||||
const au = @import("Render/au.zig");
|
||||
|
||||
const Render = @import("Render.zig");
|
||||
const Window = @import("Window.zig");
|
||||
|
||||
const im = @import("cimgui");
|
||||
pub usingnamespace im;
|
||||
|
||||
pub fn loader_wrapper(procname: [*c]const u8, _: ?*anyopaque) callconv(.C) vk.PfnVoidFunction {
|
||||
return au.glfwGetInstanceProcAddress(au.I.handle, procname);
|
||||
}
|
||||
|
||||
var ctx: *im.c.ImGuiContext = undefined;
|
||||
var ctx: *im.ImGuiContext = undefined;
|
||||
var descriptor_pool: vk.DescriptorPool = undefined;
|
||||
|
||||
pub fn init() !void {
|
||||
ctx = im.c.igCreateContext(null) orelse {
|
||||
ctx = im.igCreateContext(null) orelse {
|
||||
return error.igCreateContextFailed;
|
||||
};
|
||||
errdefer im.c.igDestroyContext(ctx);
|
||||
errdefer im.igDestroyContext(ctx);
|
||||
|
||||
if (!im.c.ImGui_ImplVulkan_LoadFunctions(loader_wrapper, null)) {
|
||||
if (!im.impl.ImGui_ImplVulkan_LoadFunctions(loader_wrapper, null)) {
|
||||
return error.igVulkanLoadFunctionsFailed;
|
||||
}
|
||||
|
||||
if (!im.c.ImGui_ImplGlfw_InitForVulkan(@ptrCast(Window.handle), true)) {
|
||||
if (!im.impl.ImGui_ImplGlfw_InitForVulkan(@ptrCast(Window.handle), true)) {
|
||||
return error.igGlfwInitFailed;
|
||||
}
|
||||
errdefer im.c.ImGui_ImplGlfw_Shutdown();
|
||||
errdefer im.impl.ImGui_ImplGlfw_Shutdown();
|
||||
|
||||
descriptor_pool = try au.D.createDescriptorPool(&vk.DescriptorPoolCreateInfo{
|
||||
.flags = .{ .free_descriptor_set_bit = true },
|
||||
@@ -43,7 +45,7 @@ pub fn init() !void {
|
||||
}, null);
|
||||
errdefer au.D.destroyDescriptorPool(descriptor_pool, null);
|
||||
|
||||
if (im.c.ImGui_ImplVulkan_Init(@constCast(&im.c.ImGui_ImplVulkan_InitInfo{
|
||||
if (im.impl.ImGui_ImplVulkan_Init(@constCast(&im.impl.ImGui_ImplVulkan_InitInfo{
|
||||
.Instance = @ptrFromInt(@intFromEnum(au.I.handle)),
|
||||
.PhysicalDevice = @ptrFromInt(@intFromEnum(au.device_config.pdev)),
|
||||
.Device = @ptrFromInt(@intFromEnum(au.D.handle)),
|
||||
@@ -68,9 +70,9 @@ pub fn init() !void {
|
||||
})) != true) {
|
||||
return error.igVulkanInitFailed;
|
||||
}
|
||||
errdefer im.c.ImGui_ImplVulkan_Shutdown();
|
||||
errdefer im.impl.ImGui_ImplVulkan_Shutdown();
|
||||
|
||||
if (!im.c.ImGui_ImplVulkan_CreateFontsTexture()) {
|
||||
if (!im.impl.ImGui_ImplVulkan_CreateFontsTexture()) {
|
||||
return error.igVulkanFontTextureFailed;
|
||||
}
|
||||
|
||||
@@ -79,27 +81,27 @@ pub fn init() !void {
|
||||
}
|
||||
|
||||
pub fn frame() void {
|
||||
im.c.ImGui_ImplGlfw_NewFrame();
|
||||
im.c.ImGui_ImplVulkan_NewFrame();
|
||||
im.c.igNewFrame();
|
||||
im.impl.ImGui_ImplGlfw_NewFrame();
|
||||
im.impl.ImGui_ImplVulkan_NewFrame();
|
||||
im.igNewFrame();
|
||||
|
||||
im.c.igShowDemoWindow(null);
|
||||
im.igShowDemoWindow(null);
|
||||
|
||||
im.c.igEndFrame();
|
||||
im.c.igRender();
|
||||
im.igEndFrame();
|
||||
im.igRender();
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
Render.remove_present_callback(present);
|
||||
im.c.ImGui_ImplVulkan_Shutdown();
|
||||
im.impl.ImGui_ImplVulkan_Shutdown();
|
||||
au.D.destroyDescriptorPool(descriptor_pool, null);
|
||||
im.c.ImGui_ImplGlfw_Shutdown();
|
||||
im.c.igDestroyContext(ctx);
|
||||
im.impl.ImGui_ImplGlfw_Shutdown();
|
||||
im.igDestroyContext(ctx);
|
||||
}
|
||||
|
||||
pub fn present(cmd: au.CommandBufferProxy) void {
|
||||
im.c.ImGui_ImplVulkan_RenderDrawData(
|
||||
im.c.igGetDrawData(),
|
||||
im.impl.ImGui_ImplVulkan_RenderDrawData(
|
||||
@ptrCast(im.igGetDrawData()),
|
||||
@ptrFromInt(@intFromEnum(cmd.handle)),
|
||||
null,
|
||||
);
|
||||
|
Reference in New Issue
Block a user