diff --git a/examples/app/headless_renderer.rs b/examples/app/headless_renderer.rs index 2b6b23b706..2038c85a29 100644 --- a/examples/app/headless_renderer.rs +++ b/examples/app/headless_renderer.rs @@ -1,11 +1,16 @@ -//! This example illustrates how to make headless renderer -//! derived from: -//! It follows this steps: +//! This example illustrates how to make a headless renderer. +//! Derived from: +//! It follows these steps: +//! //! 1. Render from camera to gpu-image render target //! 2. Copy from gpu image to buffer using `ImageCopyDriver` node in `RenderGraph` //! 3. Copy from buffer to channel using `receive_image_from_buffer` after `RenderSystems::Render` //! 4. Save from channel to random named file using `scene::update` at `PostUpdate` in `MainWorld` //! 5. Exit if `single_image` setting is set +//! +//! If your goal is to capture a single “screenshot” as opposed to every single rendered frame +//! without gaps, it is simpler to use [`bevy::render::view::window::screenshot::Screenshot`] +//! than this approach. use bevy::{ app::{AppExit, ScheduleRunnerPlugin}, @@ -86,6 +91,9 @@ fn main() { // replaces the bevy_winit app runner and so a window is never created. .set(WindowPlugin { primary_window: None, + // Don’t automatically exit due to having no windows. + // Instead, the code in `update()` will explicitly produce an `AppExit` event. + exit_condition: bevy::window::ExitCondition::DontExit, ..default() }) // WinitPlugin will panic in environments without a display server.