Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Texture

Struct Texture 

Source
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>

Source

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.

Source

pub fn width(&self) -> u16

Width in texels.

Source

pub fn height(&self) -> u16

Height in texels.

Source

pub fn depth(&self) -> Depth

Colour depth.

Source

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.

Source

pub fn flags(&self) -> u16

Texture feature flags from the shared asset header.

Source

pub fn is_index_zero_transparent(&self) -> bool

True when indexed palette entry 0 should remain transparent.

Source

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.

Source

pub fn clut_bytes(&self) -> &'a [u8]

Raw CLUT halfwords, as bytes. Empty for 15bpp.

Source

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§

Source§

impl<'a> Clone for Texture<'a>

Source§

fn clone(&self) -> Texture<'a>

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Texture<'a>

Source§

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

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

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.