Use castle's stbi instead of zstbi

This commit is contained in:
2026-02-06 23:27:21 +01:00
parent 33a0b241ef
commit 39712e359d
10 changed files with 73 additions and 75 deletions

View File

@@ -3,6 +3,7 @@
const Blocks = @This();
const std = @import("std");
const media = @import("media");
const voxels = @import("../voxels.zig");
const Atom = @import("../engine/Atom.zig").Atom;
@@ -134,6 +135,7 @@ pub fn getOrLoad(
engine: *Engine,
materials: *Materials,
textures: *Textures,
stbi: *media.stbi,
filename: []const u8,
temp_allocator: std.mem.Allocator,
) !Id {
@@ -152,7 +154,7 @@ pub fn getOrLoad(
const id = Id.fromIndexSafe(self.array.items.len) catch |err| switch (err) {
error.Overflow => return error.OutOfBlocks,
};
const def = try loadBlock(engine, materials, textures, filename, temp_allocator);
const def = try loadBlock(engine, materials, textures, stbi, filename, temp_allocator);
self.map.putAssumeCapacityNoClobber(key, id);
self.array.appendAssumeCapacity(def);
@@ -166,6 +168,7 @@ pub fn getOrLoadAtom(
engine: *Engine,
materials: *Materials,
textures: *Textures,
stbi: *media.stbi,
filename: Atom,
temp_allocator: std.mem.Allocator,
) !Id {
@@ -182,7 +185,7 @@ pub fn getOrLoadAtom(
const id = Id.fromIndexSafe(self.array.items.len) catch |err| switch (err) {
error.Overflow => return error.OutOfBlocks,
};
const def = try loadBlock(engine, materials, textures, filename.toString(), temp_allocator);
const def = try loadBlock(engine, materials, textures, stbi, filename.toString(), temp_allocator);
self.map.putAssumeCapacityNoClobber(key, id);
self.array.appendAssumeCapacity(def);
@@ -196,6 +199,7 @@ pub fn loadAll(
engine: *Engine,
materials: *Materials,
textures: *Textures,
stbi: *media.stbi,
temp_allocator: std.mem.Allocator,
) void {
const cwd = std.fs.cwd();
@@ -216,7 +220,7 @@ pub fn loadAll(
continue;
}
_ = self.getOrLoad(engine, materials, textures, entry.name, temp_allocator) catch |err| {
_ = self.getOrLoad(engine, materials, textures, stbi, entry.name, temp_allocator) catch |err| {
std.log.err("Error while loading block definition entry {s}: {s}", .{ entry.name, @errorName(err) });
};
}
@@ -226,6 +230,7 @@ fn loadBlock(
engine: *Engine,
materials: *Materials,
textures: *Textures,
stbi: *media.stbi,
filename: []const u8,
temp_allocator: std.mem.Allocator,
) !Definition {
@@ -274,7 +279,7 @@ fn loadBlock(
return error.ParseError;
}
const material = try materials.getOrLoad(engine, textures, name, temp_allocator);
const material = try materials.getOrLoad(engine, textures, stbi, name, temp_allocator);
break :blk .initUniform(material);
}
@@ -284,7 +289,7 @@ fn loadBlock(
var ret: Definition.Walls = undefined;
inline for (@typeInfo(voxels.Orientation).@"enum".fields) |field| {
@field(ret, field.name) = .{
.material = try materials.getOrLoad(engine, textures, @field(walls, field.name).material, temp_allocator),
.material = try materials.getOrLoad(engine, textures, stbi, @field(walls, field.name).material, temp_allocator),
.transform = @field(walls, field.name).transform,
};
}