Skip to main content

ss_player_set_cellmap_texture

Function ss_player_set_cellmap_texture 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ss_player_set_cellmap_texture( handle: *mut SsPlayer, pack_name: *const c_char, cellmap_name: *const c_char, rgba: *const u8, width: u32, height: u32, ) -> i32
Expand description

Replace the texture a cellmap binds, on one player, from straight-alpha RGBA8 pixels — a costume change or dynamic expression, driven from the program rather than the authoring data.

pack_name null selects the main pack. cellmap_name is a cellmap name or a TextureChange target — one of the strings ss_player_cellmap_texture_name lists. rgba is width * height * 4 bytes and is premultiplied on the way to the GPU; passing rgba null restores the cellmap to its original atlas (width / height are then ignored). The swap is per player — another player of the same pack is unaffected — and reaches the GPU on the next scene update.

The replacement should match the original atlas’s size and cell layout: the runtime’s UVs stay in the original cellmap’s pixel space, so a different resolution samples a different region. One the device cannot hold fails with SS_ERROR_INVALID_ARGUMENT and leaves the cellmap as it was (see ss_scene_add_texture), as does a cellmap_name the pack does not list or a pack_name the player does not hold. Restoring a cellmap that carries no override succeeds and changes nothing.

§Safety

pack_name must be null or NUL-terminated UTF-8; cellmap_name must be NUL-terminated UTF-8. When rgba is non-null it must point at width * height * 4 readable bytes; it is not retained.