49 lines
1.2 KiB
Zig
49 lines
1.2 KiB
Zig
const std = @import("std");
|
|
const dvui = @import("dvui");
|
|
const hncore = @import("hncore");
|
|
|
|
const App = @import("./App.zig").App;
|
|
|
|
pub fn main() !void {
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
defer if (gpa.deinit() == .leak) {
|
|
@panic("memory leak detected");
|
|
};
|
|
|
|
var backend = try dvui.backend.initWindow(.{
|
|
.allocator = gpa.allocator(),
|
|
.size = .{ .w = 800, .h = 600, },
|
|
.min_size = .{ .w = 250, .h = 350, },
|
|
.vsync = true,
|
|
.title = "Heaven's Net",
|
|
});
|
|
defer backend.deinit();
|
|
|
|
var win = try dvui.Window.init(@src(), gpa.allocator(), backend.backend(), .{});
|
|
defer win.deinit();
|
|
|
|
var app = try App.init(gpa.allocator());
|
|
while (true) {
|
|
try win.begin(
|
|
win.beginWait(backend.hasEvent()),
|
|
);
|
|
|
|
const quit = try backend.addAllEvents(&win);
|
|
if (quit) {
|
|
break;
|
|
}
|
|
|
|
try app.gui();
|
|
|
|
const end_micros = try win.end(.{});
|
|
|
|
backend.setCursor(win.cursorRequested());
|
|
backend.textInputRect(win.textInputRequested());
|
|
backend.renderPresent();
|
|
|
|
backend.waitEventTimeout(
|
|
win.waitTime(end_micros, null),
|
|
);
|
|
}
|
|
}
|