From da79599ad5201f4eebd3edaabbe4b33498de448e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Wed, 8 Sep 2021 15:46:39 +0700 Subject: Move configuration parsing to Zig The config file is now read from configuration directories instead of pwd. --- src/main.zig | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 34e3844..baca0e0 100644 --- a/src/main.zig +++ b/src/main.zig @@ -16,14 +16,24 @@ // You should have received a copy of the GNU General Public License // along with Black Shades. If not, see . -const legacy = @cImport({ @cInclude("Game.h"); }); -const al = @import("zeal"); +const Loca = @import("loca").Loca; +const allocator = @import("std").heap.c_allocator; +const legacy = @cImport(@cInclude("Game.h")); +const configuration = @import("config.zig"); +const zeal = @import("zeal"); pub fn main() !void { - try al.init(null); - defer al.deinit() catch unreachable; + const loca = try Loca.init(allocator, .{}); + defer loca.deinit(); + const config = try configuration.parse(allocator, loca.user_config); - const game = legacy.makeGame(); + const device = try zeal.Device.init(null); + defer device.deinit() catch unreachable; + const context = try zeal.Context.init(device, &.{ }); + defer context.deinit() catch unreachable; + try zeal.useContext(context); + + const game = legacy.makeGame(@bitCast(legacy.Config, config)); legacy.initGl(game); legacy.initGame(game); defer legacy.closeGame(game); -- cgit v1.2.3