|
|
@ -9,10 +9,14 @@ const c = @cImport({
|
|
9
|
9
|
@cInclude("SDL2/SDL.h");
|
|
10
|
10
|
@cInclude("SDL2/SDL_ttf.h");
|
|
11
|
11
|
});
|
|
12
|
|
const assert = @import("std").debug.assert;
|
|
13
|
|
const process = @import("std").process;
|
|
|
12
|
const std = @import("std");
|
|
14
|
13
|
|
|
15
|
14
|
pub fn main() !void {
|
|
|
15
|
var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
|
|
|
16
|
const gpa = &general_purpose_allocator.allocator;
|
|
|
17
|
const args = try std.process.argsAlloc(gpa);
|
|
|
18
|
defer std.process.argsFree(gpa, args);
|
|
|
19
|
|
|
16
|
20
|
if (c.SDL_Init(c.SDL_INIT_VIDEO) != 0) {
|
|
17
|
21
|
c.SDL_Log("Unable to initialize SDL: %s", c.SDL_GetError());
|
|
18
|
22
|
return error.SDLInitializationFailed;
|
|
|
@ -25,12 +29,13 @@ pub fn main() !void {
|
|
25
|
29
|
}
|
|
26
|
30
|
defer c.TTF_Quit();
|
|
27
|
31
|
|
|
28
|
|
var font_file = "./FantasqueSansMono-Regular.ttf";
|
|
|
32
|
var font_file = if (args.len > 1) args[1] else "./FantasqueSansMono-Regular.ttf";
|
|
29
|
33
|
const font = c.TTF_OpenFont(font_file, 20) orelse {
|
|
30
|
34
|
c.SDL_Log("Unable to load font: %s", c.TTF_GetError());
|
|
31
|
35
|
return error.TTFInitializationFailed;
|
|
32
|
36
|
};
|
|
33
|
37
|
defer c.TTF_CloseFont(font);
|
|
|
38
|
c.SDL_Log("Using font %s", font_file.ptr);
|
|
34
|
39
|
|
|
35
|
40
|
const msg = "howdy there, enby! 🐘 ";
|
|
36
|
41
|
c.SDL_Log(msg);
|