Struct nannou::wgpu::TextureBuilder
source · pub struct TextureBuilder { /* private fields */ }
Expand description
A type aimed at simplifying the construction of a Texture.
The builder assumes a set of defaults describing a 128x128, non-multisampled, single-layer, non-linear sRGBA-8 texture. A suite of builder methods may be used to specify the exact properties desired.
Implementations§
source§impl Builder
impl Builder
sourcepub const REQUIRED_IMAGE_TEXTURE_USAGE: TextureUsages = wgpu::TextureUsages::COPY_DST
pub const REQUIRED_IMAGE_TEXTURE_USAGE: TextureUsages = wgpu::TextureUsages::COPY_DST
The minimum required texture usage when loading from an image.
sourcepub fn from_image_view<T>(image_view: &T) -> Builder
pub fn from_image_view<T>(image_view: &T) -> Builder
Produce a texture descriptor from an image.
Specifically, this supports any image type implementing image::GenericImageView
whose
Pixel
type implements Pixel
.
By default, the produced builder will have the wgpu::TextureUsages
returned by
wgpu::TextureBuilder::default_image_texture_usage()
. This is a general-purpose usage that
should allow for copying to and from the texture, sampling the texture and rendering to the
texture. Specifying only the texture usage required may result in better performance. It
may be necessary to manually specify the the usage if STORAGE
is required.
sourcepub fn default_image_texture_usage() -> TextureUsages
pub fn default_image_texture_usage() -> TextureUsages
The default texture usage for the case where a user has loaded a texture from an image.
source§impl Builder
impl Builder
pub const DEFAULT_SIDE: u32 = 128u32
pub const DEFAULT_DEPTH: u32 = 1u32
pub const DEFAULT_SIZE: Extent3d = _
pub const DEFAULT_ARRAY_LAYER_COUNT: u32 = 1u32
pub const DEFAULT_MIP_LEVEL_COUNT: u32 = 1u32
pub const DEFAULT_SAMPLE_COUNT: u32 = 1u32
pub const DEFAULT_DIMENSION: TextureDimension = wgpu::TextureDimension::D2
pub const DEFAULT_FORMAT: TextureFormat = wgpu::TextureFormat::Rgba8Unorm
pub const DEFAULT_USAGE: TextureUsages = _
pub const DEFAULT_DESCRIPTOR: TextureDescriptor<Option<&'static str>, &'static [TextureFormat]> = _
sourcepub fn size(self, _: [u32; 2]) -> Builder
pub fn size(self, _: [u32; 2]) -> Builder
Specify the width and height of the texture.
Note: On calls to size
, depth
and extent
the Builder
will attempt to infer the
wgpu::TextureDimension
of its inner wgpu::TextureDescriptor
by examining its size
field. Use TextureBuilder::dimension()
to override this behavior.
sourcepub fn depth(self, depth: u32) -> Builder
pub fn depth(self, depth: u32) -> Builder
Specify the depth of the texture.
Note: On calls to size
, depth
and extent
the Builder
will attempt to infer the
wgpu::TextureDimension
of its inner wgpu::TextureDescriptor
by examining its size
field. Use TextureBuilder::dimension()
to override this behavior.
sourcepub fn extent(self, extent: Extent3d) -> Builder
pub fn extent(self, extent: Extent3d) -> Builder
Specify the width, height and depth of the texture.
Note: On calls to size
, depth
and extent
the Builder
will attempt to infer the
wgpu::TextureDimension
of its inner wgpu::TextureDescriptor
by examining its size
field. Use TextureBuilder::dimension()
to override this behavior.
sourcepub fn dimension(self, dimension: TextureDimension) -> Builder
pub fn dimension(self, dimension: TextureDimension) -> Builder
Specify the dimension of the texture, overriding inferred dimension.
Mainly useful for creating 2d texture arrays – override dimension with
wgpu::TextureDimension::D2
on a texture with extent.depth > 1
in order to create a
texture array (/ cubemap / cubemap array) instead of a 3d texture.
sourcepub fn mip_level_count(self, count: u32) -> Builder
pub fn mip_level_count(self, count: u32) -> Builder
Specify the number of mip levels of the texture.
sourcepub fn sample_count(self, count: u32) -> Builder
pub fn sample_count(self, count: u32) -> Builder
Specify the number of samples per pixel in the case that the texture is multisampled.
sourcepub fn format(self, format: TextureFormat) -> Builder
pub fn format(self, format: TextureFormat) -> Builder
Specify the texture format.
sourcepub fn usage(self, usage: TextureUsages) -> Builder
pub fn usage(self, usage: TextureUsages) -> Builder
Describes to the implementation how the texture is to be used.
It is important that the set of usage bits reflects the
sourcepub fn build(self, device: &Device) -> Texture
pub fn build(self, device: &Device) -> Texture
Build the texture resulting from the specified parameters with the given device.
sourcepub fn into_descriptor(
self
) -> TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>
pub fn into_descriptor( self ) -> TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>
Consumes the builder and returns the resulting wgpu::TextureDescriptor
.
Trait Implementations§
source§impl From<TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>> for Builder
impl From<TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>> for Builder
source§fn from(
descriptor: TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>
) -> Builder
fn from( descriptor: TextureDescriptor<Option<&'static str>, &'static [TextureFormat]> ) -> Builder
source§impl Into<TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>> for Builder
impl Into<TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>> for Builder
source§fn into(
self
) -> TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>
fn into( self ) -> TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>
Auto Trait Implementations§
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
source§fn convert_into(self) -> U
fn convert_into(self) -> U
source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains the unclamped color. Read more