SDL ported to the Zig build system.
// momentum
// why it's here
- Active: last commit today
- Has issues labelled for new contributors
- Health 84/100 with only 82 stars
- 5 releases in the last 90 days
// how to help
// readme
SDL Zig
SDL ported to the Zig build system.
Supports cross compilation and custom platform configuration.
Versioning
See build.zig.zon for the current Zig version, see releases for support for previous Zig versions.
The versions specified in build.zig.zon are split between the package version (before the plus)
and the SDL version (after the plus). For example, version 1.0.0+3.4.4 is package version 1.0.0
with support for SDL 3.4.4.
For SDL2, see the SDL2 branch.
Setup
You can add SDL to your project like this by updating build.zig.zon from the command line:
zig fetch --save <url-of-this-repo>
And then you can add it to your build.zig like this:
const sdl = b.dependency("sdl", .{
.optimize = optimize,
.target = target,
});
exe.root_module.addImport("sdl3", sdl.module("sdl3"));
Finally, you can use SDLโs C API from Zig like this:
const std = @import("std");
const sdl = @import("sdl3");
if (!sdl.SDL_Init(sdl.SDL_INIT_VIDEO)) {
std.debug.panic("SDL_Init failed: {s}\n", .{sdl.SDL_GetError()});
}
defer sdl.SDL_Quit();
Example
You can run src/example.zig from the command line: