|
|
@ -5,6 +5,11 @@
|
|
5
|
5
|
// Resources:
|
|
6
|
6
|
// - http://wiki.libsdl.org/CategoryAPI
|
|
7
|
7
|
// - https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html
|
|
|
8
|
//
|
|
|
9
|
// Unrelatedly, https://ziglang.org/learn/samples/ lead me to
|
|
|
10
|
// raylib, which looks like a really neat library to get started with
|
|
|
11
|
// game programming without Godot or Unity:
|
|
|
12
|
// https://github.com/raysan5/raylib
|
|
8
|
13
|
const c = @cImport({
|
|
9
|
14
|
@cInclude("SDL2/SDL.h");
|
|
10
|
15
|
@cInclude("SDL2/SDL_ttf.h");
|
|
|
@ -71,6 +76,8 @@ pub fn main() !void {
|
|
71
|
76
|
// thanks to https://stackoverflow.com/questions/22886500/how-to-render-text-in-sdl2 for some actually useful code here
|
|
72
|
77
|
const white: c.SDL_Color = c.SDL_Color{ .r = 255, .g = 255, .b = 255, .a = 255 };
|
|
73
|
78
|
const black: c.SDL_Color = c.SDL_Color{ .r = 0, .g = 0, .b = 0, .a = 255 };
|
|
|
79
|
// Shaded vs Solid gives a nicer output, with solid the output
|
|
|
80
|
// was squiggly and not aligned with a baseline.
|
|
74
|
81
|
const text = c.TTF_RenderUTF8_Shaded(font, msg, white, black);
|
|
75
|
82
|
_ = c.SDL_BlitSurface(text, null, surface, null);
|
|
76
|
83
|
|