Libraries - Getting Started - Sample applications - Others using zig-gamedev
We build game development ecosystem for Zig programming language, every day since July 2021. Please consider supporting the project. We create:
- Cross-platform and composable libraries
- Cross-platform sample applications
- DirectX 12 sample applications
- Very modular "toolbox of libraries", user can use only the components she needs
- Just Zig is required to build on Windows, macOS and Linux - no Visual Studio, Build Tools, Windows SDK, gcc, dev packages, system headers/libs, cmake, ninja, etc. is needed
- Building is as easy as
zig build
- Libraries are written from scratch in Zig or provide Ziggified bindings for carefully selected C/C++ libraries
- Uses native wgpu implementation (Dawn) or OpenGL for cross-platform graphics and DirectX 12 for low-level graphics on Windows
Download the latest archive or clone/submodule with Git.
Note: If using Git then you will need Git LFS to be installed.
Our main branch is currenly tracking Zig 0.12.0-dev.2063+804cee3b9 as nominated by the Mach engine project to maintain compatibilty for users of both projects.
zigup is recommended for managing compiler versions. Alternatively, you can download and install manually using the links below:
OS/Arch | Download link |
---|---|
Windows x86_64 | zig-windows-x86_64-0.12.0-dev.2063+804cee3b9.zip |
Linux x86_64 | zig-linux-x86_64-0.12.0-dev.2063+804cee3b9.tar.xz |
macOS x86_64 | zig-macos-x86_64-0.12.0-dev.2063+804cee3b9.tar.xz |
macOS aarch64 | zig-macos-aarch64-0.12.0-dev.2063+804cee3b9.tar.xz |
If you need to use a more recent version of Zig, you can try our unstable branch. But this is not generally recommended.
Build and run the Samples
To get started on Windows/Linux/macOS try out physically based rendering (wgpu) sample:
zig build physically_based_rendering_wgpu-run
To get a list of all available build steps:
zig build -l
Using the Libraries
Option to download packages using Zig Package Manager coming soon!
Copy each library to a subdirectory in your project and add them as local package dependencies. For example:
build.zig.zon
.{
.name = "MyGame",
.version = "0.0.0",
.dependencies = .{
.zglfw = .{ .path = "libs/zglfw" },
.system_sdk = .{ .path = "libs/system-sdk" },
},
.paths = "",
}
build.zig
const zglfw = @import("zglfw");
pub fn build(b: *std.Build) void {
const zglfw_pkg = zglfw.package(b, target, optimize, .{});
...
zglfw_pkg.link(exe);
...
}
Refer to each lib's README.md for further usage intructions.
Library | Latest version | Description |
---|---|---|
zphysics | 0.0.6 | Build package, C API and bindings for Jolt Physics |
zflecs | 0.0.1 | Build package and bindings for flecs ECS |
zopengl | 0.4.3 | OpenGL loader (supports 4.2 Core Profile and ES 2.0 Profile) |
zsdl | 0.0.1 | Bindings for SDL2 and SDL3 (wip) |
zgpu | 0.9.1 | Small helper library built on top of native WebGPU implementation (Dawn) |
zgui | 1.89.6 | Build package and bindings for Dear Imgui (includes ImPlot) |
zaudio | 0.9.4 | Build package and bindings for miniaudio |
zmath | 0.9.6 | SIMD math library for game developers |
zstbi | 0.9.3 | Image reading, writing and resizing with stb libraries |
zmesh | 0.9.0 | Loading, generating, processing and optimizing triangle meshes |
ztracy | 0.10.0 | Support for CPU profiling with Tracy |
zpool | 0.9.0 | Generic pool & handle implementation |
zglfw | 0.8.0 | Build pacakage & bindings for GLFW |
znoise | 0.1.0 | Build pacakge & bindings for FastNoiseLite |
zjobs | 0.1.0 | Generic job queue implementation |
zbullet | 0.2.0 | Build package, C API and bindings for Bullet physics library |
zwin32 | 0.9.0 | Bindings for Win32 API (d3d12, d3d11, xaudio2, directml, wasapi and more) |
zd3d12 | 0.9.0 | Helper library for DirectX 12 |
zxaudio2 | 0.9.0 | Helper library for XAudio2 |
zpix | 0.9.0 | Support for GPU profiling with PIX for Windows |
Some of the sample applications are listed below. More can be found in samples directory.
-
physically based rendering (wgpu): This sample implements physically-based rendering (PBR) and image-based lighting (IBL) to achive realistic looking rendering results.
zig build physically_based_rendering_wgpu-run
-
audio experiments (wgpu): This sample lets the user experiment with audio and observe data that feeds the hardware.
zig build audio_experiments_wgpu-run
-
bullet physics test (wgpu): This sample application demonstrates how to use full 3D physics engine in your Zig programs.
zig build bullet_physics_test_wgpu-run
-
procedural mesh (wgpu): This sample shows how to efficiently draw several procedurally generated meshes.
zig build procedural_mesh_wgpu-run
-
gui test (wgpu): This sample shows how to use our zgui library.
zig build gui_test_wgpu-run
Some of the sample applications are listed below. More can be found in samples directory. They can be built and run on Windows and Linux (Wine + VKD3D-Proton 2.8+):
-
bindless: This sample implements physically based shading and image based lighting to achieve realistic looking rendering results. It uses bindless textures and HLSL 6.6 dynamic resources.
zig build bindless-run
-
rasterization: This sample application shows how GPU rasterizes triangles in slow motion.
zig build rasterization-run
-
simple raytracer: This sample implements basic hybrid renderer. It uses rasterization to resolve primary rays and raytracing (DXR) for shadow rays.
zig build simple_raytracer-run
-
mesh shader test: This sample shows how to use DirectX 12 Mesh Shader.
zig build mesh_shader_test-run
- Tides of Revival - First-person, open-world, fantasy RPG being developed in the open
- Simulations - GPU Accelerated agent-based modeling to visualize and simulate complex systems
- krateroid - 3D strategy game
- blokens - Voxel game
- Delve Framework - Simple game framework for making games with Lua
- jok - A minimal 2D/3D game framework for Zig
- Aftersun - Top-down 2D RPG
- Pixi - Pixel art editor made with Zig