Skip to content

Commit

Permalink
Defer unloading of textures and images in group
Browse files Browse the repository at this point in the history
- Added Clap to the library for future passing of CLI arguments
  • Loading branch information
Tony Bark committed May 9, 2024
1 parent 65f4d35 commit 444f6f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
9 changes: 9 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
6 changes: 5 additions & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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
Expand Down
14 changes: 9 additions & 5 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 444f6f5

Please sign in to comment.