cotis-wgpu 0.1.0-alpha

Desktop wgpu renderer backend for Cotis
Documentation
# cotis-wgpu

`cotis-wgpu` is the desktop **wgpu renderer backend** for [Cotis](https://docs.rs/cotis). It implements Cotis's renderer traits on top of [wgpu](https://crates.io/crates/wgpu), [winit](https://crates.io/crates/winit), and [glyphon](https://crates.io/crates/glyphon), and can be used as a drop-in alternative to other Cotis backends such as `cotis-raylib`.

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

This repository contains the **renderer backend** only. A full desktop application also needs core Cotis crates, a layout engine, and a pipe from the [ecosystem](#ecosystem) below.

## Architecture

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

```mermaid
flowchart LR
    UI[UI_closure] --> LayoutMgr[CotisLayoutManager]
    LayoutMgr --> LayoutOut[RenderCommandOutput]
    LayoutOut --> Pipe[cotis-pipes]
    Pipe --> Renderer[CotisWgpuRenderer]
```

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. `CotisWgpuRenderer` draws the command stream through wgpu.

## Installation

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

```toml
cotis-wgpu = "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"
```

## Quick start

Clone this repository and run the shipped example:

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

The example opens a resizable window, lays out UI with `cotis-layout` and `cotis-pipes`, and renders rectangles, borders, and text through wgpu.

### Typical app wiring

```rust
use cotis::cotis_app::CotisApp;
use cotis_layout::preamble::CotisLayoutManager;
use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;
use cotis_utils::math::Dimensions;
use cotis_wgpu::prelude::*;

let renderer = CotisWgpuRenderer::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-wgpu` for [`cotis-raylib`](https://github.com/igna-778/cotis-raylib) or another backend without changing layout or UI code.

## Ecosystem

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

| Repository | Role |
|------------|------|
| [`cotis`]https://github.com/igna-778/cotis | Core traits and `CotisApp` orchestration |
| [`cotis-layout`]https://github.com/igna-778/cotis-layout | Flexbox-style layout engine (`CotisLayoutManager`) |
| [`cotis-pipes`]https://github.com/igna-778/cotis-pipes | Layout output to render commands (`CotisLayoutToRenderListPipeForGenerics`) |
| [**cotis-wgpu**]https://github.com/igna-778/cotis-wgpu (this repo) | Desktop renderer (wgpu + winit + glyphon) |
| [`cotis-raylib`]https://github.com/igna-778/cotis-raylib | Desktop renderer (raylib) |
| [`cotis-renderer-template`]https://github.com/igna-778/cotis-renderer-template | Scaffold for authoring a custom render backend |
| [`cotis-cli`]https://github.com/igna-778/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 |
|---------|--------|
| `complex-color` | Enables `ColorLayer` types from cotis-defaults; gradients are not rendered (solid/layered fallback only) |

### Known limitations

- **Gradients**`complex-color` is supported, but gradient layers fall back to solid or layered colors.
- **Images**`Image` commands render as colored placeholder rectangles (no texture sampling yet).
- **Alpha blending** — limited support; see crate rustdoc for details.

## Documentation

- API reference: `cargo doc --open -p cotis-wgpu`
- Published docs: [cotis-wgpu]https://docs.rs/cotis-wgpu
- Core crate docs: [cotis]https://docs.rs/cotis, [cotis-defaults]https://docs.rs/cotis-defaults, [cotis-utils]https://docs.rs/cotis-utils