2
2
3
3
Zig bindings for SDL libs.
4
4
5
- ## Getting started
5
+ ## Getting started (SDL2)
6
6
7
7
Example ` build.zig ` :
8
8
@@ -13,17 +13,27 @@ pub fn build(b: *std.Build) !void {
13
13
exe.linkLibC();
14
14
15
15
const zsdl = b.dependency("zsdl", .{});
16
+
16
17
exe.root_module.addImport("zsdl2", zsdl.module("zsdl2"));
17
-
18
18
@import("zsdl").link_SDL2(exe);
19
19
20
- // Optionally use prebuilt libs instead of relying on system installed SDL...
20
+ exe.root_module.addImport("zsdl2_ttf", zsdl.module("zsdl2_ttf"));
21
+ @import("zsdl").link_SDL2_ttf(exe);
22
+
23
+ exe.root_module.addImport("zsdl2_image", zsdl.module("zsdl2_image"));
24
+ @imporT("zsdl").link_SDL2_image(exe);
21
25
26
+ // Optionally use prebuilt libs instead of relying on system installed SDL...
22
27
@import("zsdl").prebuilt.addLibraryPathsTo(exe);
23
-
24
28
if (@import("zsdl").prebuilt.install_SDL2(b, target.result, .bin)) |install_sdl2_step| {
25
29
b.getInstallStep().dependOn(install_sdl2_step);
26
30
}
31
+ if (@import("zsdl").prebuilt.install_SDL2_ttf(b, target.result, .bin)) |install_sdl2_ttf_step| {
32
+ b.getInstallStep().dependOn(install_sdl2_ttf_step);
33
+ }
34
+ if (@import("zsdl").prebuilt.install_SDL2_image(b, target.result, .bin)) |install_sdl2_image_step| {
35
+ b.getInstallStep().dependOn(install_sdl2_image_step);
36
+ }
27
37
}
28
38
```
29
39
@@ -39,6 +49,11 @@ NOTE: If you want to use our prebuilt libraries also add the following to your `
39
49
.hash = "1220ade6b84d06d73bf83cef22c73ec4abc21a6d50b9f48875f348b7942c80dde11b",
40
50
.lazy = true,
41
51
},
52
+ .@"sdl2-prebuilt-x86_64-linux-gnu" = .{
53
+ .url = "https://github.com/zig-gamedev/sdl2-prebuilt-x86_64-linux-gnu/archive/2eccc574ad909b0d00b694b10c217a95145c47af.tar.gz",
54
+ .hash = "12200ecb91c0596d0356ff39d573af83abcd44fecb27943589f11c2cd172763fea39",
55
+ .lazy = true,
56
+ },
42
57
```
43
58
44
59
Now in your code you may import and use ` zsdl2 ` :
@@ -64,3 +79,6 @@ pub fn main() !void {
64
79
...
65
80
}
66
81
```
82
+
83
+ ## Getting started (SDL3)
84
+ TODO
0 commit comments