[−][src]Struct web_glitz::image::LayeredImageSource
Encapsulates data that may be uploaded to a layered texture (sub-)image.
Example
use web_glitz::image::{LayeredImageSource, MipmapLevels}; use web_glitz::image::format::RGB8; use web_glitz::image::texture_3d::Texture3DDescriptor; let texture = context.try_create_texture_3d(&Texture3DDescriptor { format: RGB8, width: 256, height: 256, depth: 256, levels: MipmapLevels::Complete }).unwrap(); let data: Vec<[u8; 3]> = vec![[255, 0, 0]; 256 * 256 * 256]; let image_source = LayeredImageSource::from_pixels(data, 256, 256, 256).unwrap(); context.submit(texture.base_level().upload_command(image_source));
Note that the pixel data type ([u8; 3] in the example) must implement [ClientFormat] for the
texture's [InternalFormat] (in this case that means ClientFormat<RGB8> must be implemented
for [u8; 3], which it is).
Implementations
impl<D, T> LayeredImageSource<D, T> where
D: Borrow<[T]>, [src]
D: Borrow<[T]>,
pub fn from_pixels(
pixels: D,
width: u32,
height: u32,
depth: u32
) -> Result<Self, FromPixelsError>[src]
pixels: D,
width: u32,
height: u32,
depth: u32
) -> Result<Self, FromPixelsError>
Creates a new LayeredImageSource from the pixels for an image with the given width,
the given height and the given depth.
In this context the depth of the image corresponds to its number of layers.
Returns FromPixelsError::NotEnoughPixels if the pixels does not contain enough data for
at least width * height * depth pixels.
Example
use web_glitz::image::LayeredImageSource; let data: Vec<[u8; 3]> = vec![[255, 0, 0]; 256 * 256 * 256]; let image_source = LayeredImageSource::from_pixels(data, 256, 256, 256).unwrap();
Auto Trait Implementations
impl<D, T> RefUnwindSafe for LayeredImageSource<D, T> where
D: RefUnwindSafe,
T: RefUnwindSafe,
D: RefUnwindSafe,
T: RefUnwindSafe,
impl<D, T> Send for LayeredImageSource<D, T> where
D: Send,
T: Send,
D: Send,
T: Send,
impl<D, T> Sync for LayeredImageSource<D, T> where
D: Sync,
T: Sync,
D: Sync,
T: Sync,
impl<D, T> Unpin for LayeredImageSource<D, T> where
D: Unpin,
T: Unpin,
D: Unpin,
T: Unpin,
impl<D, T> UnwindSafe for LayeredImageSource<D, T> where
D: UnwindSafe,
T: UnwindSafe,
D: UnwindSafe,
T: UnwindSafe,
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,
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,
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.
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>,