Skip to main content

ss_scene_add_texture

Function ss_scene_add_texture 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ss_scene_add_texture( scene: *mut SsScene, key: u32, rgba: *const u8, width: u32, height: u32, ) -> i32
Expand description

Supply a texture for a reference-mode pack under ss_texture_ref_t.key โ€” what ss_player_texture_at reports for the atlas. It identifies the image, not the cell map hash in DrawBatch.texture_hash. rgba is straight-alpha RGBA8, width * height * 4 bytes; it is premultiplied on the way to the GPU.

Registered on the scene, because the texture map is device-scoped: every player in the window sees it, and a pack shown five times is uploaded once. Embedded-mode packs need no call โ€” their atlases load with the pack.

Fails with SS_ERROR_INVALID_ARGUMENT, uploading nothing, when the device cannot hold the texture: wider or taller than its max_texture_dimension_2d (8192 on the device this library asks for), or empty.

ยงSafety

rgba must point at width * height * 4 readable bytes. It is not retained.