examples: improve compatibility with self-hosted compiler; zigimg updates

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-20 22:58:18 -07:00
parent bc5e2fe9bf
commit c4421840cb
3 changed files with 4 additions and 4 deletions

View file

@ -109,7 +109,7 @@ fn write(ctx: WriterContext, bytes: []const u8) WriterError!usize {
glyph_buffer[(y - 1) * glyph_width + (x - 1)]; glyph_buffer[(y - 1) * glyph_width + (x - 1)];
// zig fmt: on // zig fmt: on
data.* = zigimg.color.Rgba32.initRGB(glyph_col, glyph_col, glyph_col); data.* = zigimg.color.Rgba32.initRgb(glyph_col, glyph_col, glyph_col);
} }
var glyph_atlas_region = try ctx.app.texture_atlas_data.reserve(ctx.label.allocator, glyph_width + 2, glyph_height + 2); var glyph_atlas_region = try ctx.app.texture_atlas_data.reserve(ctx.label.allocator, glyph_width + 2, glyph_height + 2);
ctx.app.texture_atlas_data.set(glyph_atlas_region, glyph_data); ctx.app.texture_atlas_data.set(glyph_atlas_region, glyph_data);

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")); var 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));
@ -84,7 +84,7 @@ pub fn init(app: *App, core: *mach.Core) !void {
const white_texture_uv_data = atlas_white_region.getUVData(atlas_float_size); const white_texture_uv_data = atlas_white_region.getUVData(atlas_float_size);
var white_tex_data = try core.allocator.alloc(zigimg.color.Rgba32, white_tex_scale * white_tex_scale); var white_tex_data = try core.allocator.alloc(zigimg.color.Rgba32, white_tex_scale * white_tex_scale);
defer core.allocator.free(white_tex_data); defer core.allocator.free(white_tex_data);
std.mem.set(zigimg.color.Rgba32, white_tex_data, zigimg.color.Rgba32.initRGB(0xff, 0xff, 0xff)); std.mem.set(zigimg.color.Rgba32, white_tex_data, zigimg.color.Rgba32.initRgb(0xff, 0xff, 0xff));
app.texture_atlas_data.set(atlas_white_region, white_tex_data); app.texture_atlas_data.set(atlas_white_region, white_tex_data);
app.vertices = try std.ArrayList(draw.Vertex).initCapacity(core.allocator, 9); app.vertices = try std.ArrayList(draw.Vertex).initCapacity(core.allocator, 9);

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")); 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) };