INNER CODE UNIT · Rust

to_c_texture

elringus/sprite-dicing · crates/abi/src/lib.rs:133

fn to_c_texture(texture: &Texture) -> sd_texture {
    let mut pixels: Vec<_> = texture.pixels.iter().map(to_c_pixel).collect();
    pixels.resize(
        pixel_count(texture.width, texture.height),
        sd_pixel::default(),
    );
    sd_texture {
        width: texture.width,
        height: texture.height,
        pixels: to_array(pixels).0,
    }
}

fn to_c_sprite(sprite: &DicedSprite) -> sd_diced_sprite {
    let (vertices, vertex_count) = to_array(sprite.vertices.iter().map(to_c_vertex).collect());
    let mut uvs: Vec<_> = sprite.uvs.iter().map(to_c_uv).collect();
    uvs.resize(vertex_count, sd_uv::default());
    let (indices, index_count) = to_array(sprite.indices.iter().map(|i| *i as u32).collect());

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…