[][src]Struct web_glitz::image::texture_cube::LevelFaceSubImage

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

Returned from LevelFace::sub_image, a reference to a sub-region of a LevelFace's image.

See [Level::sub_image] for details.

Implementations

impl<'a, F> LevelFaceSubImage<'a, F> where
    F: TextureFormat
[src]

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

Returns the index of the mipmap level this LevelFaceSubImage references.

pub fn face(&self) -> CubeFace[src]

Returns the face referenced by this LevelFaceSubImage.

pub fn region(&self) -> Region2D[src]

Returns the sub-region of the level-face this LevelFaceSubImage references.

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

Returns the width of this LevelFaceSubImage.

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

Returns the height of this LevelFaceSubImage.

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

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

See also LevelFace::sub_image.

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

Returns a command which, when executed, replaces the image data in this LevelFaceSubImage's image region 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 LevelFaceSubImage region entirely, starting from the region's origin, then only the region of overlap is updated (note that the origin of a region is at its lower left corner). For example, given a LevelFaceSubImage 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 LevelFaceSubImage's region is updated. If the dimensions of the image provided in data would, when starting from the [LevelSubImage]'s origin, cover more than the LevelFaceSubImage's region (the width and/or height of data is/are greater than the width and/or height of the LevelFaceSubImage's region), then any pixels that would fall outside of the LevelFaceSubImage's region are ignored. For example, given a LevelFaceSubImage 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 LevelFaceSubImage and the upper half is ignored.

Example

use web_glitz::image::{Image2DSource, MipmapLevels, Region2D};
use web_glitz::image::format::RGB8;
use web_glitz::image::texture_cube::TextureCubeDescriptor;

let texture = context.try_create_texture_cube(&TextureCubeDescriptor {
    format: RGB8,
    width: 256,
    height: 256,
    levels: MipmapLevels::Complete
}).unwrap();

let level = texture.base_level();
let face = level.positive_x();
let sub_image = face.sub_image(Region2D::Area((0, 0), 128, 128));

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

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

Trait Implementations

impl<'a, F> BlitSource for TextureCubeLevelFaceSubImage<'a, F> where
    F: TextureFormat + 'static, 
[src]

type Format = F

The image storage format used by the source image.

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

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

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

Auto Trait Implementations

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

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

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

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

impl<'a, F> !UnwindSafe for LevelFaceSubImage<'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.