Examples
More than 400 small programs that each show one part of the NEO engine, grouped by category, with what each one shows and the command that runs it.
On this page
The engine source comes with more than 400 examples: small, self-contained programs that each show one part of the engine, from printing "Hello, World!" to a full PBR scene. Each one is a single Rust file you can read, run and change. They are the quickest way to see how an API is meant to be used.
The pages below list every example by category, with what it shows, whether it also runs in a browser, and the command that runs it.
Run an example#
The examples live in the engine core's own Cargo workspace, under examples/. From that folder of the engine source (the one that holds the neo crate's Cargo.toml):
cargo run --example hello_world
cargo run --release --example breakout # optimised: smoother, slower to compileThe first build compiles the whole engine and takes a few minutes; later runs only rebuild the example. Every example's source starts with a comment saying what it shows, and the file is at the path its category page names it by, for example examples/games/breakout.rs.
Some examples need extra cargo features, and the Run column includes them:
cargo run --example fps_overlay --features neo_dev_tools,render_dev_toolsSeveral of those features (neo_feathers, free_camera, neo_dev_tools and others) aren't on in NEO's game builds. Running an example with them is fine; using the same thing in a game means turning the feature on for the game too. See Cargo features.
On Linux, pick a display server with --features x11 or --features wayland if the default doesn't open a window.
Run an example in a browser#
Examples marked Web: Yes also run as WebAssembly with WebGL 2. The workspace has a helper that builds one and writes the page's files to examples/wasm/:
rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli --version <the version in Cargo.lock>
cargo run -p build-wasm-example -- --api webgl2 breakoutThen serve the examples/wasm folder with any static web server and open it. --debug builds without optimisations, --features a,b adds cargo features, and --api webgpu builds for WebGPU instead, which NEO's own web builds don't use. To package a whole game for the browser, see Web builds.
Categories#
| Category | Examples | What they cover |
|---|---|---|
| 2D rendering | 29 | Sprites, 2D meshes and shapes, 2D cameras and 2D post-processing. |
| 3D rendering | 62 | Meshes, materials, lights, shadows, the environment, post-processing and anti-aliasing. |
| Animation | 13 | Clips, graphs, masks, morph targets, easing and animated properties. |
| Application | 19 | Plugins, runners, headless apps, exiting, logging and settings. |
| Assets | 18 | Loading, asset events, custom assets and loaders, sources, saving and processing. |
| Async tasks | 3 | Work on the task pools. |
| Audio | 8 | Sounds, music, playback control and spatial audio. |
| Camera | 9 | Projections, viewports, controllers and following a target. |
| Dev tools | 4 | The FPS overlay, the infinite grid, schedule data and the inspector. |
| Diagnostics | 3 | Frame time and your own diagnostics. |
| ECS | 35 | Entities, components, systems, queries, messages, observers, hooks, relationships and schedules. |
| Games | 7 | Small complete games: Breakout, a minesweeper, a game menu and a loading screen. |
| Gizmos | 9 | Debug drawing in 2D and 3D. |
| glTF | 9 | glTF scenes, meshes, materials and extensions. |
| Input | 12 | Keyboard, mouse, gamepads, touch, text input and IME. |
| Math | 6 | Primitives, bounding volumes, curves, sampling and ray casts. |
| Picking | 7 | Pointer events on meshes, sprites and UI. |
| Reflection | 10 | Runtime type information, the type registry and serialization. |
| Remote protocol | 4 | Inspecting and controlling a running app from outside. |
| Scene | 2 | Saving a world as a scene and spawning it back. |
| Shaders | 31 | Custom materials, shader defs, post-processing passes and compute shaders. |
| State | 4 | States, sub-states, computed states and custom transitions. |
| Stress tests | 19 | Heavy workloads for measuring performance. |
| Time | 3 | Time, virtual time, timers and the fixed timestep. |
| Transforms | 5 | Moving, rotating and scaling, and the hierarchy. |
| UI | 66 | Layout, text, images, buttons, scrolling, focus and widgets. |
| Window | 11 | Window settings, multiple windows, cursors and screenshots. |
| Other | 8 | Usage patterns, fixed-timestep movement, small tools and a no_std library. |
Examples in NEO's own crates#
NEO's gameplay crates have examples of their own, run with -p from the engine source's root workspace rather than from the engine core's. For example, the gameplay kit's third-person character:
cargo run -p neo_gameplay_kit --example third_personSee Gameplay kit.