pub struct RenderTexture {
inner: Arc<RenderTextureInner>,
}Expand description
GPU texture configured for rendering into and reading back.
Usage flags: RENDER_ATTACHMENT | COPY_SRC | TEXTURE_BINDING.
Fields§
§inner: Arc<RenderTextureInner>Implementations§
Source§impl RenderTexture
impl RenderTexture
Sourcepub fn new(app: &Application, width: u32, height: u32) -> Self
pub fn new(app: &Application, width: u32, height: u32) -> Self
Allocate a new RenderTexture of the given dimensions in Rgba8UnormSrgb.
Use RenderTexture::with_format for other formats.
Sourcepub fn with_format(
app: &Application,
width: u32,
height: u32,
format: TextureFormat,
) -> Self
pub fn with_format( app: &Application, width: u32, height: u32, format: TextureFormat, ) -> Self
Allocate with an explicit color format.
Sourcepub fn view(&self) -> &TextureView
pub fn view(&self) -> &TextureView
wgpu::TextureView suitable for use as a render-pass color attachment.
Sourcepub fn sampler(&self) -> &Sampler
pub fn sampler(&self) -> &Sampler
Sampler for downstream passes that read from this render target.
Sourcepub fn as_texture(&self) -> Texture
pub fn as_texture(&self) -> Texture
Wrap this render target as a sampled Texture for use in
the sprite pipeline.
Shares the underlying wgpu resources — no GPU copy. The render
texture’s TEXTURE_BINDING usage flag is already set, so
sampling is well-defined.
Useful for compositing text/mask/filter outputs into a scene:
render into a RenderTexture, then as_texture() + attach to
a crate::scene::Sprite.
Sourcepub fn read_pixels(&self, app: &Application) -> Vec<u8> ⓘ
pub fn read_pixels(&self, app: &Application) -> Vec<u8> ⓘ
Read back the rendered pixels as a tightly-packed RGBA8 buffer.
For Rgba8UnormSrgb / Bgra8UnormSrgb formats the returned buffer is
width * height * 4 bytes; row-padding from
COPY_BYTES_PER_ROW_ALIGNMENT is stripped before return.
Blocks the current thread on device.poll(Maintain::Wait).
Trait Implementations§
Source§impl Clone for RenderTexture
impl Clone for RenderTexture
Source§fn clone(&self) -> RenderTexture
fn clone(&self) -> RenderTexture
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RenderTexture
impl !RefUnwindSafe for RenderTexture
impl Send for RenderTexture
impl Sync for RenderTexture
impl Unpin for RenderTexture
impl UnsafeUnpin for RenderTexture
impl !UnwindSafe for RenderTexture
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,
§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