[−][src]Struct web_glitz::image::texture_2d_array::LevelMut
A mutable reference to a Texture2DArray mipmap level.
Methods
impl<'a, F> LevelMut<'a, F>
[src]
pub fn layers_mut(&mut self) -> LevelLayersMut<'a, F>
[src]
Returns mutable a reference to the layers of this Level.
Examples
// Returns a mutable reference to layer 2 of the texture's base level if the texture has a 2 // or more layers, or None otherwise: let layer_2 = texture.base_level_mut().layers_mut().get_mut(2); // We can also iterate over mutable references to all layers that exist for the texture's // base level: for layer in texture.base_level_mut().layers_mut().iter_mut() { // ... }
Methods from Deref<Target = Level<'a, F>>
pub fn level(&self) -> usize
[src]
Returns the integer that identifies this level.
For example, if this Level is the texture's base level, returns 0
; if it is the second
level, returns 1
; etc.
pub fn width(&self) -> u32
[src]
Returns the width of this level.
pub fn height(&self) -> u32
[src]
Returns the height of this level.
pub fn depth(&self) -> u32
[src]
Returns the depth of the layered image.
Note that the depth is the same for all levels of a Texture2DArray.
pub fn layers(&self) -> LevelLayers<F>
[src]
Returns a reference to the layers of this Level.
Examples
// Returns a reference to layer 2 of the texture's base level if the texture has a 2 or more // layers, or None otherwise: let layer_2 = texture.base_level().layers().get(2); // We can also iterate over references to all layers that exist for the texture's base // level: for layer in texture.base_level().layers().iter() { // ... }
pub fn sub_image(&self, region: Region3D) -> LevelSubImage<F>
[src]
Returns a reference to the sub-region of this Level's layered image described by region
.
Example
This may for example be used to upload data to only a sub-region of a layered image, rather than the complete image:
use web_glitz::image::{LayeredImageSource, MipmapLevels, Region3D}; use web_glitz::image::format::RGB8; use web_glitz::image::texture_2d_array::Texture2DArrayDescriptor; let texture = context.create_texture_2d_array(&Texture2DArrayDescriptor { format: RGB8, width: 256, height: 256, depth: 16, levels: MipmapLevels::Complete }).unwrap(); let base_level = texture.base_level(); let sub_image = base_level.sub_image(Region3D::Area((0, 0, 0), 128, 128, 8)); let pixels: Vec<[u8; 3]> = vec![[0, 0, 255]; 128 * 128 * 8]; let data = LayeredImageSource::from_pixels(pixels, 128, 128, 8).unwrap(); context.submit(sub_image.upload_command(data));
The lower left quadrants of the first 8 layers of texture's base level now contain blue pixels.
pub fn upload_command<D, T>(
&self,
data: LayeredImageSource<D, T>
) -> LevelUploadCommand<D, T, F> where
T: ClientFormat<F>,
[src]
&self,
data: LayeredImageSource<D, T>
) -> LevelUploadCommand<D, T, F> where
T: ClientFormat<F>,
Returns a command which, when executed, replaces the image data in this Level's image
with the image data provided in data
.
The image data must be stored in a ClientFormat that is suitable for the texture's TextureFormat.
If the dimensions of the image provided in data
are not sufficient to cover the Level's
image entirely, starting from the origin, then only the region of overlap is updated (note
that the origin of a layered image is the lower left corner on the first layer). For
example, given a Level with a width of 256 pixels, a height of 256 pixels and a depth
of 16 layers, and data
with a width of 128 pixels, a height of 128 pixels and a depth of
8 layers, then only the lower left quadrants of the first 8 layers of the Level are
updated. If the dimensions of the image provided in data
would, when starting from the
origin, cover more than the Level's image (the width, height and/or depth of data
is/are
greater than the width, height and/or depth of the Level's image), then any pixels that
would fall outside of the Level are ignored. For example, given a Level with a width of
256 pixels, a height of 256 pixels and a depth of 16 layers, and data
with a width of 256
pixels, height of 512 pixels and a depth of 20 layers, then only the lower halves of the
first 16 layers in data
are used to update the Level; the upper halves of the first 16
layers in data
are ignored, and the last 4 layers in data
are ignored entirely.
Example
use web_glitz::image::{LayeredImageSource, MipmapLevels}; use web_glitz::image::format::RGB8; use web_glitz::image::texture_2d_array::Texture2DArrayDescriptor; let texture = context.create_texture_2d_array(&Texture2DArrayDescriptor { format: RGB8, width: 256, height: 256, depth: 16, levels: MipmapLevels::Complete }).unwrap(); let pixels: Vec<[u8; 3]> = vec![[255, 0, 0]; 256 * 256 * 16]; let data = LayeredImageSource::from_pixels(pixels, 256, 256, 16).unwrap(); context.submit(texture.base_level().upload_command(data));
Trait Implementations
Auto Trait Implementations
impl<'a, F> !Send for LevelMut<'a, F>
impl<'a, F> Unpin for LevelMut<'a, F>
impl<'a, F> !Sync for LevelMut<'a, F>
impl<'a, F> !UnwindSafe for LevelMut<'a, F>
impl<'a, F> !RefUnwindSafe for LevelMut<'a, F>
Blanket Implementations
impl<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static,
[src]
D: Borrow<T> + 'static,
T: Copy + 'static,
fn into_buffer<Rc>(Self, &Rc, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static,
[src]
Rc: RenderingContext + Clone + 'static,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,