pub struct Texture<'a> { /* private fields */ }Expand description
A parsed 2D texture backed by slices into the caller’s cooked blob. Pixel data is already packed into the halfword-nibble layout the PSX GPU reads; the CLUT (if any) is a slice of RGB555 halfwords.
Construct by Texture::from_bytes(&blob); upload to VRAM via
[Texture::upload], which returns the matching TexturePage + Clut
handles ready to feed into primitive constructors.
Implementations§
Source§impl<'a> Texture<'a>
impl<'a> Texture<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ParseError>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ParseError>
Parse a cooked .psxt blob. Returns a Texture view that
borrows into bytes. Cheap – header decode + two slice
computations.
Sourcepub fn clut_entries(&self) -> u16
pub fn clut_entries(&self) -> u16
Number of CLUT entries in the blob. Normal textures use 16 for 4bpp, 256 for 8bpp, or 0 for 15bpp; specialized 4bpp assets may concatenate multiple 16-entry CLUT rows.
Sourcepub fn is_index_zero_transparent(&self) -> bool
pub fn is_index_zero_transparent(&self) -> bool
True when indexed palette entry 0 should remain transparent.
Sourcepub fn pixel_bytes(&self) -> &'a [u8]
pub fn pixel_bytes(&self) -> &'a [u8]
Raw packed pixel halfwords, as bytes. Suitable for
halfword-level DMA upload; caller pairs this with a VramRect
describing the halfword footprint, not the texel width.
Sourcepub fn clut_bytes(&self) -> &'a [u8]
pub fn clut_bytes(&self) -> &'a [u8]
Raw CLUT halfwords, as bytes. Empty for 15bpp.
Sourcepub fn halfwords_per_row(&self) -> u16
pub fn halfwords_per_row(&self) -> u16
Halfwords-per-row at this texture’s depth (rows padded up to a full halfword). Needed when computing the VRAM rect for upload: VRAM measures in halfwords regardless of the texel depth the GPU will fetch them at.
Trait Implementations§
impl<'a> Copy for Texture<'a>
Auto Trait Implementations§
impl<'a> Freeze for Texture<'a>
impl<'a> RefUnwindSafe for Texture<'a>
impl<'a> Send for Texture<'a>
impl<'a> Sync for Texture<'a>
impl<'a> Unpin for Texture<'a>
impl<'a> UnsafeUnpin for Texture<'a>
impl<'a> UnwindSafe for Texture<'a>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)