From 729b8e9af15799de72ef08b3bd7f73ca1e530159 Mon Sep 17 00:00:00 2001 From: Vicente Ferrari Smith Date: Thu, 29 Jan 2026 21:35:54 +0100 Subject: [PATCH] smth --- build.zig | 56 +++++++++++++-------------------------------- src/client/font.zig | 17 ++++++-------- src/client/main.zig | 5 ++-- 3 files changed, 26 insertions(+), 52 deletions(-) diff --git a/build.zig b/build.zig index 56d6a05..7a9bfe7 100644 --- a/build.zig +++ b/build.zig @@ -1,8 +1,8 @@ const std = @import("std"); pub fn build(b: *std.Build) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); + const target = b.standardTargetOptions(.{ .default_target = .{ .cpu_model = .native } }); + const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseFast }); const assets = b.addInstallDirectory(.{ .source_dir = b.path("assets"), @@ -10,43 +10,6 @@ pub fn build(b: *std.Build) void { .install_subdir = "assets", }); - // const sdl3 = b.dependency("sdl3", .{ - // .target = target, - // .optimize = .Debug, - - // // Lib options. - // // .callbacks = false, - // // .ext_image = false, - // // .ext_net = false, - // // .ext_ttf = false, - // // .log_message_stack_size = 1024, - // // .main = false, - // // .renderer_debug_text_stack_size = 1024, - - // // Options passed directly to https://github.com/castholm/SDL (SDL3 C Bindings): - // // .c_sdl_preferred_linkage = .static, - // // .c_sdl_strip = false, - // // .c_sdl_sanitize_c = .off, - // // .c_sdl_lto = .none, - // // .c_sdl_emscripten_pthreads = false, - // // .c_sdl_install_build_config_h = false, - - // // Options if `ext_image` is enabled: - // // .image_enable_bmp = true, - // // .image_enable_gif = true, - // // .image_enable_jpg = true, - // // .image_enable_lbm = true, - // // .image_enable_pcx = true, - // // .image_enable_png = true, - // // .image_enable_pnm = true, - // // .image_enable_qoi = true, - // // .image_enable_svg = true, - // // .image_enable_tga = true, - // // .image_enable_xcf = true, - // // .image_enable_xpm = true, - // // .image_enable_xv = true, - // }); - const shared = b.addModule("shared", .{ .root_source_file = b.path("src/shared/shared.zig"), .target = target, @@ -67,6 +30,7 @@ pub fn build(b: *std.Build) void { }), .use_llvm = true, }); + client.root_module.strip = true; const server = b.addExecutable(.{ .name = "server", @@ -80,6 +44,7 @@ pub fn build(b: *std.Build) void { }), .use_llvm = true, }); + server.root_module.strip = true; const ztracy = b.dependency("ztracy", .{ .enable_ztracy = true, @@ -96,7 +61,18 @@ pub fn build(b: *std.Build) void { client.root_module.addImport("mach-freetype", mach_freetype.module("mach-freetype")); client.root_module.addImport("mach-harfbuzz", mach_freetype.module("mach-harfbuzz")); - client.root_module.addCSourceFile(.{ .file = b.path("vendor/kb_text_shape/kb_text_shape.h"), .language = .c, .flags = &.{"-DKB_TEXT_SHAPE_IMPLEMENTATION"} }); + client.root_module.addCSourceFile(.{ + .file = b.path("vendor/kb_text_shape/kb_text_shape.h"), + .language = .c, + .flags = &.{ + "-DKB_TEXT_SHAPE_IMPLEMENTATION", + "-O3", // Maximum optimization + // "-ffast-math", // Allows algebraic reorganizations (risky for precision, great for speed) + // "-fno-plt", // Reduces overhead for library calls + // "-march=native", // Use every instruction your CPU has + // "-flto", // Enable LTO for the C side specifically + }, + }); const kb_text_shape = b.addTranslateC(.{ .root_source_file = b.path("vendor/kb_text_shape/kb_text_shape.h"), .target = target, diff --git a/src/client/font.zig b/src/client/font.zig index 9d6d7d4..047dedf 100644 --- a/src/client/font.zig +++ b/src/client/font.zig @@ -1,10 +1,10 @@ -const std = @import("std"); -const rl = @import("raylib"); -const kb = @import("kb"); -const ft = @import("mach-freetype"); -const hb = @import("mach-harfbuzz"); -const rp = @import("stb_rect_pack"); -const ztracy = @import("ztracy"); +const std = @import("std"); +const rl = @import("raylib"); +const kb = @import("kb"); +const ft = @import("mach-freetype"); +const hb = @import("mach-harfbuzz"); +const rp = @import("stb_rect_pack"); +const ztracy = @import("ztracy"); pub var ft_lib : ft.Library = undefined; pub var shader : rl.Shader = undefined; @@ -286,9 +286,6 @@ pub const Font = struct { const dpi_offset_y = offset_y / rl.getWindowScaleDPI().y; if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| { - if (RunGlyph.OffsetX != 0) { - std.log.info("font bearing ({}, {}), kb offset ({}, {})", .{glyph.bearing_x, glyph.bearing_y, RunGlyph.OffsetX, RunGlyph.OffsetX}); - } var v0 = rl.Vector2.zero(); var v1 = rl.Vector2.zero(); diff --git a/src/client/main.zig b/src/client/main.zig index b233428..4514bb1 100644 --- a/src/client/main.zig +++ b/src/client/main.zig @@ -3,8 +3,9 @@ const zm = @import("zmath"); const znet = @import("znet"); const rl = @import("raylib"); const bufzilla = @import("bufzilla"); -const ft = @import("mach-freetype"); +const ft = @import("mach-freetype"); const ztracy = @import("ztracy"); +const kb = @import("kb"); const shared = @import("shared"); @@ -49,7 +50,7 @@ pub fn main() !void { try znet.init(); defer znet.deinit(); - rl.setConfigFlags(.{ .window_highdpi = true, .vsync_hint = true }); + // rl.setConfigFlags(.{ .window_highdpi = true, .vsync_hint = true }); rl.initWindow(screen_width, screen_height, "zzz"); defer rl.closeWindow();