Skip to content

[Feature] Organize demos into dedicated crates #169

Description

@vmarcella

Overview

Reorganize the existing examples from crates/lambda-rs/examples/ into a
dedicated demos/ directory at the repository root. Demo crates will be
included in the main workspace members but excluded from default-members,
so they are not built by default but remain accessible via -p flag. This
structure enables better feature flag management per demo category, cleaner
build configurations, and a more scalable approach for showcasing engine
capabilities.

Current State

Examples currently reside in crates/lambda-rs/examples/ as individual .rs
files:

crates/lambda-rs/examples/
├── audio_sine_wave.rs
├── immediates.rs
├── indexed_multi_vertex_buffers.rs
├── instanced_quads.rs
├── minimal.rs
├── offscreen_post.rs
├── play_slash_sound.rs
├── reflective_room.rs
├── sound_buffer_load.rs
├── textured_cube.rs
├── textured_quad.rs
├── triangle.rs
├── triangles.rs
└── uniform_buffer_triangle.rs

This flat structure has several limitations:

  • All examples share the same Cargo feature configuration
  • No separation between audio, rendering, and other demo categories
  • Difficult to enable feature flags selectively per demo type
  • Examples must be run via cargo run --example <name> -p lambda-rs

Scope

Goals:

  • Create a demos/ directory at the repository root
  • Organize demos into domain-specific crates (e.g., demos/audio/,
    demos/render/, demos/minimal/)
  • Configure appropriate feature flags per demo crate
  • Add demo crates to workspace members but exclude from default-members
  • Maintain backward compatibility by keeping minimal examples in
    crates/lambda-rs/examples/ for documentation purposes
  • Provide clear README documentation for running demos

Non-Goals:

  • Creating new demos (existing examples will be migrated)
  • Modifying the core lambda-rs or lambda-rs-platform APIs
  • Automated demo testing infrastructure (can be addressed separately)

Proposed API

demos/
├── README.md            # Documentation for running demos
├── audio/
│   ├── Cargo.toml       # [features] audio-specific flags
│   └── src/
│       └── bin/
│           ├── sine_wave.rs
│           ├── play_sound.rs
│           └── sound_buffer.rs
├── render/
│   ├── Cargo.toml       # [features] render-validation, etc.
│   └── src/
│       └── bin/
│           ├── triangle.rs
│           ├── triangles.rs
│           ├── immediates.rs
│           ├── indexed_multi_vertex_buffers.rs
│           ├── instanced_quads.rs
│           ├── textured_quad.rs
│           ├── textured_cube.rs
│           ├── uniform_buffer_triangle.rs
│           ├── offscreen_post.rs
│           └── reflective_room.rs
└── minimal/
    ├── Cargo.toml       # Minimal dependencies
    └── src/
        └── bin/
            └── minimal.rs

Example demos/render/Cargo.toml:

[package]
name = "lambda-demos-render"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
lambda-rs = { path = "../../crates/lambda-rs" }

[features]
default = []
validation = ["lambda-rs/render-validation"]
validation-strict = ["lambda-rs/render-validation-strict"]

[[bin]]
name = "triangle"
path = "src/bin/triangle.rs"

[[bin]]
name = "textured_quad"
path = "src/bin/textured_quad.rs"

# ... additional binaries

Root Cargo.toml changes:

[workspace]
resolver = "2"

members = [
  "crates/lambda-rs",
  "crates/lambda-rs-args",
  "crates/lambda-rs-logging",
  "crates/lambda-rs-platform",
  "tools/obj_loader",
  "tools/lambda_audio",
  # Demo crates included in workspace but not built by default
  "demos/audio",
  "demos/render",
  "demos/minimal",
]

default-members = [
  "crates/lambda-rs",
  "crates/lambda-rs-args",
  "crates/lambda-rs-logging",
  "crates/lambda-rs-platform",
  "tools/obj_loader",
]

Running demos:

# Run a render demo with default features
cargo run -p lambda-demos-render --bin triangle

# Run with validation enabled
cargo run -p lambda-demos-render --bin triangle --features validation

# Run an audio demo
cargo run -p lambda-demos-audio --bin sine_wave

Acceptance Criteria

Acceptance Criteria

  • demos/ directory created at repository root
  • demos/audio/ crate with migrated audio examples
  • demos/render/ crate with migrated rendering examples
  • demos/minimal/ crate with basic window example
  • Each demo crate has appropriate feature flags configured
  • Root Cargo.toml updated: demo crates added to members, excluded from
    default-members
  • cargo build does not build demos by default
  • cargo build -p lambda-demos-render builds only the render demos
  • demos/README.md documents how to build and run demos
  • Existing crates/lambda-rs/examples/ simplified to minimal reference
    examples for rustdoc
  • All migrated demos compile and run successfully

Affected Crates

lambda-rs

Notes

  • Demo crates should use publish = false to prevent accidental publishing
  • Excluding demos from default-members keeps cargo build --workspace fast
    while still allowing cargo build -p <demo-crate> access
  • Consider adding a demos/shared/ crate if common utilities emerge
  • Feature flags in demo crates should mirror high-level lambda-rs features
  • This structure aligns with patterns used in wgpu and bevy repositories
  • Future demos (physics, UI, etc.) can follow the same pattern

Activity

  1. self-assigned this
    on Feb 3, 2026
  2. added
    enhancement
    lambda-rs
    audio
    on Feb 3, 2026
  3. added theissue type on Feb 3, 2026
  4. added
    good first issue
    and removed
    audio
    on Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementgood first issuelambda-rs

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions