pub struct Texture2D {
pub width: u32,
pub height: u32,
pub format: TextureFormat,
pub data: Vec<u8>,
pub mip_levels: u32,
pub label: Option<String>,
}Expand description
CPU-side 2D texture bytes.
Fields§
§width: u32Width in texels.
height: u32Height in texels.
format: TextureFormatTexture format.
data: Vec<u8>Contiguous texture bytes.
mip_levels: u32Number of mip levels. 0 means base data with auto generation later.
label: Option<String>Optional debug label.
Implementations§
Source§impl Texture2D
impl Texture2D
Sourcepub fn new(
width: u32,
height: u32,
format: TextureFormat,
data: Vec<u8>,
) -> Result<Self, ValidationError>
pub fn new( width: u32, height: u32, format: TextureFormat, data: Vec<u8>, ) -> Result<Self, ValidationError>
Creates a base-level texture and validates byte size.
Sourcepub fn with_mip_levels(
width: u32,
height: u32,
format: TextureFormat,
data: Vec<u8>,
mip_levels: u32,
) -> Result<Self, ValidationError>
pub fn with_mip_levels( width: u32, height: u32, format: TextureFormat, data: Vec<u8>, mip_levels: u32, ) -> Result<Self, ValidationError>
Creates a texture with explicit mip-level count and validates byte size.
Sourcepub fn from_mips(
width: u32,
height: u32,
format: TextureFormat,
mips: Vec<Vec<u8>>,
) -> Result<Self, ValidationError>
pub fn from_mips( width: u32, height: u32, format: TextureFormat, mips: Vec<Vec<u8>>, ) -> Result<Self, ValidationError>
Creates a texture from explicit mip levels and flattens the data.
Sourcepub fn base_level_len(&self) -> Result<usize, ValidationError>
pub fn base_level_len(&self) -> Result<usize, ValidationError>
Returns the expected byte length of the base mip level.
Sourcepub fn mip_level_range(
&self,
level: u32,
) -> Result<Range<usize>, ValidationError>
pub fn mip_level_range( &self, level: u32, ) -> Result<Range<usize>, ValidationError>
Returns the byte range occupied by one mip level in data.
Sourcepub fn validate(&self) -> Result<(), ValidationError>
pub fn validate(&self) -> Result<(), ValidationError>
Validates dimensions and byte length.
Trait Implementations§
impl StructuralPartialEq for Texture2D
Auto Trait Implementations§
impl Freeze for Texture2D
impl RefUnwindSafe for Texture2D
impl Send for Texture2D
impl Sync for Texture2D
impl Unpin for Texture2D
impl UnsafeUnpin for Texture2D
impl UnwindSafe for Texture2D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more