From 444f6f5bea3c581649c6d5e059df63781cc17f3f Mon Sep 17 00:00:00 2001 From: Tony Bark Date: Thu, 9 May 2024 10:45:36 -0400 Subject: [PATCH] Defer unloading of textures and images in group - Added Clap to the library for future passing of CLI arguments --- build.zig | 9 +++++++++ build.zig.zon | 6 +++++- src/main.zig | 14 +++++++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/build.zig b/build.zig index c1992aa..ee649f0 100644 --- a/build.zig +++ b/build.zig @@ -45,6 +45,15 @@ pub fn build(b: *std.Build) void { // exe.root_module.addImport("raylib-gui", raylib_gui); exe.root_module.addImport("rlgl", rlgl); + const clap_dep = b.dependency("clap", .{ + .target = target, + .optimize = optimize, + }); + + const clap = clap_dep.module("clap"); // main clap module + + exe.root_module.addImport("clap", clap); + // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default // step when running `zig build`). diff --git a/build.zig.zon b/build.zig.zon index ed1dd74..0c1a351 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -7,7 +7,7 @@ // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. - .minimum_zig_version = "0.12.0", + .minimum_zig_version = "0.11.0", // This field is optional. // Each dependency must either provide a `url` and `hash`, or a `path`. @@ -19,6 +19,10 @@ .url = "https://github.com/tonytins/raylib-zig/archive/refs/tags/v5.1.103-dev.tar.gz", .hash = "1220f48ef45b22a393da16f3210b61b87ad9b65d215d02c51189861a57a1b4290059", }, + .clap = .{ + .url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.8.0.tar.gz", + .hash = "1220949d4e88864579067b6d4cdad6476c6176f27e782782c2c39b7f2c4817a10efb", + }, }, .paths = .{ // This makes *all* files, recursively, included in this package. It is generally diff --git a/src/main.zig b/src/main.zig index 86c07af..1321505 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2,6 +2,7 @@ const std = @import("std"); const rl = @import("raylib"); const world = @import("world.zig"); const nso = @import("niotso.zig"); +const clap = @import("clap"); const dbg = std.debug; @@ -104,11 +105,14 @@ pub fn main() anyerror!void { const chair2_rect = rl.Rectangle.init(0, 0, @as(f32, @floatFromInt(-chair2.width)), @as(f32, @floatFromInt(chair2.height))); const city = rl.loadImage("resources/cities/city_0100/elevation.png"); // const city_texture = rl.Texture.init("resources/cities/city_0100/vertexcolor.png"); - defer rl.unloadTexture(splash); - defer rl.unloadTexture(logo); - defer rl.unloadTexture(chair1); - defer rl.unloadTexture(chair2); - defer rl.unloadImage(city); + // TODO: figure out a better way to unload all images and textures. + defer { + rl.unloadTexture(splash); + rl.unloadTexture(logo); + rl.unloadTexture(chair1); + rl.unloadTexture(chair2); + rl.unloadImage(city); + } const mesh = rl.genMeshHeightmap(city, rl.Vector3.init(16, 8, 16)); const model = rl.loadModelFromMesh(mesh);