Enum TextureData

Source
pub enum TextureData {
    RU8(Vec<u8>),
    RgU8(Vec<[u8; 2]>),
    RgbU8(Vec<[u8; 3]>),
    RgbaU8(Vec<[u8; 4]>),
    RF16(Vec<f16>),
    RgF16(Vec<[f16; 2]>),
    RgbF16(Vec<[f16; 3]>),
    RgbaF16(Vec<[f16; 4]>),
    RF32(Vec<f32>),
    RgF32(Vec<[f32; 2]>),
    RgbF32(Vec<[f32; 3]>),
    RgbaF32(Vec<[f32; 4]>),
}
Expand description

The pixel/texel data for a Texture2D or Texture3D.

If 2D data, the data array should start with the top left texel and then one row at a time. The indices (row, column) into the 2D data would look like

[
(0, 0), (1, 0), .., // First row
(0, 1), (1, 1), .., // Second row
..
]

If 3D data, the data array would look like the 2D data, one layer/image at a time. The indices (row, column, layer) into the 3D data would look like

[
(0, 0, 0), (1, 0, 0), .., // First row in first layer
(0, 1, 0), (1, 1, 0), .., // Second row in first layer
..
(0, 0, 1), (1, 0, 1), .., // First row in second layer
(0, 1, 1), (1, 1, 1), ..,  // Second row in second layer
..
]

Variants§

§

RU8(Vec<u8>)

One byte in the red channel.

§

RgU8(Vec<[u8; 2]>)

One byte in the red and green channel.

§

RgbU8(Vec<[u8; 3]>)

One byte in the red, green and blue channel.

§

RgbaU8(Vec<[u8; 4]>)

One byte in the red, green, blue and alpha channel.

§

RF16(Vec<f16>)

16-bit float in the red channel.

§

RgF16(Vec<[f16; 2]>)

16-bit float in the red and green channel.

§

RgbF16(Vec<[f16; 3]>)

16-bit float in the red, green and blue channel.

§

RgbaF16(Vec<[f16; 4]>)

16-bit float in the red, green, blue and alpha channel.

§

RF32(Vec<f32>)

32-bit float in the red channel.

§

RgF32(Vec<[f32; 2]>)

32-bit float in the red and green channel.

§

RgbF32(Vec<[f32; 3]>)

32-bit float in the red, green and blue channel.

§

RgbaF32(Vec<[f32; 4]>)

32-bit float in the red, green, blue and alpha channel.

Implementations§

Source§

impl TextureData

Source

pub fn to_linear_srgb(&mut self)

Converts the texture data to linear sRGB color space if the data is either TextureData::RgbU8 (assuming sRGB color space) or TextureData::RgbaU8 (assuming sRGB color space with an alpha channel). Does nothing if the data is any other data type.

Source

pub fn to_color(&mut self)

Converts the texture data to color TextureData::RgbU8 if the data is TextureData::RU8 (assuming gray scale colors). Does nothing if the data is any other data type.

Trait Implementations§

Source§

impl Clone for TextureData

Source§

fn clone(&self) -> TextureData

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextureData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TextureData

Source§

fn eq(&self, other: &TextureData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TextureData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,