pub struct Presenter {
render: Option<Entity>,
renderer: Entity,
scene_pass: Entity,
blit: Option<Blit>,
surface: WindowSurface,
attachments: FrameAttachments,
target: Option<PersistentTarget>,
pub fallback_size: (u32, u32),
}Expand description
Everything needed to render a frame and present it.
The presenter is a component of its own entity, built by
build_presenter: everything it holds arrives after the GPU request
resolves, and a component set fixed at spawn has no room for that.
Fields§
§render: Option<Entity>§renderer: Entity§scene_pass: Entity§blit: Option<Blit>§surface: WindowSurface§attachments: FrameAttachments§target: Option<PersistentTarget>§fallback_size: (u32, u32)The size used until the window reports its own.
Implementations§
Source§impl Presenter
impl Presenter
Sourcepub fn present(&mut self, host: &World) -> Result<(), PresenterError>
pub fn present(&mut self, host: &World) -> Result<(), PresenterError>
Draw the frame’s result into the swap chain and present it.
The presenting pass parks first and takes the frame’s view only after the swap chain image has been acquired. Between the two, and after the image has been presented and destroyed, the pass states no attachment – so a frame rendered by anything other than this loop, an MCP tool’s screenshot of the scene, skips the pass rather than recording into a dead swap-chain image.
A surface released by Self::release is opened again here, so a host
that suspended only has to keep presenting.
§Errors
Returns an error when the render world’s renderer or its resources
are gone, or the window can no longer back a surface. A render
sub-world that is gone presents nothing and returns Ok.
Sourcepub fn resize(
&mut self,
host: &World,
size: (u32, u32),
) -> Result<(), PresenterError>
pub fn resize( &mut self, host: &World, size: (u32, u32), ) -> Result<(), PresenterError>
Match the surface, the swap-chain attachments and the offscreen target to a new size.
The surface resizes first and reports the size it ended up with; the swap chain’s attachments follow it, and the offscreen target is rebuilt for that size. The target’s texture and view are replaced in place – their resource nodes keep their ids – so the blit reading the view rebuilds its bind group through its own dependency, without the presenter touching the source.
§Errors
Returns an error when the render world or its resources are gone.
Sourcepub fn release(&mut self, host: &World) -> Result<(), PresenterError>
pub fn release(&mut self, host: &World) -> Result<(), PresenterError>
Drop the swap chain the platform is about to invalidate, keeping everything the scene drew from.
The presenting pass parks first: it still names a view of the swap chain, and that id is what keeps the view alive – parking it drops the view, so the view goes with the surface this release collects. The scene keeps its state and presents again through a surface built from the same window.
§Errors
Returns an error when the render world or its renderer is gone.
Auto Trait Implementations§
impl !Freeze for Presenter
impl !RefUnwindSafe for Presenter
impl !UnwindSafe for Presenter
impl Forget for Presenter
impl Send for Presenter
impl Sync for Presenter
impl Unpin for Presenter
impl UnsafeUnpin for Presenter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Component for Twhere
T: 'static,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> MaybeSync for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.