const ext = @cImport({ @cInclude("SDL2/SDL.h"); }); const io = @import("./io.zig"); const stack = @import("./stack.zig"); const std = @import("std"); const sys = @import("./sys.zig"); /// /// Entry point. /// pub fn main() anyerror!void { return sys.runGraphics(anyerror, run); } test { _ = @import("./mem.zig"); } fn run(event_loop: *sys.EventLoop, graphics: *sys.GraphicsContext) anyerror!void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); { const file_access = try event_loop.open(.readonly, try sys.FileSystem.data.joinedPath(&.{"data", "ona.lua"})); defer _ = event_loop.close(file_access); const file_size = try file_access.size(event_loop); const allocator = gpa.allocator(); const buffer = try allocator.alloc(u8, file_size); defer allocator.free(buffer); if ((try event_loop.readFile(file_access, buffer)) != file_size) return error.ScriptLoadFailure; event_loop.log(buffer); } while (graphics.poll()) |_| { graphics.present(); } }