examples: workaround change in @embedFile not working with relative paths

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-20 22:48:19 -07:00
parent 37c3045314
commit bc5e2fe9bf
8 changed files with 17 additions and 7 deletions

12
.gitmodules vendored
View file

@ -16,9 +16,6 @@
path = examples/libs/zigimg path = examples/libs/zigimg
url = https://github.com/slimsag/zigimg url = https://github.com/slimsag/zigimg
branch = zig-master branch = zig-master
[submodule "examples/assets"]
path = examples/assets
url = https://github.com/hexops/mach-example-assets
[submodule "freetype/upstream"] [submodule "freetype/upstream"]
path = freetype/upstream path = freetype/upstream
url = https://github.com/hexops/freetype url = https://github.com/hexops/freetype
@ -31,3 +28,12 @@
[submodule "sysaudio/upstream"] [submodule "sysaudio/upstream"]
path = sysaudio/upstream path = sysaudio/upstream
url = https://github.com/hexops/soundio url = https://github.com/hexops/soundio
[submodule "examples/image-blur/assets"]
path = examples/image-blur/assets
url = https://github.com/hexops/mach-example-assets
[submodule "examples/textured-cube/assets"]
path = examples/textured-cube/assets
url = https://github.com/hexops/mach-example-assets
[submodule "examples/gkurve/assets"]
path = examples/gkurve/assets
url = https://github.com/hexops/mach-example-assets

View file

@ -54,7 +54,9 @@ pub fn build(b: *std.build.Builder) void {
ensureGit(b.allocator); ensureGit(b.allocator);
ensureDependencySubmodule(b.allocator, "examples/libs/zmath") catch unreachable; ensureDependencySubmodule(b.allocator, "examples/libs/zmath") catch unreachable;
ensureDependencySubmodule(b.allocator, "examples/libs/zigimg") catch unreachable; ensureDependencySubmodule(b.allocator, "examples/libs/zigimg") catch unreachable;
ensureDependencySubmodule(b.allocator, "examples/assets") catch unreachable; ensureDependencySubmodule(b.allocator, "examples/gkurve/assets") catch unreachable;
ensureDependencySubmodule(b.allocator, "examples/image-blur/assets") catch unreachable;
ensureDependencySubmodule(b.allocator, "examples/textured-cube/assets") catch unreachable;
inline for ([_]ExampleDefinition{ inline for ([_]ExampleDefinition{
.{ .name = "triangle" }, .{ .name = "triangle" },

View file

@ -59,7 +59,7 @@ pub fn init(app: *App, core: *mach.Core) !void {
.rows_per_image = @intCast(u32, atlas_size.height), .rows_per_image = @intCast(u32, atlas_size.height),
}; };
const img = try zigimg.Image.fromMemory(core.allocator, @embedFile("../assets/gotta-go-fast.png")); const img = try zigimg.Image.fromMemory(core.allocator, @embedFile("./assets/gotta-go-fast.png"));
defer img.deinit(); defer img.deinit();
const atlas_img_region = try app.texture_atlas_data.reserve(core.allocator, @truncate(u32, img.width), @truncate(u32, img.height)); const atlas_img_region = try app.texture_atlas_data.reserve(core.allocator, @truncate(u32, img.width), @truncate(u32, img.height));

@ -0,0 +1 @@
Subproject commit b5a8404715e6cfc57e66c4a7cc0625e64b3b3c56

View file

@ -83,7 +83,7 @@ pub fn init(app: *App, core: *mach.Core) !void {
.min_filter = .linear, .min_filter = .linear,
}); });
const img = try zigimg.Image.fromMemory(core.allocator, @embedFile("../assets/gotta-go-fast.png")); const img = try zigimg.Image.fromMemory(core.allocator, @embedFile("./assets/gotta-go-fast.png"));
defer img.deinit(); defer img.deinit();
const img_size = gpu.Extent3D{ .width = @intCast(u32, img.width), .height = @intCast(u32, img.height) }; const img_size = gpu.Extent3D{ .width = @intCast(u32, img.width), .height = @intCast(u32, img.height) };

@ -0,0 +1 @@
Subproject commit b5a8404715e6cfc57e66c4a7cc0625e64b3b3c56

View file

@ -105,7 +105,7 @@ pub fn init(app: *App, core: *mach.Core) !void {
.min_filter = .linear, .min_filter = .linear,
}); });
const queue = core.device.getQueue(); const queue = core.device.getQueue();
var img = try zigimg.Image.fromMemory(core.allocator, @embedFile("assets/gotta-go-fast.png")); var img = try zigimg.Image.fromMemory(core.allocator, @embedFile("./assets/gotta-go-fast.png"));
defer img.deinit(); defer img.deinit();
const img_size = gpu.Extent3D{ .width = @intCast(u32, img.width), .height = @intCast(u32, img.height) }; const img_size = gpu.Extent3D{ .width = @intCast(u32, img.width), .height = @intCast(u32, img.height) };
const cube_texture = core.device.createTexture(&.{ const cube_texture = core.device.createTexture(&.{