Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
hazeycode committed Jan 28, 2025
1 parent 6c5861b commit 13b8a20
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Zig bindings for SDL libs.

## Getting started
## Getting started (SDL2)

Example `build.zig`:

Expand All @@ -13,17 +13,27 @@ pub fn build(b: *std.Build) !void {
exe.linkLibC();
const zsdl = b.dependency("zsdl", .{});
exe.root_module.addImport("zsdl2", zsdl.module("zsdl2"));
@import("zsdl").link_SDL2(exe);
// Optionally use prebuilt libs instead of relying on system installed SDL...
exe.root_module.addImport("zsdl2_ttf", zsdl.module("zsdl2_ttf"));
@import("zsdl").link_SDL2_ttf(exe);
exe.root_module.addImport("zsdl2_image", zsdl.module("zsdl2_image"));
@imporT("zsdl").link_SDL2_image(exe);
// Optionally use prebuilt libs instead of relying on system installed SDL...
@import("zsdl").prebuilt.addLibraryPathsTo(exe);
if (@import("zsdl").prebuilt.install_SDL2(b, target.result, .bin)) |install_sdl2_step| {
b.getInstallStep().dependOn(install_sdl2_step);
}
if (@import("zsdl").prebuilt.install_SDL2_ttf(b, target.result, .bin)) |install_sdl2_ttf_step| {
b.getInstallStep().dependOn(install_sdl2_ttf_step);
}
if (@import("zsdl").prebuilt.install_SDL2_image(b, target.result, .bin)) |install_sdl2_image_step| {
b.getInstallStep().dependOn(install_sdl2_image_step);
}
}
```

Expand All @@ -39,6 +49,11 @@ NOTE: If you want to use our prebuilt libraries also add the following to your `
.hash = "1220ade6b84d06d73bf83cef22c73ec4abc21a6d50b9f48875f348b7942c80dde11b",
.lazy = true,
},
.@"sdl2-prebuilt-x86_64-linux-gnu" = .{
.url = "https://github.com/zig-gamedev/sdl2-prebuilt-x86_64-linux-gnu/archive/2eccc574ad909b0d00b694b10c217a95145c47af.tar.gz",
.hash = "12200ecb91c0596d0356ff39d573af83abcd44fecb27943589f11c2cd172763fea39",
.lazy = true,
},
```

Now in your code you may import and use `zsdl2`:
Expand All @@ -64,3 +79,6 @@ pub fn main() !void {
...
}
```

## Getting started (SDL3)
TODO

0 comments on commit 13b8a20

Please sign in to comment.