$ show love2d/love
LÖVE (love2d/love) is a cross-platform 2D game engine and framework. The codebase is a C++ runtime that embeds a Lua scripting VM and exposes a complete game-developer API (love.graphics, love.audio, love.physics, love.filesystem, love.math, love.window, etc.) used to build and ship games. The main executable (src/love.cpp) bootstraps a Lua state, loads src/modules/love/boot.lua, and runs the standard game loop defined in callbacks.lua (love.load/update/draw). In production this engine packages .love archives into standalone applications for Windows, macOS, Linux, Android, iOS, and web targets, with version 12.0 "Bestest Friend" currently defined in src/common/version.h. Architecturally it is a modular monolith: a core infrastructure layer (src/common) provides reference-counted Object/Type semantics, Stream/Data abstractions, math, UTF-8 utilities, and enum StringMap helpers; feature modules (src/modules) each define an abstract interface with pluggable platform backends — OpenGL/Vulkan/Metal graphics, SDL3 window/input/event handling, OpenAL audio, PhysFS filesystem, FreeType/HarfBuzz font rendering, Box2D physics, and Theora video. Lua bindings are hand-written via a consistent luax_* convention in wrap_*.cpp files. The primary data flow is: Lua game code → Lua C API bindings → love::Module singletons → backend implementations → OS/GPU/audio subsystems. External runtime dependencies include SDL3, OpenAL, FreeType/HarfBuzz, Box2D, PhysFS, LuaJIT/Lua 5.1/5.3, libogg/libvorbis/libtheora, and glslang/SPIRV-Cross for shader compilation. Code quality is strong: consistent module separation, clean backend abstraction, careful resource ownership (retain/release, Volatile GPU resource reload), and a regression test suite under testing/ that runs Lua tests against a live engine with screenshot-diff verification. Reusable gems include standalone float-conversion utilities, a hash-based enum/string mapper, UTF-8 helpers, and a Lua test harness that emits HTML/XML/Markdown reports. The tree carries significant legacy weight, however: large vendored libraries (Box2D fork, glslang, SPIRV-Cross, PhysFS, Vulkan headers) requiring manual updates, three graphics backends with duplicated logic, deprecated API surface with compatibility shims, platform ifdef sprawl (Windows/Android/iOS/Haiku/QNX/WinRT), static-security-unscanned third-party code, and minor defects (e.g., an uninitialized bool in the WinINet client). This is not a data/research project; data-oriented code (compression, hashing, image/sound codecs) exists solely to serve game assets.
The LLM identified 5 files worth highlighting for reuse:
Converts between 32-bit floats and the half (16-bit), 10-bit, and 11-bit float formats used by GPU vertex and texture formats. Fully self-contained with no internal dependencies, making it trivially extractable to any graphics, audio, or geometry project. Demonstrates careful, non-obvious bit-level handling of rounding, precision, and special values.
Generic compile-time hash-based bidirectional mapping between C++ enums and their string names, used to convert Lua strings to engine constants across physics, audio, graphics, and filesystem modules. Self-contained header template that replaces fragile switch/if chains with O(1) string lookup; usable in any C++ project needing string-to-enum and enum-to-string conversion.
Self-contained UTF-8 decode/encode/validation utilities (codepoint counting, byte-length calculation, encoding/decoding) used for Lua string interop and font shaping. No external dependencies; extractable into any C or C++ project needing robust UTF-8 handling without pulling in ICU or a heavy text library.
Tessellates polylines into renderable vertex strips with configurable join styles (miter with miter-limit clamping, bevel, none) and line caps. Implements non-obvious 2D geometry algorithms for join clamping and vertex generation against a minimal vertex abstraction. The core math is self-contained and portable; only the vertex output structure requires adaptation when reusing in another rendering stack.
A class-based Lua test framework that discovers and runs love.test.* modules, tracks pass/fail/skip status, and generates HTML, XML (JUnit-style), and Markdown reports from a single run. It also supports screenshot-based output comparison against expected images for graphics regression testing. Self-contained and portable — the harness pattern could be extracted to test any Lua-embedded application, not just LÖVE.