Zevy Raylib is an integration layer that connects the Zevy ECS with the Raylib game library. It provides input handling, asset loading utilities, GUI components, and a plugin system to register common engine features easily.
- Zig 0.15.1
Zevy Raylib is a small library that wires the Raylib runtime into a Zevy ECS-based app. It handles window creation, input harvesting, asset management and sets up RayGui-based UI systems over the Zevy scheduler.
Examples can be ran with:
zig build examplesWarning
This library and its APIs are experimental. They are intended as a convenient integration layer for example apps and prototypes. The API and internal behavior can and will change without backward compatibility guarantees. Tests and cross-platform coverage are limited — treat this as a development-ready library, not production-ready. Please open issues or submit PRs if you rely on features that should be stabilized or suggested.
The input layer provides the following:
InputManager— the main runtime service that polls raylib for input state and dispatches events.InputBindingsandInputBinding— mapping action names to input chords.- Input types and helpers (keyboard, mouse, touch, gesture, and gamepads).
InputManager is designed to be added to the ECS via the InputPlugin and optionally polled directly from systems. It supports event handlers and action checking API:
isActionActive("action_name")— check if action is currently activewasActionTriggered("action_name")— check a press event this frameaddEventHandler— subscribe to input events
Input bindings, chords, and actions are declared with types located inside the input folder. Use the InputBindings helper to create action mappings from keyboard/mouse/gamepad/touch inputs.
The IO module provides a powerful AssetManager<T, Loader> generator for loading and tracking assets.
Use AssetManager to queue asset loads and process them in a separate step. It validates asset paths (supports builtin embedded:// scheme), manages unload, and stores assets in a string-to-entry map.
Useful methods:
loadAsset(file, settings)— queue asset for asynchronous loadingloadAssetNow(file, settings)— load asset immediatelyprocess()— perform a single step of queued loadersunloadAsset(handle)— release a loaded asset
The system supports schemes (for embedded:// content or custom resolvers) and allows custom loaders via AssetLoader and AssetUnloader wrappers.
Zevy Raylib exposes a RayGui-based GUI layer tied to the Zevy scheduler.
src/gui/ui.zig— exportscomponents,layout,renderer, andsystemssrc/gui/*— UI primitives, layout engines (flex, grid, anchor, dock), render systems
The RayGuiPlugin registers a GuiStage and several systems:
- uiInputSystem — maps engine input to GUI events
- flexLayoutSystem / gridLayoutSystem / anchorLayoutSystem / dockLayoutSystem — layout pass
- uiRenderSystem — draws the UI after the normal draw stage
Examples are available in src/gui/examples.zig and unit tests in src/gui/ui_tests.zig and src/gui/ui_render_tests.zig.
The embed module exposes helpers to include binary assets in the compiled artifact. See embed.zig in src/builtin. Use embedded:// URIs with the asset manager to reference compiled-in assets.
src/builtin/embed.zig— helper utilities
Zevy Raylib defines several convenience plugins that register and configure services with the Zevy ECS system.
src/app.plugin.zig— Raylib application and RayGui pluginsrc/assets.plugin.zig— assets resource (wrapsio.Assets)src/input.plugin.zig— registersInputManagerand the input system
Provides:
- Window creation (
rl.initWindow) with title, width, height - Audio device initialization (
rl.initAudioDevice) - Logging of the window and audio state
- Cleaning up in
deinit(close audio and window)
Usage example:
try plugs.add(RaylibPlugin, RaylibPlugin{ .title = "My App", .width = 800, .height = 600 });Wires RayGui into the Zevy scheduler and adds UI systems to a GuiStage. The plugin registers the UI systems and the uiRenderSystem into the drawing stage.
Creates and registers io.Assets in the ECS as a resource so your systems can call loadAsset and process through the io API.
Registers the InputManager resource and attaches an input update system that polls device state and emits events each frame.
src/input/tests.zig— Input unit tests*_tests.zig— IO tests for asset managers and loaders
Some tests are ommitted on Debug builds. To test all use -Doptimize=Release(Safe/Small/Fast).
- Follow existing Zig patterns
- Register new plugins in
src/root.zigby adding them toplug() - Add unit tests beside features in the
src/*directory. Prefer tests to be named*_tests.zig.