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

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

Implementations

Returns the index of the mipmap level this LevelLayerSubImage references.

Returns the index of the layer this LevelLayerSubImage references.

Returns the Region2D of the level-layer this LevelLayerSubImage references.

Returns the width of this LevelLayerSubImage.

Returns the height of this LevelLayerSubImage.

Returns a reference to the sub-region of this LevelLayerSubImage’s image described by region.

See also LevelLayer::sub_image.

Returns a command which, when executed, replaces the image data in this LevelLayerSubImage’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 LevelLayerSubImage 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 LevelLayerSubImage 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 LevelLayerSubImage’s region is updated. If the dimensions of the image provided in data would, when starting from the LevelLayerSubImage’s origin, cover more than the LevelLayerSubImage’s region (the width and/or height of data is/are greater than the width and/or height of the LevelLayerSubImage’s region), then any pixels that would fall outside of the LevelLayerSubImage’s region are ignored. For example, given a LevelLayerSubImage 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 LevelLayerSubImage 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_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 level = texture.base_level();
let layers = 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![[255, 0, 0]; 128 * 128];
let data = Image2DSource::from_pixels(pixels, 128, 128).unwrap();

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

Trait Implementations

The image storage format used by the source image.

Encapsulates the information about the blit source required by the BlitCommand.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Stores the data in a buffer belonging to the given context, using the given usage_hint. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.