Build BGFX (and shaderc) with Zig

Hi all, this is a small project I have been working on over the Easter weekend, I’m pretty happy with the result so I thought I’d share it here.

It is basically a build.zig + build.zig.zon that allows you to build BGFX library and use it in your Zig project, but also build shaderc and directly build shaders in your build.zig, so you can hook shader compilation into other build steps.

It can also create a single Zig module from a directory with all your shaders, for all enabled BGFX backends, so you can automatically hook all your shaders into your source code.

It comes with examples (working on Windows/Linux/Mac) showing BGFX and shader compilation usage.

It’s been a long time since I wanted to hook shaderc into zig build system, having to just zig build run in a clean repo and having everything automagically fetched/built with no submodules nor external make calls is a joy :smile:

Hope some of you find it useful!

7 Likes