misc cleanup
This commit is contained in:
108
src/main.zig
108
src/main.zig
@@ -1,7 +1,11 @@
|
||||
const std = @import("std");
|
||||
const nu = @import("nu.zig");
|
||||
|
||||
const App = @import("App.zig");
|
||||
pub const nu_modules = .{
|
||||
App,
|
||||
// UI,
|
||||
};
|
||||
pub const main = nu.main;
|
||||
|
||||
pub const nu_options: nu.Options = .{
|
||||
.window = .{ .title = "Hello World" },
|
||||
@@ -11,44 +15,72 @@ pub const nu_options: nu.Options = .{
|
||||
},
|
||||
};
|
||||
|
||||
// todo declare or infer module dependencies, topological sort for init order. clean up "init" lines in main.
|
||||
//
|
||||
// problem: where should gpa go? probably some "Engine" structure in nu.zig
|
||||
//
|
||||
// don't necessarily need to declare topological sort - depth-first traversal
|
||||
// of each module's dependencies without repeats would do.
|
||||
//
|
||||
// idea - use a structure like std.Build.Step where the polymorphic part is a
|
||||
// component of the larger structure.
|
||||
pub const UI = struct {
|
||||
const im = nu.ImGui;
|
||||
|
||||
pub const nu_driver = nu.Window;
|
||||
pub const nu_present = nu.Render;
|
||||
pub const nu_modules = .{
|
||||
nu.ImGui,
|
||||
App,
|
||||
pub const depends = .{im};
|
||||
|
||||
var color: @Vector(4, f32) = @splat(1);
|
||||
|
||||
pub fn setup(_: std.mem.Allocator) !void {
|
||||
const io: *nu.ImGui.ImGuiIO = @ptrCast(nu.ImGui.igGetIO());
|
||||
io.ConfigFlags |= nu.ImGui.ImGuiConfigFlags_DockingEnable;
|
||||
}
|
||||
|
||||
pub fn frame() !void {
|
||||
nu.ImGui.igShowMetricsWindow(null);
|
||||
|
||||
{
|
||||
const viewport = im.igGetMainViewport();
|
||||
im.igSetNextWindowPos(viewport.*.WorkPos, 0, .{ .x = 0, .y = 0 });
|
||||
im.igSetNextWindowSize(viewport.*.WorkSize, 0);
|
||||
im.igSetNextWindowViewport(viewport.*.ID);
|
||||
im.igPushStyleVar_Float(im.ImGuiStyleVar_WindowRounding, 0);
|
||||
im.igPushStyleVar_Float(im.ImGuiStyleVar_WindowBorderSize, 0);
|
||||
im.igPushStyleVar_Vec2(im.ImGuiStyleVar_WindowPadding, .{ .x = 0, .y = 0 });
|
||||
defer im.igPopStyleVar(3);
|
||||
|
||||
const window_flags =
|
||||
im.ImGuiWindowFlags_MenuBar |
|
||||
im.ImGuiWindowFlags_NoDocking |
|
||||
im.ImGuiWindowFlags_NoTitleBar |
|
||||
im.ImGuiWindowFlags_NoCollapse |
|
||||
im.ImGuiWindowFlags_NoResize |
|
||||
im.ImGuiWindowFlags_NoMove |
|
||||
im.ImGuiWindowFlags_NoBringToFrontOnFocus |
|
||||
im.ImGuiWindowFlags_NoNavFocus |
|
||||
im.ImGuiWindowFlags_NoBackground;
|
||||
|
||||
const dock_flags =
|
||||
im.ImGuiDockNodeFlags_PassthruCentralNode |
|
||||
im.ImGuiDockNodeFlags_NoDockingOverCentralNode;
|
||||
|
||||
_ = im.igBegin("Main Dockspace", null, window_flags);
|
||||
const id = im.igGetID_Str("maindockspace");
|
||||
_ = im.igDockSpace(id, .{ .x = 0, .y = 0 }, dock_flags, null);
|
||||
im.igEnd();
|
||||
}
|
||||
|
||||
if (nu.ImGui.igBegin("Color", null, nu.ImGui.ImGuiWindowFlags_None)) {
|
||||
if (nu.ImGui.igColorEdit4("color", @ptrCast(&color), nu.ImGui.ImGuiColorEditFlags_AlphaPreviewHalf)) {}
|
||||
}
|
||||
nu.ImGui.igEnd();
|
||||
}
|
||||
};
|
||||
|
||||
pub const main = nu.main;
|
||||
const App = struct {
|
||||
const vk = @import("vk");
|
||||
const au = @import("nu/Render/au.zig");
|
||||
|
||||
// pub fn main() !void {
|
||||
// var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
// defer _ = gpa.detectLeaks();
|
||||
// const alloc = gpa.allocator();
|
||||
//
|
||||
// nu.init(alloc);
|
||||
// defer nu.deinit();
|
||||
//
|
||||
// try nu.Window.init(alloc);
|
||||
// defer nu.Window.deinit();
|
||||
//
|
||||
// try nu.Render.init(alloc);
|
||||
// defer nu.Render.deinit();
|
||||
//
|
||||
// try nu.ImGui.init(alloc);
|
||||
// defer nu.ImGui.deinit();
|
||||
//
|
||||
// try App.init(alloc);
|
||||
// defer App.deinit();
|
||||
//
|
||||
// try nu.run(alloc);
|
||||
// }
|
||||
pub const depends = .{nu.Render};
|
||||
|
||||
// todo timeline semaphore
|
||||
|
||||
pub fn setup(_: std.mem.Allocator) !void {}
|
||||
|
||||
pub fn teardown() void {}
|
||||
|
||||
pub fn frame() !void {}
|
||||
|
||||
pub fn present(_: au.CommandBufferProxy) void {}
|
||||
};
|
||||
|
Reference in New Issue
Block a user