[−][src]Struct web_glitz::image::texture_2d::LevelMut
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 sub_image(&self, region: Region2D) -> LevelSubImage<'_, F>[src]
Returns a reference to the sub-region of this Level'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::Texture2DDescriptor; let texture = context.try_create_texture_2d(&Texture2DDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Complete }).unwrap(); let base_level = texture.base_level(); let sub_image = base_level.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 texture's base level now contains blue pixels, while the
rest of the base levels remains black (texture storage starts out with all bits set to 0,
which with format [RGB8] is interpreted as black).
pub fn upload_command<D, T>(
&self,
data: Image2DSource<D, T>
) -> UploadCommand<D, T, F> where
T: PixelUnpack<F>, [src]
&self,
data: Image2DSource<D, T>
) -> UploadCommand<D, T, F> where
T: PixelUnpack<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 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 Level'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 Level 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 Level'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
Level are ignored. For example, given a Level 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 Level 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::Texture2DDescriptor; let texture = context.try_create_texture_2d(&Texture2DDescriptor { format: RGB8, width: 256, height: 256, levels: MipmapLevels::Complete }).unwrap(); let pixels: Vec<[u8; 3]> = vec![[255, 0, 0]; 256 * 256]; let data = Image2DSource::from_pixels(pixels, 256, 256).unwrap(); context.submit(texture.base_level().upload_command(data));
pub fn pack_to_buffer_command<P>(
&self,
buffer: BufferView<'_, [P]>
) -> PackToBufferCommand<F, P> where
P: PixelPack<F>, [src]
&self,
buffer: BufferView<'_, [P]>
) -> PackToBufferCommand<F, P> where
P: PixelPack<F>,
Trait Implementations
impl<'a, F> AsAttachment for Texture2DLevelMut<'a, F> where
F: TextureFormat, [src]
F: TextureFormat,
type Format = F
The type of image storage format the image is stored in.
fn as_attachment(&mut self) -> Attachment<'_, Self::Format>[src]
impl<'a, F> AttachColorFloat for Texture2DLevelMut<'a, F> where
F: TextureFormat + FloatRenderable, [src]
F: TextureFormat + FloatRenderable,
impl<'a, F> AttachColorInteger for Texture2DLevelMut<'a, F> where
F: TextureFormat + IntegerRenderable, [src]
F: TextureFormat + IntegerRenderable,
impl<'a, F> AttachColorUnsignedInteger for Texture2DLevelMut<'a, F> where
F: TextureFormat + UnsignedIntegerRenderable, [src]
F: TextureFormat + UnsignedIntegerRenderable,
impl<'a, F> AttachDepth for Texture2DLevelMut<'a, F> where
F: TextureFormat + DepthRenderable, [src]
F: TextureFormat + DepthRenderable,
impl<'a, F> AttachDepthStencil for Texture2DLevelMut<'a, F> where
F: TextureFormat + DepthStencilRenderable, [src]
F: TextureFormat + DepthStencilRenderable,
impl<'a, F> AttachStencil for Texture2DLevelMut<'a, F> where
F: TextureFormat + StencilRenderable, [src]
F: TextureFormat + StencilRenderable,
impl<'a, F> Deref for LevelMut<'a, F>[src]
type Target = Level<'a, F>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target[src]
impl<'a, F: Hash> Hash for LevelMut<'a, F>[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<'a, F: PartialEq> PartialEq<LevelMut<'a, F>> for LevelMut<'a, F>[src]
fn eq(&self, other: &LevelMut<'a, F>) -> bool[src]
fn ne(&self, other: &LevelMut<'a, F>) -> bool[src]
impl<'a, F> StructuralPartialEq for LevelMut<'a, F>[src]
Auto Trait Implementations
impl<'a, F> !RefUnwindSafe for LevelMut<'a, F>
impl<'a, F> !Send for LevelMut<'a, F>
impl<'a, F> !Sync for LevelMut<'a, F>
impl<'a, F> Unpin for LevelMut<'a, F>
impl<'a, F> !UnwindSafe for LevelMut<'a, F>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static, [src]
D: Borrow<T> + 'static,
T: Copy + 'static,
pub fn into_buffer<Rc>(Self, &Rc, BufferId, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static, [src]
Rc: RenderingContext + Clone + 'static,
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.
pub 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>,