Add SDL TTF for text rendering

This commit is contained in:
Nathan McRae 2023-06-10 23:11:44 -07:00
parent 80de6db167
commit deb02fa359
2 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,7 @@ pub fn build(b: *Builder) void {
exe.setBuildMode(mode);
exe.linkSystemLibrary("SDL2");
exe.linkSystemLibrary("SDL_TTF");
exe.linkSystemLibrary("c");
b.default_step.dependOn(&exe.step);

View File

@ -3,6 +3,11 @@ const std = @import("std");
const c = @cImport({
@cInclude("SDL2/SDL.h");
});
const t = @cImport({
@cInclude("SDL/SDL_ttf.h");
});
const assert = @import("std").debug.assert;
pub fn main() !void {
@ -37,6 +42,13 @@ pub fn main() !void {
return error.SDLInitializationFailed;
}
const ttf_init_result = t.TTF_Init();
if (ttf_init_result != 0) {
c.SDL_Log("Unable to init TTF: %d", ttf_init_result);
return error.TTFInitializationFailed;
}
defer t.TTF_Quit();
// const surface = c.SDL_GetWindowSurface(screen);
var quit = false;