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

TextureMaterial

Struct TextureMaterial 

Source
pub struct TextureMaterial { /* private fields */ }
Expand description

Textured primitive material.

clut_word is the packed CLUT handle used by indexed textures. tpage_word is the packed tpage word normally produced by TexturePage::uv_word(0). The material rewrites the tpage blend bits from BlendMode so one base tpage can be reused across opaque and translucent variants.

Implementations§

Source§

impl TextureMaterial

Source

pub const fn new(clut_word: u16, tpage_word: u16) -> Self

Build an opaque, unmodulated texture material.

Source

pub const fn opaque(clut_word: u16, tpage_word: u16, tint: (u8, u8, u8)) -> Self

Build an opaque texture material with a flat tint.

Source

pub const fn blended( clut_word: u16, tpage_word: u16, tint: (u8, u8, u8), blend_mode: BlendMode, ) -> Self

Build a translucent texture material with a flat tint.

Textured primitives still follow PS1 texel rules: the primitive command enables transparency, and sampled texels with bit 15 set actually blend through the selected mode.

Source

pub const fn with_blend_mode(self, blend_mode: BlendMode) -> Self

Return a copy using blend_mode.

For a textured primitive this only selects the blending equation. Which texels actually blend is decided per texel by bit 15 of the palette entry (psx_vram::Color555::with_stp); a CLUT without that bit draws fully opaque whatever is set here, and nothing reports it. For an untextured primitive the mode applies to the whole polygon.

Source

pub const fn with_tint(self, tint: (u8, u8, u8)) -> Self

Return a copy using tint.

Source

pub const fn with_clut_bank(self, bank: u8) -> Self

Return a copy selecting a consecutive 16-entry 4bpp CLUT bank.

Source

pub const fn with_texture_window(self, texture_window: TextureWindow) -> Self

Return a copy using texture_window.

Source

pub const fn with_raw_texture(self, raw_texture: bool) -> Self

Return a copy with raw texture modulation enabled or disabled.

Raw-texture mode bypasses RGB tint modulation. It is useful for palettes or direct textures that already carry final colors.

Source

pub const fn with_dither(self, dither: bool) -> Self

Return a copy with draw-mode dithering enabled or disabled.

Source

pub const fn clut_word(self) -> u16

Packed CLUT word for the first textured UV word.

Source

pub const fn texture_page_word(self) -> u16

Packed tpage word for textured polygon UV words.

The material owns the tpage blend and dither bits; all other tpage address/depth bits are preserved from the original word.

Source

pub const fn texture_window_word(self) -> u32

GP0(E2) texture-window word for this material.

Source

pub const fn tint(self) -> (u8, u8, u8)

Flat tint used by non-Gouraud textured primitives.

Source

pub const fn blend_mode(self) -> BlendMode

Active blend mode.

Source

pub const fn is_translucent(self) -> bool

True when the primitive command should set its semi-transparent bit.

Source

pub const fn is_raw_texture(self) -> bool

True when the primitive command should set its raw-texture bit.

Source

pub const fn is_dithered(self) -> bool

True when the material asks GP0(E1) / primitive tpage state for dithering.

Source

pub const fn textured_polygon_command(self, gouraud: bool, quad: bool) -> u32

Textured polygon command bits without the low RGB payload.

Source

pub const fn textured_gouraud_packet_material( self, ) -> TexturedGouraudPacketMaterial

Prepacked words for textured Gouraud triangle packet emission.

Source

pub const fn textured_packet_material(self) -> TexturedPacketMaterial

Prepacked words for flat textured triangle packet emission.

Source

pub const fn flat_textured_polygon_header(self, quad: bool) -> u32

Textured polygon header with the material’s flat tint.

Source

pub const fn textured_rect_header(self) -> u32

Textured rectangle command with the material’s flat tint.

Source

pub const fn draw_mode_word(self) -> u32

GP0(E1) draw-mode word implied by this material.

Textured rectangles read their tpage from this state. Textured polygons embed the tpage word directly, but applying the same material state before drawing keeps subsequent sprite draws in sync.

Source

pub fn apply_draw_mode(self)

👎Deprecated:

use Gpu::set_draw_mode

Apply this material’s tpage, blend, depth, dither, and texture-window state.

Trait Implementations§

Source§

impl Clone for TextureMaterial

Source§

fn clone(&self) -> TextureMaterial

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 Debug for TextureMaterial

Source§

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

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

impl PartialEq for TextureMaterial

Source§

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

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

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 Copy for TextureMaterial

Source§

impl Eq for TextureMaterial

Source§

impl StructuralPartialEq for TextureMaterial

Auto Trait Implementations§

§

impl Freeze for TextureMaterial

§

impl RefUnwindSafe for TextureMaterial

§

impl Send for TextureMaterial

§

impl Sync for TextureMaterial

§

impl Unpin for TextureMaterial

§

impl UnsafeUnpin for TextureMaterial

§

impl UnwindSafe for TextureMaterial

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.