pub enum RenderTarget<'a> {
Surface,
SurfaceWithDepth {
depth_view: &'a TextureView,
clear_value: Option<f32>,
},
Framebuffer(&'a Framebuffer),
}Expand description
A render target that can be either a window surface or an offscreen framebuffer.
This enum simplifies render pass setup by providing a unified interface for different rendering destinations.
Variants§
Surface
Render to the window surface.
The surface view is obtained from the [Frame] during render pass creation.
SurfaceWithDepth
Render to the window surface with an attached depth buffer.
This variant allows rendering to the surface while using a depth texture for z-ordering, which is essential for UI systems and 3D overlays.
§Example
let depth_view = frame.window_depth_view().expect("Window has depth");
let mut pass = frame.render_pass()
.target(RenderTarget::surface_with_depth_clear(&depth_view, 0.0))
.clear_color(Color::BLACK)
.build();
// ... rendering ...Fields
depth_view: &'a TextureViewThe depth texture view to attach.
Framebuffer(&'a Framebuffer)
Render to an offscreen framebuffer.
The framebuffer manages its own color, depth, and MSAA textures.
Implementations§
Source§impl<'a> RenderTarget<'a>
impl<'a> RenderTarget<'a>
Sourcepub fn surface_with_depth(depth: &'a TextureView) -> Self
pub fn surface_with_depth(depth: &'a TextureView) -> Self
Create a surface target with a depth buffer that loads existing values.
Sourcepub fn surface_with_depth_clear(depth: &'a TextureView, clear: f32) -> Self
pub fn surface_with_depth_clear(depth: &'a TextureView, clear: f32) -> Self
Create a surface target with a depth buffer that clears to the specified value.
For reverse-Z depth (recommended), use 0.0 as the clear value. For standard depth, use 1.0 as the clear value.
Sourcepub fn framebuffer(fb: &'a Framebuffer) -> Self
pub fn framebuffer(fb: &'a Framebuffer) -> Self
Create a framebuffer target.
Sourcepub fn is_surface(&self) -> bool
pub fn is_surface(&self) -> bool
Check if this target is a surface (with or without depth).
Sourcepub fn is_framebuffer(&self) -> bool
pub fn is_framebuffer(&self) -> bool
Check if this target is a framebuffer.
Sourcepub fn framebuffer_ref(&self) -> Option<&'a Framebuffer>
pub fn framebuffer_ref(&self) -> Option<&'a Framebuffer>
Get the framebuffer if this is a framebuffer target.
Sourcepub fn format(&self) -> Option<TextureFormat>
pub fn format(&self) -> Option<TextureFormat>
Get the texture format for this target.
For framebuffers, returns the framebuffer’s format. For surfaces, returns None (format must be obtained from surface config).
Sourcepub fn sample_count(&self) -> u32
pub fn sample_count(&self) -> u32
Get the sample count for this target.
For framebuffers, returns the framebuffer’s sample count. For surfaces, returns 1 (surfaces don’t support MSAA directly).
Sourcepub fn depth_view(&self) -> Option<&'a TextureView>
pub fn depth_view(&self) -> Option<&'a TextureView>
Get the depth view if available.
Sourcepub fn depth_clear_value(&self) -> Option<f32>
pub fn depth_clear_value(&self) -> Option<f32>
Get the depth clear value if this target clears depth.
Trait Implementations§
Source§impl<'a> Clone for RenderTarget<'a>
impl<'a> Clone for RenderTarget<'a>
Source§fn clone(&self) -> RenderTarget<'a>
fn clone(&self) -> RenderTarget<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for RenderTarget<'a>
impl<'a> Debug for RenderTarget<'a>
Source§impl<'a> Default for RenderTarget<'a>
impl<'a> Default for RenderTarget<'a>
Source§fn default() -> RenderTarget<'a>
fn default() -> RenderTarget<'a>
Source§impl<'a> From<&'a Framebuffer> for RenderTarget<'a>
impl<'a> From<&'a Framebuffer> for RenderTarget<'a>
Source§fn from(fb: &'a Framebuffer) -> Self
fn from(fb: &'a Framebuffer) -> Self
impl<'a> Copy for RenderTarget<'a>
Auto Trait Implementations§
impl<'a> Freeze for RenderTarget<'a>
impl<'a> !RefUnwindSafe for RenderTarget<'a>
impl<'a> Send for RenderTarget<'a>
impl<'a> Sync for RenderTarget<'a>
impl<'a> Unpin for RenderTarget<'a>
impl<'a> UnsafeUnpin for RenderTarget<'a>
impl<'a> !UnwindSafe for RenderTarget<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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