pub struct RenderAgent { /* private fields */ }Expand description
The agent responsible for managing the state and logic of the rendering pipeline.
It orchestrates the various systems and lanes involved in preparing and
translating scene data from the ECS into a format consumable by the low-level
RenderSystem.
Implementations§
Source§impl RenderAgent
impl RenderAgent
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new RenderAgent with default lanes and automatic strategy selection.
Sourcepub fn with_strategy(strategy: RenderingStrategy) -> Self
pub fn with_strategy(strategy: RenderingStrategy) -> Self
Creates a new RenderAgent with the specified rendering strategy.
Sourcepub fn add_lane(&mut self, lane: Box<dyn RenderLane>)
pub fn add_lane(&mut self, lane: Box<dyn RenderLane>)
Adds a custom render lane to the available lanes.
Sourcepub fn set_strategy(&mut self, strategy: RenderingStrategy)
pub fn set_strategy(&mut self, strategy: RenderingStrategy)
Sets the rendering strategy.
Sourcepub fn strategy(&self) -> RenderingStrategy
pub fn strategy(&self) -> RenderingStrategy
Returns the current rendering strategy.
Sourcepub fn select_lane(&self) -> &dyn RenderLane
pub fn select_lane(&self) -> &dyn RenderLane
Selects the appropriate render lane based on the current strategy.
Sourcepub fn prepare_frame(
&mut self,
world: &mut World,
cpu_meshes: &Assets<Mesh>,
graphics_device: &dyn GraphicsDevice,
)
pub fn prepare_frame( &mut self, world: &mut World, cpu_meshes: &Assets<Mesh>, graphics_device: &dyn GraphicsDevice, )
Prepares all rendering data for the current frame.
This method runs the entire Control Plane logic for rendering:
- Prepares GPU resources for any newly loaded meshes.
- Extracts all visible objects from the ECS into the internal
RenderWorld.
Sourcepub fn render(
&mut self,
world: &mut World,
cpu_meshes: &Assets<Mesh>,
graphics_device: &dyn GraphicsDevice,
materials: &RwLock<Assets<Box<dyn Material>>>,
encoder: &mut dyn CommandEncoder,
render_ctx: &RenderContext<'_>,
)
pub fn render( &mut self, world: &mut World, cpu_meshes: &Assets<Mesh>, graphics_device: &dyn GraphicsDevice, materials: &RwLock<Assets<Box<dyn Material>>>, encoder: &mut dyn CommandEncoder, render_ctx: &RenderContext<'_>, )
Renders a frame by preparing the scene data and encoding GPU commands.
This is the main rendering method that orchestrates the entire rendering pipeline:
- Calls
prepare_frame()to extract and prepare all renderable data - Calls
produce_render_objects()to build the RenderObject list with proper pipelines - Delegates to the selected render lane to encode GPU commands
§Arguments
world: The ECS world containing scene datacpu_meshes: The cache of CPU-side mesh assetsgraphics_device: The graphics device for GPU resource creationmaterials: The cache of material assetsencoder: The command encoder to record GPU commands intocolor_target: The texture view to render into (typically the swapchain)clear_color: The color to clear the framebuffer with
Sourcepub fn produce_render_objects(
&self,
materials: &RwLock<Assets<Box<dyn Material>>>,
) -> Vec<RenderObject>
pub fn produce_render_objects( &self, materials: &RwLock<Assets<Box<dyn Material>>>, ) -> Vec<RenderObject>
Translates the prepared data from the RenderWorld into a list of RenderObjects.
This method should be called after prepare_frame. It reads the intermediate
RenderWorld and produces the final, low-level data structure required by
the RenderSystem.
This logic uses the render lane to determine the appropriate pipeline for each material, then builds the RenderObjects list.
§Arguments
materials: The cache of material assets for pipeline selection
Sourcepub fn extract_camera_view(&self, world: &World) -> ViewInfo
pub fn extract_camera_view(&self, world: &World) -> ViewInfo
Extracts the active camera from the ECS world and generates a ViewInfo.
This method queries the ECS for entities with both a Camera and GlobalTransform
component, finds the first active camera, and constructs a ViewInfo containing
the camera’s view and projection matrices.
§Arguments
world: The ECS world containing camera entities
§Returns
A ViewInfo containing the camera’s matrices and position. If no active camera
is found, returns a default ViewInfo with identity matrices.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RenderAgent
impl !RefUnwindSafe for RenderAgent
impl Send for RenderAgent
impl Sync for RenderAgent
impl Unpin for RenderAgent
impl !UnwindSafe for RenderAgent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().