From b5737af9cd86b4a959465c4efc43d9a2a6df5a07 Mon Sep 17 00:00:00 2001 From: iddev5 Date: Fri, 27 May 2022 13:20:26 +0530 Subject: [PATCH] examples: Load all images from Memory (using embedFile) instead of File --- build.zig | 4 ++-- examples/gkurve/main.zig | 2 +- examples/textured-cube/main.zig | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 51ae5cff..f86e69d7 100644 --- a/build.zig +++ b/build.zig @@ -37,8 +37,8 @@ pub fn build(b: *std.build.Builder) void { .{ .name = "instanced-cube", .packages = &[_]Pkg{Packages.zmath} }, .{ .name = "advanced-gen-texture-light", .packages = &[_]Pkg{Packages.zmath} }, .{ .name = "fractal-cube", .packages = &[_]Pkg{Packages.zmath} }, - .{ .name = "gkurve", .packages = &[_]Pkg{ Packages.zmath, Packages.zigimg }, .std_platform_only = true }, - .{ .name = "textured-cube", .packages = &[_]Pkg{ Packages.zmath, Packages.zigimg }, .std_platform_only = true }, + .{ .name = "gkurve", .packages = &[_]Pkg{ Packages.zmath, Packages.zigimg } }, + .{ .name = "textured-cube", .packages = &[_]Pkg{ Packages.zmath, Packages.zigimg } }, }) |example| { // FIXME: this is workaround for a problem that some examples (having the std_platform_only=true field) as // well as zigimg uses IO which is not supported in freestanding environments. So break out of this loop diff --git a/examples/gkurve/main.zig b/examples/gkurve/main.zig index 0803808b..76c21ea7 100644 --- a/examples/gkurve/main.zig +++ b/examples/gkurve/main.zig @@ -53,7 +53,7 @@ pub fn init(app: *App, engine: *mach.Engine) !void { .rows_per_image = @intCast(u32, atlas_size.height), }; - const img = try zigimg.Image.fromFilePath(engine.allocator, "examples/assets/gotta-go-fast.png"); + const img = try zigimg.Image.fromMemory(engine.allocator, @embedFile("../assets/gotta-go-fast.png")); defer img.deinit(); const atlas_img_region = try texture_atlas_data.reserve(engine.allocator, @truncate(u32, img.width), @truncate(u32, img.height)); diff --git a/examples/textured-cube/main.zig b/examples/textured-cube/main.zig index fe12f746..fcf6cb29 100644 --- a/examples/textured-cube/main.zig +++ b/examples/textured-cube/main.zig @@ -113,7 +113,7 @@ pub fn init(app: *App, engine: *mach.Engine) !void { .min_filter = .linear, }); const queue = engine.gpu_driver.device.getQueue(); - const img = try zigimg.Image.fromFilePath(engine.allocator, "examples/assets/gotta-go-fast.png"); + const img = try zigimg.Image.fromMemory(engine.allocator, @embedFile("../assets/gotta-go-fast.png")); const img_size = gpu.Extent3D{ .width = @intCast(u32, img.width), .height = @intCast(u32, img.height) }; const cube_texture = engine.gpu_driver.device.createTexture(&.{ .size = img_size,