https://github.com/zig-gamedev/zglfw
Zig build package and bindings for GLFW
https://github.com/zig-gamedev/zglfw
bindings gamedev glfw zig
Last synced: 5 days ago
JSON representation
Zig build package and bindings for GLFW
- Host: GitHub
- URL: https://github.com/zig-gamedev/zglfw
- Owner: zig-gamedev
- License: mit
- Created: 2024-11-03T21:42:48.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-04-19T00:21:37.000Z (3 months ago)
- Last Synced: 2025-04-19T10:00:49.100Z (3 months ago)
- Topics: bindings, gamedev, glfw, zig
- Language: C
- Homepage:
- Size: 436 KB
- Stars: 23
- Watchers: 4
- Forks: 22
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [zglfw](https://github.com/zig-gamedev/zglfw)
Zig build package and bindings for [GLFW 3.4](https://github.com/glfw/glfw/releases/tag/3.4)
## Getting started
Example `build.zig`:
```zig
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{ ... });const zglfw = b.dependency("zglfw", .{});
exe.root_module.addImport("zglfw", zglfw.module("root"));if (target.result.os.tag != .emscripten) {
exe.linkLibrary(zglfw.artifact("glfw"));
}
}
```Now in your code you may import and use `zglfw`:
```zig
const glfw = @import("zglfw");pub fn main() !void {
try glfw.init();
defer glfw.terminate();const window = try glfw.createWindow(600, 600, "zig-gamedev: minimal_glfw_gl", null);
defer glfw.destroyWindow(window);// or, using the equivilent, encapsulated, "objecty" API:
const window = try glfw.Window.create(600, 600, "zig-gamedev: minimal_glfw_gl", null);
defer window.destroy();// setup your graphics context here
while (!window.shouldClose()) {
glfw.pollEvents();// render your things here
window.swapBuffers();
}
}
```See [zig-gamedev samples](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples) for more complete usage examples.