Home

Awesome

Libraries - Getting Started - Sample applications - Others using zig-gamedev

zig-gamedev project

We build game development ecosystem for Zig programming language, every day since July 2021. Please consider supporting the project. We create:

Vision

Getting Started

Download the latest archive or clone/submodule with Git.

Note: If using Git then you will need Git LFS to be installed.

Get Zig

Our main branch is currenly tracking Zig 0.13.0-dev.351+64ef45eb0.

zigup is recommended for managing compiler versions. Alternatively, you can download and install manually using the links below:

OS/ArchDownload link
Windows x86_64zig-windows-x86_64-0.13.0-dev.351+64ef45eb0.zip
Linux x86_64zig-linux-x86_64-0.13.0-dev.351+64ef45eb0.tar.xz
macOS x86_64zig-macos-x86_64-0.13.0-dev.351+64ef45eb0.tar.xz
macOS aarch64zig-macos-aarch64-0.13.0-dev.351+64ef45eb0.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

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

pub fn build(b: *std.Build) void {
   const exe = b.addExecutable(.{ ... });

   const zglfw = b.dependency("zglfw", .{});
   exe.root_module.addImport("zglfw", zglfw.module("root"));
   exe.linkLibrary(zglfw.artifact("glfw"));
}

Refer to each lib's README.md for further usage intructions.

Option to download packages using Zig Package Manager coming soon!

Libraries

LibraryDescription
zaudioCross-platform audio using miniaudio
zbulletBuild package, C API and bindings for Bullet physics
zd3d12Helper library for DirectX 12
zflecsBuild package and bindings for flecs ECS
zglfwBuild package & bindings for GLFW
zgpuSmall helper library built on top of Dawn native WebGPU implementation
zguiBuild package and bindings for Dear Imgui (includes ImPlot)
zjobsGeneric job queue implementation
zmathSIMD math library for game developers
zmeshLoading, generating, processing and optimizing triangle meshes
znoiseBuild package & bindings for FastNoiseLite
zopenglOpenGL loader (supports 4.2 Core Profile and ES 2.0 Profile)
zopenvrBindings for OpenVR
zphysicsBuild package, C API and bindings for Jolt Physics
zpixSupport for GPU profiling with PIX for Windows
zpoolGeneric pool & handle implementation
zsdlBindings for SDL2 and SDL3
zstbiImage reading, writing and resizing with stb libraries
ztracySupport for CPU profiling with Tracy
zwin32Bindings for Win32 API (d3d12, d3d11, xaudio2, directml, wasapi and more)
zxaudio2Helper library for XAudio2

Sample applications (native wgpu)

Some of the sample applications are listed below. More can be found in samples directory.

  1. physically based rendering (wgpu): This sample implements physically-based rendering (PBR) and image-based lighting (IBL) to achive realistic looking rendering results.<br />zig build physically_based_rendering_wgpu-run

    <a href="samples/physically_based_rendering_wgpu"><img src="samples/physically_based_rendering_wgpu/screenshot0.jpg" alt="physically based rendering (wgpu)" height="200"></a>

  2. audio experiments (wgpu): This sample lets the user experiment with audio and observe data that feeds the hardware.<br />zig build audio_experiments_wgpu-run

    <a href="samples/audio_experiments_wgpu"><img src="samples/audio_experiments_wgpu/screenshot.png" alt="audio experiments (wgpu)" height="200"></a>

  3. bullet physics test (wgpu): This sample application demonstrates how to use full 3D physics engine in your Zig programs.<br />zig build bullet_physics_test_wgpu-run

    <a href="samples/bullet_physics_test_wgpu"><img src="samples/bullet_physics_test_wgpu/screenshot.jpg" alt="bullet physics test (wgpu)" height="200"></a>

  4. procedural mesh (wgpu): This sample shows how to efficiently draw several procedurally generated meshes.<br />zig build procedural_mesh_wgpu-run

    <a href="samples/procedural_mesh_wgpu"><img src="samples/procedural_mesh_wgpu/screenshot.png" alt="procedural mesh (wgpu)" height="200"></a>

  5. gui test (wgpu): This sample shows how to use our zgui library.<br />zig build gui_test_wgpu-run

    <a href="samples/gui_test_wgpu"><img src="samples/gui_test_wgpu/screenshot.png" alt="gui test (wgpu)" height="200"></a>

Sample applications (DirectX 12)

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+):

  1. 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.<br />zig build bindless-run

    <a href="samples/bindless"><img src="samples/bindless/screenshot.png" alt="bindless" height="200"></a>

  2. rasterization: This sample application shows how GPU rasterizes triangles in slow motion.<br />zig build rasterization-run

    <a href="samples/rasterization"><img src="samples/rasterization/screenshot.png" alt="rasterization" height="200"></a>

  3. simple raytracer: This sample implements basic hybrid renderer. It uses rasterization to resolve primary rays and raytracing (DXR) for shadow rays.<br />zig build simple_raytracer-run

    <a href="samples/simple_raytracer"><img src="samples/simple_raytracer/screenshot.png" alt="simple raytracer" height="200"></a>

  4. mesh shader test: This sample shows how to use DirectX 12 Mesh Shader.<br />zig build mesh_shader_test-run

    <a href="samples/mesh_shader_test"><img src="samples/mesh_shader_test/screenshot.png" alt="mesh shader test" height="200"></a>

Others using zig-gamedev