WSG Examples
The examples are organized into four category folders, one per theme. Each
folder has its own README.md documenting its examples in detail (what they
demonstrate, how to run them, keyboard controls, what to observe).
| Folder | Theme | Examples |
|---|---|---|
| meshes/ | Geometry, materials, file import, low-level workflow | simple, cube, pbr, import, manual |
| lights/ | Light types, shadow mapping, emissive materials | shadow, shadow_test, spot_test, emissive |
| cameras/ | Camera-driven rendering (frustum culling) | culling |
| effects/ | HDR, tone mapping, post-process, full showcase | demo, bloom, hdr, msaa, fog, dof |
Running an example
Example names are stable — from the repo root:
cargo run -p wsg-lib --example <name>
Examples gated behind a Cargo feature need the feature too:
cargo run -p wsg-lib --example import --features import-obj
All examples are self-contained: procedural textures, hard-coded geometries,
no on-disk assets. All use the declarative API (AppBuilder + AppHandler)
except manual, which demonstrates the low-level workflow instead.
Where do the files live? Examples live in subfolders (
examples/<folder>/<name>.rs). Cargo only auto-discovers top-levelexamples/*.rs, so every example is declared explicitly inlib/Cargo.tomlwith itspath. This keeps--example <name>working while allowing the folder organization.
Suggested learning path
simple— the minimal declarative workflow (flat unlit quad, ~15 lines)cube— the 3D MVP: a textured, lit, spinning cubepbr— PBR materials and normal mappingspot_test,shadow_test— isolated light and shadow behaviorhdr→emissive→bloom— the HDR chain, step by stepculling— GPU-driven frustum cullingdemo— everything combinedmanual— what theAppfacade actually encapsulates
Adding your own example
- Create
lib/examples/<folder>/my_example.rs(pick the matching category; add a new folder + README if needed). - Declare it in
lib/Cargo.toml(Cargo won't discover it otherwise):[[example]] name = "my_example" path = "examples/<folder>/my_example.rs" - Keep it self-contained: procedural textures, hard-coded geometries, no external assets.
- Document it in the folder's
README.md(and indocs/user/examples.md).