Previously, @Avokadoen and @mattnite ran into issues including the GLFW library in other projects, e.g. https://github.com/Avokadoen/zig_vulkan/issues/17 In #24 we removed the intermediate static library, which solved the issue. The problem is that when the function is invoked in the directory of the project including GLFW, then our code: ``` const lib = b.addStaticLibrary("glfw", "src/main.zig"); ``` Would refer to the project's `src/main.zig` -- not the GLFW library `main.zig`. Although removing the intermediate lib worked around the issue, it created a new one - slower compilation: hexops/mach#31 This fixes the issue by ensuring that the path we pass to `addStaticLibrary` is in fact absolute, not relative. Fixes hexops/mach#31 Signed-off-by: Stephen Gutekanst <stephen@hexops.com> |
||
|---|---|---|
| .. | ||
| .github | ||
| src | ||
| upstream | ||
| .gitattributes | ||
| .gitignore | ||
| build.zig | ||
| LICENSE | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
| update-upstream.sh | ||
mach/glfw - Ziggified GLFW bindings

Ziggified GLFW bindings that Mach engine uses, with 100% API coverage, zero-fuss installation, cross compilation, and more.
The main Mach repository includes this one as a git subtree. This is a separate repo so that anyone can use this library in their own project / engine if they like!
Zero fuss installation, cross compilation, and more
Just as with Mach, you get zero fuss installation & cross compilation using these GLFW bindings. only zig and git are needed to build from any OS and produce binaries for every OS. No system dependencies at all.
See also: platform support table
100% API coverage
These bindings recently achieved 100% API coverage of GLFW v3.3.4. Every function, type, etc. has been wrapped in a ziggified API.
What does a ziggified GLFW API offer?
You could just @cImport GLFW with Zig - the main reasons to use a ziggified wrapper though are because you get:
trueandfalsebooleans instead ofc.GLFW_TRUEandc.GLFW_FALSEintegers- Methods, so you can write e.g.
window.hintinstead ofglfwWindowHint - Generics, so you can just use
window.hintinstead ofglfwWindowHint,glfwWindowHintString, etc. - Enums, so you can write
window.getKey(.escape)instead ofc.glfwGetKey(window, c.GLFW_KEY_ESCAPE) - Slices instead of C pointers and lengths.
packed structto represent bit masks, so you can interact with each bit the same way you'd interact with aboolif you like, instead of remembering the&|^incantation (although you're free to do that too.)
How do I use OpenGL, Vulkan, WebGPU, etc. with this?
You'll need to bring your own library for this. Some are:
- (Vulkan) https://github.com/Snektron/vulkan-zig (also see https://github.com/Avokadoen/zig_vulkan)
- (OpenGL) https://github.com/ziglibs/zgl
Issues
Issues are tracked in the main Mach repository.
Contributing
Contributions are very welcome. Just send a PR to this repository.
We track the latest stable release of GLFW, if you need a newer version we can start a development branch / figure that out - just open an issue.
Once your PR is merged, if you're using Mach engine and wanting the changes there, it will be sync'd to the main repo via git subtree.