|
|
@ -0,0 +1,36 @@
|
|
|
1
|
# hello\_sdl
|
|
|
2
|
|
|
|
3
|
While reading [Things Unlearned](https://scattered-thoughts.net/writing/things-unlearned)
|
|
|
4
|
by Jamie Brandon recently, I happened upon this paragraph:
|
|
|
5
|
|
|
|
6
|
> I definitely feel I've gotten better at this. When I wanted to write a
|
|
|
7
|
> text editor last year I spent a few days learning the absolute basics
|
|
|
8
|
> of graphics programming and text rendering, used mostly mainstream
|
|
|
9
|
> tools like sdl and freetype, and then just sat down and shoveled
|
|
|
10
|
> through a long todo list. In the end it only took 100 hours or so,
|
|
|
11
|
> much less time than I spent thrashing on that note-taking app a decade
|
|
|
12
|
> ago. And now I get to use my text editor all the time.
|
|
|
13
|
|
|
|
14
|
And then I proceeded to render some text using SDL + FreeType. It took
|
|
|
15
|
2 or 3 hours, never having used SDL _or_ FreeType. That includes
|
|
|
16
|
debugging various string-related segfaults in C. (Don't write to
|
|
|
17
|
statically allocated `char *msg = "...";` and don't use `strcmp` with
|
|
|
18
|
NULL pointers.)
|
|
|
19
|
|
|
|
20
|
It was fun! And hence, this little thing. You can even type something
|
|
|
21
|
yourself.
|
|
|
22
|
|
|
|
23
|
This is how it looks after those initial few hours:
|
|
|
24
|
|
|
|
25
|

|
|
|
26
|
|
|
|
27
|
And for everything else, see [`hello_sdl.c`](./hello_sdl.c). To run it
|
|
|
28
|
run `make` and then run `./hello_sdl`. Do not that you'll need a TTF
|
|
|
29
|
font from somewhere and then run it like this:
|
|
|
30
|
|
|
|
31
|
```
|
|
|
32
|
./hello_sdl /usr/share/fonts/TTF/DejaVuSerif.ttf
|
|
|
33
|
```
|
|
|
34
|
|
|
|
35
|
By default it wants `./FantasqueSansMono-Regular.ttf`, which you can get
|
|
|
36
|
from the `ttf-fantasque-sans-mono` package on ArchLinux.
|