ona/src/main.zig

38 lines
953 B
Zig
Raw Normal View History

2022-09-22 23:03:25 +02:00
const ext = @cImport({
2022-08-10 15:52:16 +02:00
@cInclude("SDL2/SDL.h");
});
const io = @import("./io.zig");
const stack = @import("./stack.zig");
2022-08-10 15:52:16 +02:00
const std = @import("std");
2022-09-25 00:09:02 +02:00
const sys = @import("./sys.zig");
///
/// Entry point.
///
2022-08-10 15:52:16 +02:00
pub fn main() anyerror!void {
return sys.runGraphics(anyerror, run);
}
fn run(event_loop: *sys.EventLoop, graphics: *sys.GraphicsContext) anyerror!void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
{
const file_access =
try event_loop.open(.readonly, try sys.FileSystem.data.pathJoin(&.{"data", "ona.lua"}));
2022-08-10 15:52:16 +02:00
defer _ = event_loop.close(file_access);
2022-08-10 15:52:16 +02:00
const file_size = try file_access.size(event_loop);
var buffer = try gpa.allocator().alloc(u8, file_size);
if ((try event_loop.readFile(file_access, buffer)) != file_size) return error.ScriptLoadError;
event_loop.log(buffer);
}
while (graphics.poll()) |_| {
graphics.present();
2022-08-10 15:52:16 +02:00
}
}