Odin't Know That · Appendix C

Appendix C: Beyond the book, raylib's real strengths

Sköll deliberately used only raylib's shape and audio primitives, to keep the zero-assets promise and the focus on Odin. But raylib is a full 2D/3D games library, and the moment you want art, real fonts or a UI, it's all one call away, and already in your Odin install. Here's the map, with the call you'd reach for. See the cheatsheet and examples for the details.

Textures and sprites

tex := rl.LoadTexture("wolf.png")     // needs an image file (breaks zero-assets)
defer rl.UnloadTexture(tex)
rl.DrawTextureV(tex, pos, rl.WHITE)
// animation: draw a sub-rectangle of a sprite sheet
rl.DrawTextureRec(tex, {frame*fw, 0, fw, fh}, pos, rl.WHITE)

Swap the primitive wolf for a sprite sheet and drive the frame from p.anim. Textures live in GPU memory; load once, never per frame.

Real fonts (full Unicode text)

font := rl.LoadFontEx("font.ttf", 32, nil, 0)
defer rl.UnloadFont(font)
rl.DrawTextEx(font, "Sköll, Скёлл, スコル", pos, 32, 1, rl.WHITE)

This is the fix for the "default font is ASCII-ish" gotcha in Chapter 9, at the cost of shipping a .ttf.

raygui: immediate-mode UI

raylib ships a companion UI toolkit, raygui, bundled in the Odin distribution too:

import rl "vendor:raylib"
// gui procs live alongside; e.g. buttons, sliders, checkboxes for a settings screen

Perfect for an options menu, a volume slider, or a level editor, all in the same immediate-mode style.

Shaders

shader := rl.LoadShader(nil, "bloom.fs")
defer rl.UnloadShader(shader)
rl.BeginShaderMode(shader); /* draw */ ; rl.EndShaderMode()

Post-processing (bloom, CRT, colour grading) and per-object effects, written in GLSL.

A window icon (still generated, no file)

The one asset-adjacent touch that stays in the zero-assets spirit: build a small Image in memory and set it as the icon:

img := rl.GenImageColor(32, 32, rl.BLANK)
// ... draw into img with rl.ImageDraw* ...
rl.SetWindowIcon(img)
rl.UnloadImage(img)

3D

raylib is a 3D library too: rl.Camera3D, rl.DrawCube, rl.DrawModel, rl.LoadModel, and BeginMode3D/EndMode3D mirror the 2D API you already know. A natural next project.

Sound and music from files

Where synthesis (Chapter 10) isn't enough, rl.LoadSound("hit.wav") and rl.LoadMusicStream("theme.ogg") play audio files directly, the conventional path Sköll chose to avoid.