Add a UI lesson — TTF parsing, font rasterization, immediate-mode UI controls, layout
Create a new UI lesson teaching how to build an immediate-mode UI system from scratch — font parsing, text rasterization, layout, and interactive controls.
UI lessons produce CPU-side data (textures, vertices, indices, UVs) that a separate GPU lesson will later render. The UI library itself contains no GPU code — it is a pure data-generation layer.
When to use this skill:
Smart behavior:
The user (or you) can provide:
If any are missing, infer from context or ask.
common/ui/: Does relevant library code already exist?lessons/ui/NN-topic-name/
main.c)A focused C program that demonstrates the UI concept by producing data and
verifying it. UI lesson programs must write BMP images as their primary
visual output. These images are committed to assets/ and embedded in the
README so readers see results immediately. Programs typically:
Requirements:
#include "math/forge_math.h" for vec2/rect math,
#include "ui/forge_ui.h" for UI types (once the library exists)Template structure:
/*
* UI Lesson NN — Topic Name
*
* Demonstrates: [what this shows]
*
* SPDX-License-Identifier: Zlib
*/
#include <SDL3/SDL.h>
#include "math/forge_math.h"
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
if (!SDL_Init(0)) {
SDL_Log("SDL_Init failed: %s", SDL_GetError());
return 1;
}
/* Demonstrate the UI concept here */
SDL_Quit();
return 0;
}
Console output formatting:
-, =, *, |, ->, [OK], [!], "px", "glyph", "atlas"─, ═, •, ↓, →, ✓, ⚠ (may render as garbled text on
Windows)CMakeLists.txtadd_executable(NN-topic-name main.c)
target_include_directories(NN-topic-name PRIVATE ${FORGE_COMMON_DIR})
target_link_libraries(NN-topic-name PRIVATE SDL3::SDL3)
if(TARGET SDL3::SDL3-shared)
add_custom_command(TARGET NN-topic-name POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL3::SDL3-shared>
$<TARGET_FILE_DIR:NN-topic-name>
)
endif()
Adapt as needed: Later lessons may link against a shared UI library
(common/ui/) once it exists.
README.mdStructure:
# UI Lesson NN — Topic Name
[Brief subtitle explaining what this teaches]
## What you'll learn
[Bullet list of UI concepts covered]
## Why this matters
[1-2 paragraphs connecting this topic to real game/tool UI development.
Explain when and why a developer will need this.]
## Result
[Brief description of what the example program produces]
[Embed PNG images generated by the program. The program writes BMP files
(no libpng dependency needed in C), so convert them to PNG before committing.
Copy the PNGs to the lesson's `assets/` directory and reference them with
``. Use tables to show multiple images side by