update to zig 0.14.0 and clay 0.13

This commit is contained in:
johan0A 2025-03-06 22:13:31 +01:00
parent c26ef9d4b6
commit dff7f01dcd
22 changed files with 167 additions and 196 deletions

View file

@ -65,18 +65,18 @@ fn createLayout(profile_picture: *const rl.Texture2D) cl.ClayArray(cl.RenderComm
return cl.endLayout();
}
fn loadFont(file_data: ?[]const u8, font_id: u16, font_size: i32) void {
renderer.raylib_fonts[font_id] = rl.loadFontFromMemory(".ttf", file_data, font_size * 2, null);
fn loadFont(file_data: ?[]const u8, font_id: u16, font_size: i32) !void {
renderer.raylib_fonts[font_id] = try rl.loadFontFromMemory(".ttf", file_data, font_size * 2, null);
rl.setTextureFilter(renderer.raylib_fonts[font_id].?.texture, .bilinear);
}
fn loadImage(comptime path: [:0]const u8) rl.Texture2D {
const texture = rl.loadTextureFromImage(rl.loadImageFromMemory(@ptrCast(std.fs.path.extension(path)), @embedFile(path)));
fn loadImage(comptime path: [:0]const u8) !rl.Texture2D {
const texture = try rl.loadTextureFromImage(try rl.loadImageFromMemory(@ptrCast(std.fs.path.extension(path)), @embedFile(path)));
rl.setTextureFilter(texture, .bilinear);
return texture;
}
pub fn main() anyerror!void {
pub fn main() !void {
const allocator = std.heap.page_allocator;
// init clay
@ -97,8 +97,8 @@ pub fn main() anyerror!void {
rl.setTargetFPS(120);
// load assets
loadFont(@embedFile("./resources/Roboto-Regular.ttf"), 0, 24);
const profile_picture = loadImage("./resources/profile-picture.png");
try loadFont(@embedFile("./resources/Roboto-Regular.ttf"), 0, 24);
const profile_picture = try loadImage("./resources/profile-picture.png");
var debug_mode_enabled = false;
while (!rl.windowShouldClose()) {
@ -127,7 +127,7 @@ pub fn main() anyerror!void {
var render_commands = createLayout(&profile_picture);
rl.beginDrawing();
renderer.clayRaylibRender(&render_commands, allocator);
try renderer.clayRaylibRender(&render_commands, allocator);
rl.endDrawing();
}
}