When zig meets bgfx.
- C 61.6%
- C++ 34.7%
- Zig 2.6%
- Shell 1%
| .github/workflows | Upgrade BGFX. ( #5 ) | |
| examples |
Add shared option.
|
|
| includes | Initial commit. | |
| libs | Upgrade BGFX. ( #5 ) | |
| shaders | BREAKING: Upgrade BGFX ( #2 ) | |
| src | BREAKING: Upgrade to zig 0.16.0 ( #7 ) | |
| .gitattributes | Remove LFS content ( #15 ) | |
| .gitignore | BREAKING: Upgrade to zig 0.16.0 ( #7 ) | |
| .gitmodules | Update zig-gamedev libs. ( #6 ) | |
| AUTHORS.md | Upgrade BGFX ( #3 ) | |
| build.zig |
Add shared option.
|
|
| build.zig.zon |
Add shared option.
|
|
| LICENSE | Initial commit. | |
| README.md |
Add link to bgfx_shader_analyzer.
|
|
ZBgfx
Features
- Zig api.
- Compile as standard zig library.
shadercas build artifact.- Shader compile from runtime via
shadercas child process. - Shader compile in
build.zigand embed as zig module. - Binding for DebugDraw API
imguirender backend. Use build optionimgui_includeto enable. ex. for zgui:.imgui_include = zgui.path("libs").getPath(b),- Zig based allocator.
Important
Warning
shadercneed 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
- bgfx_shader_analyzer - LSP for bgfx shaders.
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 |