[][src]Struct web_glitz::image::LayeredImageSource

pub struct LayeredImageSource<D, T> { /* fields omitted */ }

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]

pub fn from_pixels(
    pixels: D,
    width: u32,
    height: u32,
    depth: u32
) -> Result<Self, FromPixelsError>
[src]

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

impl<D, T> Send for LayeredImageSource<D, T> where
    D: Send,
    T: Send

impl<D, T> Sync for LayeredImageSource<D, T> where
    D: Sync,
    T: Sync

impl<D, T> Unpin for LayeredImageSource<D, T> where
    D: Unpin,
    T: Unpin

impl<D, T> UnwindSafe for LayeredImageSource<D, T> where
    D: UnwindSafe,
    T: UnwindSafe

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.