1
3
Fork
You've already forked zbgfx
1
When zig meets bgfx.
  • C 61.6%
  • C++ 34.7%
  • Zig 2.6%
  • Shell 1%
2026年05月11日 20:24:57 +02:00
.github/workflows Upgrade BGFX. ( #5 ) 2026年03月28日 20:10:07 +01:00
examples Add shared option. 2026年04月30日 21:54:23 +02:00
includes Initial commit. 2024年04月11日 15:17:59 +02:00
libs Upgrade BGFX. ( #5 ) 2026年03月28日 20:10:07 +01:00
shaders BREAKING: Upgrade BGFX ( #2 ) 2026年03月09日 20:41:35 +01:00
src BREAKING: Upgrade to zig 0.16.0 ( #7 ) 2026年04月19日 16:59:46 +02:00
.gitattributes Remove LFS content ( #15 ) 2025年04月02日 16:27:13 +02:00
.gitignore BREAKING: Upgrade to zig 0.16.0 ( #7 ) 2026年04月19日 16:59:46 +02:00
.gitmodules Update zig-gamedev libs. ( #6 ) 2024年11月27日 16:58:59 +01:00
AUTHORS.md Upgrade BGFX ( #3 ) 2024年08月23日 20:55:14 +02:00
build.zig Add shared option. 2026年04月30日 21:54:23 +02:00
build.zig.zon Add shared option. 2026年04月30日 21:54:23 +02:00
LICENSE Initial commit. 2024年04月11日 15:17:59 +02:00
README.md Add link to bgfx_shader_analyzer. 2026年05月11日 20:24:57 +02:00

ZBgfx

GitHub Actions

When zig meets bgfx.

Features

  • Zig api.
  • Compile as standard zig library.
  • shaderc as build artifact.
  • Shader compile from runtime via shaderc as child process.
  • Shader compile in build.zig and embed as zig module.
  • Binding for DebugDraw API
  • imgui render backend. Use build option imgui_include to enable. ex. for zgui: .imgui_include = zgui.path("libs").getPath(b),
  • Zig based allocator.

Important

  • This is only zig binding. For BGFX stuff goto bgfx.
  • Github repository is only mirror. Development continues here

Warning

  • shaderc need some time to compile.

License

Folders libs, shaders is copy&paste from bgfx for more sell-contained experience and is licensed by LICENSEE

Zig binding is licensed by WTFPL

Zig version

Minimal is 0.16.0. But you know try your version and believe.

Bgfx version

Useful tools

Getting started

Copy zbgfx to a subdirectory of your project and then add the following to your build.zig.zon .dependencies:

.zbgfx=.{.path="path/to/zbgfx"},

or use zig fetch --save ... way.

Then in your build.zig add:

constzbgfx=@import("zbgfx");pubfnbuild(b:*std.Build)void{constexe=b.addExecutable(.{...});constzbgfx_dep=b.dependency("zbgfx",.{});exe.root_module.addImport("zbgfx",zbgfx_dep.module("zbgfx"));exe.linkLibrary(zbgfx.artifact("bgfx"));_=tryzbgfx.build_step.installShaderc(b,zbgfx_dep);}

Usage

See examples for binding usage and bgfx for bgfx stuff.

Build options

Build option Default Description
shared false Build as shared library.
imgui_include null Path to ImGui includes (need for imgui bgfx backend)
multithread true Compile with BGFX_CONFIG_MULTITHREADED
with_shaderc true Compile with shaderc

Examples

Run this for build all examples:

cd examples
zig build

Minimal GLFW

Minimal setup with GLFW for window and input.

examples/zig-out/bin/minimal-glfw
Key Description
v Vsync on/off
d Debug on/off

Shader embed

Basic usage of shaders compiled in build and embed to zig module.

examples/zig-out/bin/shader-embed
Key Description
v Vsync on/off
d Debug on/off

Shader runtime

Basic usage of shader compile in runtime. Try edit shaders in zig-out/bin/shaders and hit r to recompile.

examples/zig-out/bin/shader-runtime
Key Description
v Vsync on/off
d Debug on/off
r Recompile shaders form file

ZGui

Minimal setup for zgui/ImGui.

examples/zig-out/bin/zgui
Key Description
v Vsync on/off
d Debug on/off

debugdraw

DebugDraw api usage example.

examples/zig-out/bin/debugdraw
Key Description
v Vsync on/off
d Debug on/off