Skip to content

Commit ca94f4d

Browse files
committed
WIP: Upgrade BGFX
1 parent 8711923 commit ca94f4d

1,309 files changed

Lines changed: 260819 additions & 61756 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
project.xcworkspace/
2828
xcuserdata/
2929

30+
# Kevelop
31+
*.kdev4
32+
3033
kcov-output/
3134

3235
imgui.ini

build.zig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const std = @import("std");
22
const builtin = @import("builtin");
33

44
pub const generate_ide = @import("src/tools/generate_ide.zig");
5+
const zbgfx = @import("zbgfx");
56

67
const min_zig_version = std.SemanticVersion.parse("0.15.1") catch @panic("Where is .zigversion?");
78
const cetech1_version = std.SemanticVersion.parse(@embedFile(".version")) catch @panic("Where is .version?");
@@ -172,7 +173,7 @@ pub fn createStudioExe(
172173
return try createKernelExe(
173174
b,
174175
base_bin_name ++ "_studio",
175-
"studio",
176+
"run-studio",
176177
"Run studio",
177178
root_source,
178179
cetech1_kernel,
@@ -246,7 +247,7 @@ pub fn build(b: *std.Build) !void {
246247
.nfd_portal = b.option(bool, "nfd_portal", "build NFD with xdg-desktop-portal instead of GTK. ( Linux, nice for steamdeck;) )") orelse true,
247248

248249
// ZGUI
249-
.with_freetype = b.option(bool, "with_freetype", "build coreui with freetype support") orelse false,
250+
.with_freetype = b.option(bool, "with_freetype", "build coreui with freetype support") orelse true,
250251

251252
// BGFX
252253
.with_shaderc = b.option(bool, "with_shaderc", "build with shaderc support") orelse true,
@@ -343,7 +344,8 @@ pub fn build(b: *std.Build) !void {
343344
);
344345

345346
// ZBGFX
346-
const zbgfx = b.dependency(
347+
// TODO: Remove
348+
const zbgfx_dep = b.dependency(
347349
"zbgfx",
348350
.{
349351
.target = target,
@@ -520,7 +522,8 @@ pub fn build(b: *std.Build) !void {
520522
});
521523

522524
if (options.with_shaderc) {
523-
b.installArtifact(zbgfx.artifact("shaderc"));
525+
const shaderc_install = try zbgfx.build_step.installShaderc(b, zbgfx_dep);
526+
b.getInstallStep().dependOn(shaderc_install);
524527
}
525528

526529
//

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106

107107
// zig-gamedev
108108
.system_sdk = .{
109-
.url = "https://github.com/zig-gamedev/system_sdk/archive/c0dbf11cdc17da5904ea8a17eadc54dee26567ec.tar.gz",
110-
.hash = "system_sdk-0.3.0-dev-alwUNnYaaAJAtIdE2fg4NQfDqEKs7QCXy_qYukAOBfmF",
109+
.url = "https://github.com/zig-gamedev/system_sdk/archive/777e76828f05d5d223df47a4c0de95ae4efde884.tar.gz",
110+
.hash = "system_sdk-0.3.0-dev-alwUNqAaaALJ5VoZImZo3n6prezBnQnrpziun3ZeZwcp",
111111
.lazy = true,
112112
},
113113
.zglfw = .{ .path = "externals/shared/lib/zglfw" },

externals/shared/lib/zbgfx/README.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ When [zig](https://codeberg.org/ziglang/zig) meets [bgfx](https://github.com/bka
99
- [x] Zig api.
1010
- [x] Compile as standard zig library.
1111
- [x] `shaderc` as build artifact.
12-
- [x] Shader compile in `build.zig` to `*.bin.h`.
13-
- [x] Shader compile in `build.zig` and embed as zig module. (this is zig equivalent of `*.bin.h`)
1412
- [x] Shader compile from runtime via `shaderc` as child process.
13+
- [x] Shader compile in `build.zig` and embed as zig module.
1514
- [x] Binding for [DebugDraw API](https://github.com/bkaradzic/bgfx/tree/master/examples/common/debugdraw)
1615
- [x] `imgui` render backend. Use build option `imgui_include` to enable. ex. for
1716
zgui: `.imgui_include = zgui.path("libs").getPath(b),`
1817
- [ ] Zig based allocator.
1918

20-
> [!IMPORTANT]
19+
> [!IMPORTANT]
20+
>
2121
> - This is only zig binding. For BGFX stuff goto [bgfx](https://github.com/bkaradzic/bgfx).
2222
> - Github repository is only mirror. Development continues [here](https://codeberg.org/cyberegoorg/zbgfx)
2323
2424
> [!WARNING]
25+
>
2526
> - `shaderc` need some time to compile.
2627
2728
> [!NOTE]
29+
>
2830
> - If you build shaders/app and see something like `run shaderc (shader.bin.h) stderr`.
2931
This is not "true" error (build success), but only in debug build shader print some stuff to stderr and zig
3032
build catch it.
@@ -42,9 +44,9 @@ Minimal is `0.15.1`. But you know try your version and believe.
4244

4345
## Bgfx version
4446

45-
- [BX](https://github.com/bkaradzic/bx//compare/ce31b1445475ecd4b090471144c4c30a1cbdd871...master)
46-
- [BImg](https://github.com/bkaradzic/bimg/compare/bf10ffbb3df1f9f12ad7a9105e5e96e11a9c5a0c...master)
47-
- [BGFX](https://github.com/bkaradzic/bgfx/compare/56eb016280731451c3b7f18433dc114df035d52a...master)
47+
- [BX](https://github.com/bkaradzic/bx/compare/cb281314e14b2684b4ccbbedda662ce6f842e0d5...master)
48+
- [BImg](https://github.com/bkaradzic/bimg/compare/5a79b67a49f7c23f8480ae1df356c3411f2c329b...master)
49+
- [BGFX](https://github.com/bkaradzic/bgfx/compare/b28febb4a8d29d441c3d1ea95d7cbd3d3e0a840c...master)
4850

4951
## Getting started
5052

@@ -93,39 +95,39 @@ cd examples
9395
zig build
9496
```
9597

96-
### [00-Minimal](examples/00-minimal/)
98+
### [Minimal GLFW](examples/minimal-glfw/)
9799

98100
Minimal setup with GLFW for window and input.
99101

100102
```sh
101-
examples/zig-out/bin/00-minimal
103+
examples/zig-out/bin/minimal-glfw
102104
```
103105

104106
| Key | Description |
105107
|-----|--------------|
106108
| `v` | Vsync on/off |
107109
| `d` | Debug on/off |
108110

109-
### [01-ZGui](examples/01-zgui/)
111+
### [Shader embed](examples/shader-embed/)
110112

111-
Minimal setup for zgui/ImGui.
113+
Basic usage of shaders compiled in build and embed to zig module.
112114

113115
```sh
114-
examples/zig-out/bin/01-zgui
116+
examples/zig-out/bin/shader-embed
115117
```
116118

117119
| Key | Description |
118120
|-----|--------------|
119121
| `v` | Vsync on/off |
120122
| `d` | Debug on/off |
121123

122-
### [02-Runtime shaderc](examples/02-runtime-shaderc/)
124+
### [Shader runtime](examples/shader-runtime/)
123125

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

127129
```sh
128-
examples/zig-out/bin/02-runtime-shaderc
130+
examples/zig-out/bin/shader-runtime
129131
```
130132

131133
| Key | Description |
@@ -134,12 +136,25 @@ examples/zig-out/bin/02-runtime-shaderc
134136
| `d` | Debug on/off |
135137
| `r` | Recompile shaders form file |
136138

137-
### [03-debugdraw](examples/03-debugdraw/)
139+
### [ZGui](examples/zgui/)
140+
141+
Minimal setup for zgui/ImGui.
142+
143+
```sh
144+
examples/zig-out/bin/zgui
145+
```
146+
147+
| Key | Description |
148+
|-----|--------------|
149+
| `v` | Vsync on/off |
150+
| `d` | Debug on/off |
151+
152+
### [debugdraw](examples/debugdraw/)
138153

139154
DebugDraw api usage example.
140155

141156
```sh
142-
examples/zig-out/bin/03-debugdraw
157+
examples/zig-out/bin/debugdraw
143158
```
144159

145160
| Key | Description |

0 commit comments

Comments
 (0)