[][src]Struct web_glitz::image::texture_2d_array::LevelLayerMut

pub struct LevelLayerMut<'a, F> { /* fields omitted */ }

A mutable reference to a layer of a Texture2DArray mipmap level.

Derefs to LevelLayer.

Methods from Deref<Target = LevelLayer<'a, F>>

pub fn level(&self) -> usize[src]

The index that identifies the Level this LevelLayer belongs to.

pub fn layer(&self) -> usize[src]

The index that identifies this layer within the Level it belongs to.

Corresponds to the depth at which this LevelLayer occurs.

pub fn width(&self) -> u32[src]

The width of the LevelLayer.

pub fn height(&self) -> u32[src]

The height of the LevelLayer.

pub fn sub_image(&self, region: Region2D) -> LevelLayerSubImage<'_, F>[src]

Returns a reference to the sub-region of this LevelLayer's image described by region.

Example

This may for example be used to upload data to only a sub-region of an image, rather than the complete image:

use web_glitz::image::{Image2DSource, MipmapLevels, Region2D};
use web_glitz::image::format::RGB8;
use web_glitz::image::texture_2d_array::Texture2DArrayDescriptor;

let texture = context.try_create_texture_2d_array(&Texture2DArrayDescriptor {
    format: RGB8,
    width: 256,
    height: 256,
    depth: 16,
    levels: MipmapLevels::Complete
}).unwrap();

let base_level = texture.base_level();
let layers = base_level.layers();
let layer = layers.get(0).unwrap();
let sub_image = layer.sub_image(Region2D::Area((0, 0), 128, 128));

let pixels: Vec<[u8; 3]> = vec![[0, 0, 255]; 128 * 128];
let data = Image2DSource::from_pixels(pixels, 128, 128).unwrap();

context.submit(sub_image.upload_command(data));

The lower left quadrant of the first layer of the texture's base level now contains blue pixels.

pub fn upload_command<D, T>(
    &self,
    data: Image2DSource<D, T>
) -> LevelLayerUploadCommand<D, T, F> where
    T: PixelUnpack<F>, 
[src]

Returns a command which, when executed, replaces the image data in this LevelLayer's image with the image data provided in data.

The image data must be stored as a PixelUnpack type that is suitable for the texture's TextureFormat.

If the dimensions of the image provided in data are not sufficient to cover the LevelLayer's image entirely, starting from the origin, then only the region of overlap is updated (note that the origin of an image is the lower left corner). For example, given a LevelLayer with a width of 256 pixels and a height of 256 pixels, and data with a width of 128 pixels and a height of 128 pixels, then only the lower left quadrant of the Level is updated. If the dimensions of the image provided in data would, when starting from the origin, cover more than the LevelLayer's image (the width and/or height of data is/are greater than the width and/or height of the Level's image), then any pixels that would fall outside of the LevelLayer are ignored. For example, given a LevelLayer with a width of 256 pixels and a height of 256 pixels, and data with a width of 256 pixels and a height of 512 pixels, then only the lower half of the image in data is used to update the LevelLayer and the upper half is ignored.

Example

use web_glitz::image::{Image2DSource, MipmapLevels};
use web_glitz::image::format::RGB8;
use web_glitz::image::texture_2d_array::Texture2DArrayDescriptor;

let texture = context.try_create_texture_2d_array(&Texture2DArrayDescriptor {
    format: RGB8,
    width: 256,
    height: 256,
    depth: 16,
    levels: MipmapLevels::Complete
}).unwrap();

let base_level = texture.base_level();
let layers = base_level.layers();
let layer = layers.get(0).unwrap();

let pixels: Vec<[u8; 3]> = vec![[255, 0, 0]; 256 * 256];
let data = Image2DSource::from_pixels(pixels, 256, 256).unwrap();

context.submit(layer.upload_command(data));

Trait Implementations

impl<'a, F> AsAttachment for Texture2DArrayLevelLayerMut<'a, F> where
    F: TextureFormat
[src]

type Format = F

The type of image storage format the image is stored in.

impl<'a, F> AttachColorFloat for Texture2DArrayLevelLayerMut<'a, F> where
    F: TextureFormat + FloatRenderable
[src]

impl<'a, F> AttachColorInteger for Texture2DArrayLevelLayerMut<'a, F> where
    F: TextureFormat + IntegerRenderable
[src]

impl<'a, F> AttachColorUnsignedInteger for Texture2DArrayLevelLayerMut<'a, F> where
    F: TextureFormat + UnsignedIntegerRenderable
[src]

impl<'a, F> AttachDepth for Texture2DArrayLevelLayerMut<'a, F> where
    F: TextureFormat + DepthRenderable
[src]

impl<'a, F> AttachDepthStencil for Texture2DArrayLevelLayerMut<'a, F> where
    F: TextureFormat + DepthStencilRenderable
[src]

impl<'a, F> AttachStencil for Texture2DArrayLevelLayerMut<'a, F> where
    F: TextureFormat + StencilRenderable
[src]

impl<'a, F> Deref for LevelLayerMut<'a, F>[src]

type Target = LevelLayer<'a, F>

The resulting type after dereferencing.

impl<'a, F: Hash> Hash for LevelLayerMut<'a, F>[src]

impl<'a, F: PartialEq> PartialEq<LevelLayerMut<'a, F>> for LevelLayerMut<'a, F>[src]

impl<'a, F> StructuralPartialEq for LevelLayerMut<'a, F>[src]

Auto Trait Implementations

impl<'a, F> !RefUnwindSafe for LevelLayerMut<'a, F>

impl<'a, F> !Send for LevelLayerMut<'a, F>

impl<'a, F> !Sync for LevelLayerMut<'a, F>

impl<'a, F> Unpin for LevelLayerMut<'a, F>

impl<'a, F> !UnwindSafe for LevelLayerMut<'a, F>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.