pub struct Texture {
inner: Arc<TextureInner>,
}Expand description
GPU image texture backed by a wgpu::Texture.
Cheaply cloneable; the underlying GPU resource is Arc-wrapped.
Fields§
§inner: Arc<TextureInner>Implementations§
Source§impl Texture
impl Texture
Sourcepub fn from_rgba(
app: &Application,
width: u32,
height: u32,
bytes: &[u8],
) -> Self
pub fn from_rgba( app: &Application, width: u32, height: u32, bytes: &[u8], ) -> Self
Construct from raw RGBA8 bytes in linear-srgb space.
bytes.len() must equal width * height * 4.
§Panics
Panics if the byte slice length doesn’t match width * height * 4.
Sourcepub fn from_image(app: &Application, img: &DynamicImage) -> Self
pub fn from_image(app: &Application, img: &DynamicImage) -> Self
Construct from a decoded image. Converts to RGBA8 if needed.
Sourcepub(crate) fn from_render_texture_parts(
texture: Texture,
view: TextureView,
sampler: Sampler,
width: u32,
height: u32,
) -> Self
pub(crate) fn from_render_texture_parts( texture: Texture, view: TextureView, sampler: Sampler, width: u32, height: u32, ) -> Self
Wrap a set of wgpu texture handles as a Texture.
Used internally by
crate::texture::render_texture::RenderTexture::as_texture
to expose a render-target as a sampled sprite texture without
copying GPU bytes. Not part of the public API — render textures
are the supported caller, and pub(crate) keeps it that way.
Sourcepub fn empty(
app: &Application,
width: u32,
height: u32,
format: TextureFormat,
) -> Self
pub fn empty( app: &Application, width: u32, height: u32, format: TextureFormat, ) -> Self
Construct an empty (zeroed) texture for the given format.
Usage flags include TEXTURE_BINDING | COPY_DST, suitable for
sampling and per-frame uploads (e.g. backing a crate::texture::video_texture).
For render targets see crate::texture::render_texture.
pub(crate) fn view(&self) -> &TextureView
pub(crate) fn sampler(&self) -> &Sampler
pub(crate) fn wgpu_texture(&self) -> &Texture
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Texture
impl !RefUnwindSafe for Texture
impl Send for Texture
impl Sync for Texture
impl Unpin for Texture
impl UnsafeUnpin for Texture
impl !UnwindSafe for Texture
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