From 0af12b6b92e17b4ca66c0c43b190fe9cf428fea7 Mon Sep 17 00:00:00 2001 From: Mark Delk Date: Sun, 29 Sep 2024 11:06:19 -0500 Subject: [PATCH] update SDL, SDL_ttf --- build.zig | 32 +++++++++++++++++++++++--------- build.zig.zon | 10 ++++------ src/ttf.zig | 9 +-------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/build.zig b/build.zig index f545eed..8184329 100644 --- a/build.zig +++ b/build.zig @@ -781,14 +781,26 @@ pub fn build(b: *std.Build) !void { }; const sdl_examples = [_]SdlExample{ - SdlExample{ .path = "examples/audio/01-simple-playback", .name = "simple-playback" }, - SdlExample{ .path = "examples/audio/02-simple-playback-callback", .name = "simple-playback-callback" }, - SdlExample{ .path = "examples/audio/03-load-wav", .name = "load-wav" }, - SdlExample{ .path = "examples/camera/01-read-and-draw", .name = "read-and-draw" }, - SdlExample{ .path = "examples/game/01-snake", .name = "snake" }, - SdlExample{ .path = "examples/pen/01-drawing-lines", .name = "drawing-lines" }, - SdlExample{ .path = "examples/renderer/01-clear", .name = "renderer-clear" }, - SdlExample{ .path = "examples/renderer/02-primitives", .name = "renderer-primitives" }, + SdlExample{ .path = "examples/audio/01-simple-playback/simple-playback.c", .name = "simple-playback" }, + SdlExample{ .path = "examples/audio/02-simple-playback-callback/simple-playback-callback.c", .name = "simple-playback-callback" }, + SdlExample{ .path = "examples/audio/03-load-wav/load-wav.c", .name = "load-wav" }, + SdlExample{ .path = "examples/camera/01-read-and-draw/read-and-draw.c", .name = "read-and-draw" }, + SdlExample{ .path = "examples/game/01-snake/snake.c", .name = "snake" }, + SdlExample{ .path = "examples/pen/01-drawing-lines/drawing-lines.c", .name = "drawing-lines" }, + SdlExample{ .path = "examples/renderer/01-clear/clear.c", .name = "clear" }, + SdlExample{ .path = "examples/renderer/02-primitives/primitives.c", .name = "primitives" }, + SdlExample{ .path = "examples/renderer/03-lines/lines.c", .name = "lines" }, + SdlExample{ .path = "examples/renderer/04-points/points.c", .name = "points" }, + SdlExample{ .path = "examples/renderer/05-rectangles/rectangles.c", .name = "rectangles" }, + SdlExample{ .path = "examples/renderer/06-textures/textures.c", .name = "textures" }, + SdlExample{ .path = "examples/renderer/07-streaming-textures/streaming-textures.c", .name = "streaming-textures" }, + SdlExample{ .path = "examples/renderer/08-rotating-textures/rotating-textures.c", .name = "rotating-textures" }, + SdlExample{ .path = "examples/renderer/09-scaling-textures/scaling-textures.c", .name = "scaling-textures" }, + SdlExample{ .path = "examples/renderer/10-geometry/geometry.c", .name = "geometry" }, + SdlExample{ .path = "examples/renderer/11-color-mods/color-mods.c", .name = "color-mods" }, + SdlExample{ .path = "examples/renderer/14-viewport/viewport.c", .name = "viewport" }, + SdlExample{ .path = "examples/renderer/15-cliprect/cliprect.c", .name = "cliprect" }, + SdlExample{ .path = "examples/renderer/17-read-pixels/read-pixels.c", .name = "read-pixels" }, }; for (sdl_examples) |sdl_example| { @@ -801,7 +813,7 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }); exe.addCSourceFile(.{ - .file = sdl_dep.path(b.fmt("{s}/{s}.c", .{ path, name })), + .file = sdl_dep.path(path), .flags = &.{}, }); exe.linkLibrary(lib); @@ -1006,6 +1018,7 @@ const generic_src_files = [_][]const u8{ "src/stdlib/SDL_stdlib.c", "src/stdlib/SDL_string.c", "src/stdlib/SDL_strtokr.c", + "src/stdlib/SDL_murmur3.c", "src/storage/SDL_storage.c", "src/storage/generic/SDL_genericstorage.c", @@ -1158,6 +1171,7 @@ const linux_src_files = [_][]const u8{ "src/joystick/hidapi/SDL_hidapi_xboxone.c", "src/joystick/hidapi/SDL_hidapijoystick.c", "src/joystick/linux/SDL_sysjoystick.c", + "src/joystick/hidapi/SDL_hidapi_steam_hori.c", // "src/joystick/n3ds/SDL_sysjoystick.c", // "src/joystick/ps2/SDL_sysjoystick.c", diff --git a/build.zig.zon b/build.zig.zon index d807861..d937a69 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -8,17 +8,15 @@ .paths = .{""}, .dependencies = .{ .sdl = .{ - .url = "git+https://github.com/libsdl-org/SDL?ref=main#4f722d372ae7246f123762b0407cbec1e6e71d65", - .hash = "122003b98a58e3b549bbed69d8aa1713f01d53d337dd512e80251918af385da96ef1", + .url = "git+https://github.com/libsdl-org/SDL?ref=main#62938837c239309500d0c078209ace4760909ec8", + .hash = "12204cc7c5c5885c0d804ded40698480a38786a5b30efeab15588e6d53de80682a4a", }, .sdl_ttf = .{ - .url = "git+https://github.com/libsdl-org/SDL_ttf?ref=main#8cb1095cc20a5395bef011051ff625de4d2598c8", - .hash = "1220369b99f58e79b6aeeac68703210f8e32367079ce58e2811192a7a92bee4a81bb", + .url = "git+https://github.com/libsdl-org/SDL_ttf?ref=main#41342890704ef3cac661a0d301f3dd122d96a039", + .hash = "1220c2c929aa0731a6ed363d4aa5beac07d3224e52f3b7a28052efee71ce43512e9c", }, .freetype = .{ .path = "build/freetype", - // .url = "git+https://gitlab.freedesktop.org/freetype/freetype.git#VER-2-13-2", - // .hash = "1220b81f6ecfb3fd222f76cf9106fecfa6554ab07ec7fdc4124b9bb063ae2adf969d", }, .fonts = .{ .path = "build/fonts", diff --git a/src/ttf.zig b/src/ttf.zig index 9b76fec..6ba0cb7 100644 --- a/src/ttf.zig +++ b/src/ttf.zig @@ -7,12 +7,6 @@ const sdl = @import("sdl").c; const font_file = @import("sdl").fonts.intel_one_mono_regular; pub fn main() !void { - var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); - defer arena.deinit(); - const allocator = arena.allocator(); - - // - if (!sdl.SDL_Init(sdl.SDL_INIT_VIDEO)) { std.log.err("Unable to initialize SDL: {s}", .{sdl.SDL_GetError()}); return error.SDLInitializationFailed; @@ -114,8 +108,7 @@ pub fn main() !void { .a = @floor(0.87 * 255), }; - const c_str = try allocator.dupeZ(u8, text); - const text_surface = sdl.TTF_RenderText_Solid(font, c_str, color) orelse { + const text_surface = sdl.TTF_RenderText_Blended(font, text.ptr, text.len, color) orelse { std.log.err("TTF_RenderText_Solid: {s}", .{sdl.SDL_GetError()}); return error.TTF_RenderText_Solid; };