cotis-raylib 0.1.0-alpha

Raylib-backed renderer for Cotis
Documentation

cotis-raylib

cotis-raylib is the raylib-backed desktop renderer for Cotis. It implements Cotis's CotisRenderer and CotisRendererAsync traits on top of raylib 6.x.

Status: Early 0.1.0-alpha release. APIs are still evolving alongside the core Cotis crates.

This repository contains the renderer backend only. It does not define layout or UI element configuration by itself. For a runnable desktop app, combine it with core Cotis crates, a layout engine, and a pipe from the ecosystem below.

Architecture

Each frame flows through five stages. This crate owns the renderer stage:

flowchart LR
    UI[UI_closure] --> LayoutMgr[CotisLayoutManager]
    LayoutMgr --> LayoutOut[RenderCommandOutput]
    LayoutOut --> Pipe[cotis-pipes]
    Pipe --> Renderer[RaylibRender]
  1. A layout manager prepares for the frame.
  2. UI code builds the element tree through the configurator API.
  3. The layout manager produces layout output items.
  4. A pipe transforms those items into renderer commands.
  5. RaylibRender draws the command stream through raylib.

Installation

Add the renderer and required core crates to your Cargo.toml:

cotis-raylib = "0.1.0-alpha"
cotis = "0.1.0-alpha"
cotis-defaults = "0.1.0-alpha"
cotis-utils = "0.1.0-alpha"
cotis-layout = "0.1.0-alpha"
cotis-pipes = "0.1.0-alpha"

The raylib crate links against native raylib libraries. On Linux you may need development packages for X11, OpenGL, and audio (for example libx11-dev, libxrandr-dev, libxi-dev, libgl1-mesa-dev, libasound2-dev).

Quick start

Clone this repository and run the basic example from the repository root:

git clone https://github.com/igna-778/cotis-raylib
cd cotis-raylib
cargo run -p cotis-raylib --example basic_example

That example opens a resizable window, lays out UI with cotis-layout and cotis-pipes, and renders through raylib.

Typical app wiring

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);

while !app.render().window_should_close() {
    app.compute_frame(|root| {
        // Build your UI tree here.
    });
}

Swap cotis-raylib for cotis-wgpu or another backend without changing layout or UI code.

Local examples

This repository ships runnable examples under cotis-raylib/examples/:

Example Command
basic_example cargo run -p cotis-raylib --example basic_example
circle_example cargo run -p cotis-raylib --example circle_example
gradients_example cargo run -p cotis-raylib --example gradients_example --features complex-color
gradients_example_solid cargo run -p cotis-raylib --example gradients_example_solid

Examples load assets from ./examples/ relative to the working directory (run from the repository root). The bundled Roboto font is licensed under the Apache License 2.0 (Google Fonts).

Ecosystem

Cotis is split across several repositories. This repo provides the raylib renderer; sibling repos provide core traits, layout, and pipes.

Repository Role
cotis Core traits and CotisApp orchestration
cotis-layout Flexbox-style layout engine (CotisLayoutManager)
cotis-pipes Layout output to render commands (CotisLayoutToRenderListPipeForGenerics)
cotis-wgpu Desktop renderer (wgpu + winit + glyphon)
cotis-raylib (this repo) Desktop renderer (raylib)
cotis-renderer-template Scaffold for authoring a custom render backend
cotis-cli Plugin host for installable build and run routines

Pick a renderer backend and swap it without changing layout or UI code. Use cotis-renderer-template to implement a new backend.

Features

Feature Effect
test-render Exposes the test_render module (RayTestRender) for scaled/headless-style testing
complex-color Enables gradient and layered fills (requires cotis-defaults/complex_color)

Documentation