Skip to content

Commit 2a2a2a7

Browse files
committed
Add samples from mono-repo
1 parent 8175dde commit 2a2a2a7

File tree

16 files changed

+1178
-0
lines changed

16 files changed

+1178
-0
lines changed

samples/content/build.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
_ = b.addModule("root", .{
5+
.root_source_file = b.path("root.zig"),
6+
});
7+
}

samples/content/build.zig.zon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.{
2+
.name = "content",
3+
.version = "0.1.0",
4+
.minimum_zig_version = "0.14.0",
5+
.paths = .{
6+
"build.zig",
7+
"build.zig.zon",
8+
},
9+
.dependencies = .{},
10+
}
277 KB
Binary file not shown.
159 KB
Binary file not shown.
428 KB
Loading

samples/content/root.zig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Fonts
3+
//
4+
pub const RobotoMedium_ttf = @embedFile("fonts/Roboto-Medium.ttf");
5+
pub const FiraCodeMedium_ttf = @embedFile("fonts/FiraCode-Medium.ttf");
6+
7+
//
8+
// Images
9+
//
10+
pub const genart_0025_5_png = @embedFile("images/genart_0025_5.png");

samples/gui_test_wgpu/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## gui test (wgpu)
2+
3+
This test application uses `zgui` - Zig bindings for `dear imgui` library.
4+
5+
`zgui` features easy to use, hand-crafted API with default arguments, named parameters and Zig style text formatting.
6+
7+
![image](screenshot.png)

samples/gui_test_wgpu/build.zig

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const std = @import("std");
2+
3+
const demo_name = "gui_test_wgpu";
4+
const content_dir = demo_name ++ "_content/";
5+
6+
pub fn build(b: *std.Build) void {
7+
const optimize = b.standardOptimizeOption(.{});
8+
const target = b.standardTargetOptions(.{});
9+
10+
const src_path = b.pathJoin(&.{"src"});
11+
const exe = b.addExecutable(.{
12+
.name = demo_name,
13+
.root_source_file = b.path(b.pathJoin(&.{ src_path, demo_name ++ ".zig" })),
14+
.target = target,
15+
.optimize = optimize,
16+
});
17+
b.installArtifact(exe);
18+
19+
const content = b.dependency("content", .{});
20+
exe.root_module.addImport("content", content.module("root"));
21+
22+
const zglfw = b.dependency("zglfw", .{
23+
.target = target,
24+
});
25+
exe.root_module.addImport("zglfw", zglfw.module("root"));
26+
exe.linkLibrary(zglfw.artifact("glfw"));
27+
28+
@import("zgpu").addLibraryPathsTo(exe);
29+
const zgpu = b.dependency("zgpu", .{
30+
.target = target,
31+
});
32+
exe.root_module.addImport("zgpu", zgpu.module("root"));
33+
exe.linkLibrary(zgpu.artifact("zdawn"));
34+
35+
const zgui = b.dependency("zgui", .{
36+
.target = target,
37+
.backend = .glfw_wgpu,
38+
.with_implot = true,
39+
.with_node_editor = true,
40+
.with_te = true,
41+
});
42+
exe.root_module.addImport("zgui", zgui.module("root"));
43+
exe.linkLibrary(zgui.artifact("imgui"));
44+
45+
const zmath = b.dependency("zmath", .{
46+
.target = target,
47+
});
48+
exe.root_module.addImport("zmath", zmath.module("root"));
49+
50+
const zstbi = b.dependency("zstbi", .{
51+
.target = target,
52+
});
53+
exe.root_module.addImport("zstbi", zstbi.module("root"));
54+
exe.linkLibrary(zstbi.artifact("zstbi"));
55+
56+
if (target.result.os.tag == .macos) {
57+
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
58+
exe.addLibraryPath(system_sdk.path("macos12/usr/lib"));
59+
exe.addSystemFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks"));
60+
}
61+
} else if (target.result.os.tag == .linux) {
62+
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
63+
exe.addLibraryPath(system_sdk.path("linux/lib/x86_64-linux-gnu"));
64+
}
65+
}
66+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.{
2+
.name = "gui_test_zgui",
3+
.version = "0.1.0",
4+
.minimum_zig_version = "0.14.0",
5+
.paths = .{
6+
"build.zig",
7+
"build.zig.zon",
8+
},
9+
.dependencies = .{
10+
.zgui = .{ .path = "../../" },
11+
.content = .{ .path = "../content" },
12+
13+
.system_sdk = .{
14+
.url = "https://github.com/zig-gamedev/system_sdk/archive/d1e724748d15cfcbf50c45ec7c7019688d45b16a.tar.gz",
15+
.hash = "122047a9298c4c9dd43389d418d6826d469b192246ba0944102964cdc57f94c562df",
16+
},
17+
18+
.zglfw = .{
19+
.url = "https://github.com/zig-gamedev/zglfw/archive/e9bd486903b5904b6d4e27b8b3771b138a667ef1.tar.gz",
20+
.hash = "12209fb981e7aab58c2f9062ab526bd43df3d7953aa41e131a173c37ad35d10b1132",
21+
},
22+
23+
.zmath = .{
24+
.url = "https://github.com/zig-gamedev/zmath/archive/24cdd20f9da09bd1ce7b552907eeaba9bafea59d.tar.gz",
25+
.hash = "1220081d55b58b968d953db1afc2fb01b2f5733929144e69522461ce25fa6450d84e",
26+
},
27+
28+
.zstbi = .{
29+
.url = "https://github.com/zig-gamedev/zstbi/archive/bcbd249f3f57fb84d6d76f1bc621c7bd3bfaa4a2.tar.gz",
30+
.hash = "12208b7d15a730294a7d8ee3a9d3ef145e109f94d0a68be7f0ee282e0630ede093d5",
31+
},
32+
33+
.zgpu = .{
34+
.url = "https://github.com/zig-gamedev/zgpu/archive/bc10f874cf9c93e347c1298efba87be4f001fc9d.tar.gz",
35+
.hash = "122020a116e18cad9f4ea905ca63a1505a47d680feb6edc9ebcf34795bf338f5868b",
36+
},
37+
.dawn_x86_64_windows_gnu = .{
38+
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-windows-gnu/archive/d3a68014e6b6b53fd330a0ccba99e4dcfffddae5.tar.gz",
39+
.hash = "1220f9448cde02ef3cd51bde2e0850d4489daa0541571d748154e89c6eb46c76a267",
40+
.lazy = true,
41+
},
42+
.dawn_x86_64_linux_gnu = .{
43+
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-linux-gnu/archive/7d70db023bf254546024629cbec5ee6113e12a42.tar.gz",
44+
.hash = "12204a3519efd49ea2d7cf63b544492a3a771d37eda320f86380813376801e4cfa73",
45+
.lazy = true,
46+
},
47+
.dawn_aarch64_linux_gnu = .{
48+
.url = "https://github.com/michal-z/webgpu_dawn-aarch64-linux-gnu/archive/c1f55e740a62f6942ff046e709ecd509a005dbeb.tar.gz",
49+
.hash = "12205cd13f6849f94ef7688ee88c6b74c7918a5dfb514f8a403fcc2929a0aa342627",
50+
.lazy = true,
51+
},
52+
.dawn_aarch64_macos = .{
53+
.url = "https://github.com/michal-z/webgpu_dawn-aarch64-macos/archive/d2360cdfff0cf4a780cb77aa47c57aca03cc6dfe.tar.gz",
54+
.hash = "12201fe677e9c7cfb8984a36446b329d5af23d03dc1e4f79a853399529e523a007fa",
55+
.lazy = true,
56+
},
57+
.dawn_x86_64_macos = .{
58+
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-macos/archive/901716b10b31ce3e0d3fe479326b41e91d59c661.tar.gz",
59+
.hash = "1220b1f02f2f7edd98a078c64e3100907d90311d94880a3cc5927e1ac009d002667a",
60+
.lazy = true,
61+
},
62+
},
63+
}
786 KB
Loading

0 commit comments

Comments
 (0)