Skip to content

Commit 0af12b6

Browse files
committed
update SDL, SDL_ttf
1 parent c883aec commit 0af12b6

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

build.zig

+23-9
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,26 @@ pub fn build(b: *std.Build) !void {
781781
};
782782

783783
const sdl_examples = [_]SdlExample{
784-
SdlExample{ .path = "examples/audio/01-simple-playback", .name = "simple-playback" },
785-
SdlExample{ .path = "examples/audio/02-simple-playback-callback", .name = "simple-playback-callback" },
786-
SdlExample{ .path = "examples/audio/03-load-wav", .name = "load-wav" },
787-
SdlExample{ .path = "examples/camera/01-read-and-draw", .name = "read-and-draw" },
788-
SdlExample{ .path = "examples/game/01-snake", .name = "snake" },
789-
SdlExample{ .path = "examples/pen/01-drawing-lines", .name = "drawing-lines" },
790-
SdlExample{ .path = "examples/renderer/01-clear", .name = "renderer-clear" },
791-
SdlExample{ .path = "examples/renderer/02-primitives", .name = "renderer-primitives" },
784+
SdlExample{ .path = "examples/audio/01-simple-playback/simple-playback.c", .name = "simple-playback" },
785+
SdlExample{ .path = "examples/audio/02-simple-playback-callback/simple-playback-callback.c", .name = "simple-playback-callback" },
786+
SdlExample{ .path = "examples/audio/03-load-wav/load-wav.c", .name = "load-wav" },
787+
SdlExample{ .path = "examples/camera/01-read-and-draw/read-and-draw.c", .name = "read-and-draw" },
788+
SdlExample{ .path = "examples/game/01-snake/snake.c", .name = "snake" },
789+
SdlExample{ .path = "examples/pen/01-drawing-lines/drawing-lines.c", .name = "drawing-lines" },
790+
SdlExample{ .path = "examples/renderer/01-clear/clear.c", .name = "clear" },
791+
SdlExample{ .path = "examples/renderer/02-primitives/primitives.c", .name = "primitives" },
792+
SdlExample{ .path = "examples/renderer/03-lines/lines.c", .name = "lines" },
793+
SdlExample{ .path = "examples/renderer/04-points/points.c", .name = "points" },
794+
SdlExample{ .path = "examples/renderer/05-rectangles/rectangles.c", .name = "rectangles" },
795+
SdlExample{ .path = "examples/renderer/06-textures/textures.c", .name = "textures" },
796+
SdlExample{ .path = "examples/renderer/07-streaming-textures/streaming-textures.c", .name = "streaming-textures" },
797+
SdlExample{ .path = "examples/renderer/08-rotating-textures/rotating-textures.c", .name = "rotating-textures" },
798+
SdlExample{ .path = "examples/renderer/09-scaling-textures/scaling-textures.c", .name = "scaling-textures" },
799+
SdlExample{ .path = "examples/renderer/10-geometry/geometry.c", .name = "geometry" },
800+
SdlExample{ .path = "examples/renderer/11-color-mods/color-mods.c", .name = "color-mods" },
801+
SdlExample{ .path = "examples/renderer/14-viewport/viewport.c", .name = "viewport" },
802+
SdlExample{ .path = "examples/renderer/15-cliprect/cliprect.c", .name = "cliprect" },
803+
SdlExample{ .path = "examples/renderer/17-read-pixels/read-pixels.c", .name = "read-pixels" },
792804
};
793805

794806
for (sdl_examples) |sdl_example| {
@@ -801,7 +813,7 @@ pub fn build(b: *std.Build) !void {
801813
.optimize = optimize,
802814
});
803815
exe.addCSourceFile(.{
804-
.file = sdl_dep.path(b.fmt("{s}/{s}.c", .{ path, name })),
816+
.file = sdl_dep.path(path),
805817
.flags = &.{},
806818
});
807819
exe.linkLibrary(lib);
@@ -1006,6 +1018,7 @@ const generic_src_files = [_][]const u8{
10061018
"src/stdlib/SDL_stdlib.c",
10071019
"src/stdlib/SDL_string.c",
10081020
"src/stdlib/SDL_strtokr.c",
1021+
"src/stdlib/SDL_murmur3.c",
10091022

10101023
"src/storage/SDL_storage.c",
10111024
"src/storage/generic/SDL_genericstorage.c",
@@ -1158,6 +1171,7 @@ const linux_src_files = [_][]const u8{
11581171
"src/joystick/hidapi/SDL_hidapi_xboxone.c",
11591172
"src/joystick/hidapi/SDL_hidapijoystick.c",
11601173
"src/joystick/linux/SDL_sysjoystick.c",
1174+
"src/joystick/hidapi/SDL_hidapi_steam_hori.c",
11611175

11621176
// "src/joystick/n3ds/SDL_sysjoystick.c",
11631177
// "src/joystick/ps2/SDL_sysjoystick.c",

build.zig.zon

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
.paths = .{""},
99
.dependencies = .{
1010
.sdl = .{
11-
.url = "git+https://github.com/libsdl-org/SDL?ref=main#4f722d372ae7246f123762b0407cbec1e6e71d65",
12-
.hash = "122003b98a58e3b549bbed69d8aa1713f01d53d337dd512e80251918af385da96ef1",
11+
.url = "git+https://github.com/libsdl-org/SDL?ref=main#62938837c239309500d0c078209ace4760909ec8",
12+
.hash = "12204cc7c5c5885c0d804ded40698480a38786a5b30efeab15588e6d53de80682a4a",
1313
},
1414
.sdl_ttf = .{
15-
.url = "git+https://github.com/libsdl-org/SDL_ttf?ref=main#8cb1095cc20a5395bef011051ff625de4d2598c8",
16-
.hash = "1220369b99f58e79b6aeeac68703210f8e32367079ce58e2811192a7a92bee4a81bb",
15+
.url = "git+https://github.com/libsdl-org/SDL_ttf?ref=main#41342890704ef3cac661a0d301f3dd122d96a039",
16+
.hash = "1220c2c929aa0731a6ed363d4aa5beac07d3224e52f3b7a28052efee71ce43512e9c",
1717
},
1818
.freetype = .{
1919
.path = "build/freetype",
20-
// .url = "git+https://gitlab.freedesktop.org/freetype/freetype.git#VER-2-13-2",
21-
// .hash = "1220b81f6ecfb3fd222f76cf9106fecfa6554ab07ec7fdc4124b9bb063ae2adf969d",
2220
},
2321
.fonts = .{
2422
.path = "build/fonts",

src/ttf.zig

+1-8
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ const sdl = @import("sdl").c;
77
const font_file = @import("sdl").fonts.intel_one_mono_regular;
88

99
pub fn main() !void {
10-
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
11-
defer arena.deinit();
12-
const allocator = arena.allocator();
13-
14-
//
15-
1610
if (!sdl.SDL_Init(sdl.SDL_INIT_VIDEO)) {
1711
std.log.err("Unable to initialize SDL: {s}", .{sdl.SDL_GetError()});
1812
return error.SDLInitializationFailed;
@@ -114,8 +108,7 @@ pub fn main() !void {
114108
.a = @floor(0.87 * 255),
115109
};
116110

117-
const c_str = try allocator.dupeZ(u8, text);
118-
const text_surface = sdl.TTF_RenderText_Solid(font, c_str, color) orelse {
111+
const text_surface = sdl.TTF_RenderText_Blended(font, text.ptr, text.len, color) orelse {
119112
std.log.err("TTF_RenderText_Solid: {s}", .{sdl.SDL_GetError()});
120113
return error.TTF_RenderText_Solid;
121114
};

0 commit comments

Comments
 (0)