Expand description
Raylib-backed renderer for the Cotis UI ecosystem.
cotis-raylib implements Cotis’s CotisRenderer and CotisRendererAsync traits
(from cotis::renders) on top of raylib 6.x.
It is the primary render backend used by cotis-layout examples.
§Quick start
For interactive applications, create a crate::renderer::RaylibRender and wire it into
CotisApp (from cotis::cotis_app) with a layout manager and pipe:
use cotis::cotis_app::CotisApp;
use cotis_layout::preamble::CotisLayoutManager;
use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;
use cotis_raylib::prelude::RaylibRender;
use cotis_utils::math::Dimensions;
let renderer = RaylibRender::auto_start();
let manager = CotisLayoutManager::new(Dimensions::new(1000.0, 800.0));
let mut app = CotisApp::new(renderer, manager, CotisLayoutToRenderListPipeForGenerics);
// app.compute_frame(...);
// while !app.render().window_should_close() { ... }Shipped examples use crate::renderer::RaylibRender directly (not RayTestRender from the
test_render module). Run from the repository root:
cargo run -p cotis-raylib --example basic_example§Recommended imports
Use prelude for the common entry-point types:
use cotis_raylib::prelude::{PathBasedImage, RaylibRender, RayRenderHandle};§Rendering model
crate::renderer::RaylibRender draws two kinds of command streams:
cotis_defaults::render_commands::render_t_list::RenderTList— typed heterogeneous command lists produced by layout pipes. Images are preloaded into the renderer cache before drawing.Box<dyn crate::drawables::RaylibDrawable>— custom drawables; implementcrate::drawables::RaylibDrawablefor types not covered bycotis-defaultscommands.
Extend drawing with crate::drawables::RaylibDrawable::scale_by (used by RayTestRender when the
test-render feature is enabled) and crate::drawables::RaylibDrawable::preload_generic_images
for path-based images.
§Images
Path-based assets use crate::cotis_defaults_images::PathBasedImage (or JPEGImage, PNGImage,
SVGImage from cotis_defaults::generic_image).
crate::renderer::RaylibRender::translate_generic_image loads textures into an internal cache
keyed by file path. SVGImage is a semantic path tag only — raylib loads raster data from the path;
true vector SVG rendering is not implemented.
§Fonts
Call crate::renderer::RaylibRender::load_font_and_keep or
crate::renderer::RaylibRender::load_font_ex_and_keep at startup.
The returned ID (0-based, assigned in load order) is stored in TextConfig::font_id
(cotis_defaults::element_configs::text_config::TextConfig).
Additional pixel sizes are loaded lazily at the start of each frame.
§Features
| Feature | Effect |
|---|---|
test-render | Exposes the test_render module for scaled/headless-style testing. |
complex-color | Enables gradient and layered fills (requires cotis-defaults/complex_color). |
§Thread safety
The raylib handle is wrapped in Arc<Mutex<RayRenderHandle>> (crate::renderer::RayRenderHandle)
so it can be shared for input polling. RaylibThread (from the raylib crate) is owned by
crate::renderer::RaylibRender and must be used for drawing on the thread that created the window.
All mutex locks panic if the mutex is poisoned.
§When to use RayTestRender
With the test-render feature, RayTestRender wraps crate::renderer::RaylibRender to render at a logical resolution while keeping a smaller physical
window (dimensions / scale). Use it for CI snapshots and headless-style tests — not as the default
for interactive applications.
Modules§
- cotis
- Cotis context trait implementations for
crate::renderer::RaylibRender. - cotis_
defaults_ images - Path-based image types for raylib texture loading.
- drawables
- Raylib draw implementations for
cotis-defaultsrender commands and custom drawables. - fonts
- Font loading and lazy size management for raylib text drawing.
- functions_
raylib - Text measurement helpers for layout integration.
- interactivity
- Input polling: maps raylib keyboard/mouse state to
cotis-utilsinteractivity traits. - prelude
- Convenient re-exports for application code.
- raylib_
images - Image loading traits and texture cache integration for
crate::renderer::RaylibRender. - renderer
- Raylib window renderer and handle types.
- text
- Text measurement type aliases.