diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | build.zig | 1 | ||||
m--------- | lib/zeal | 0 | ||||
-rw-r--r-- | src/main.zig | 24 |
4 files changed, 8 insertions, 20 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e0c1036 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/zeal"] + path = lib/zeal + url = https://git.sr.ht/~cnx/zeal diff --git a/build.zig b/build.zig index cd8f246..ada71ad 100644 --- a/build.zig +++ b/build.zig @@ -26,6 +26,7 @@ pub fn build(b: *std.build.Builder) void { exe.addCSourceFile("src/Timer.cpp", &cxxflags); exe.addCSourceFile("src/Textures.cpp", &cxxflags); + exe.addPackage(.{ .name = "zeal", .path = "lib/zeal/src/main.zig" }); exe.linkSystemLibrary("GL"); exe.linkSystemLibrary("GLU"); exe.linkSystemLibrary("SDL"); diff --git a/lib/zeal b/lib/zeal new file mode 160000 +Subproject a0238a32993194b121d2f32845e4a20c667b75f diff --git a/src/main.zig b/src/main.zig index 98e8d84..34e3844 100644 --- a/src/main.zig +++ b/src/main.zig @@ -17,27 +17,11 @@ // along with Black Shades. If not, see <https://www.gnu.org/licenses/>. const legacy = @cImport({ @cInclude("Game.h"); }); -const alc = @cImport({ @cInclude("AL/alc.h"); }); +const al = @import("zeal"); -fn initAl() void { - // FIXME: check for errors - const device = alc.alcOpenDevice(null); - const context = alc.alcCreateContext(device, null); - _ = alc.alcMakeContextCurrent(context); -} - -fn closeAl() void { - const context = alc.alcGetCurrentContext().?; - const device = alc.alcGetContextsDevice(context); - - _ = alc.alcMakeContextCurrent(null); - alc.alcDestroyContext(context); - _ = alc.alcCloseDevice(device); -} - -pub fn main() void { - initAl(); - defer closeAl(); +pub fn main() !void { + try al.init(null); + defer al.deinit() catch unreachable; const game = legacy.makeGame(); legacy.initGl(game); |