Skip to main content

drawtile

Function drawtile 

Source
pub fn drawtile(
    target: &mut DrawTarget<'_>,
    tile_pixels: &[i32],
    tile_pitch_bytes: i32,
    tx: i32,
    ty: i32,
    tcx: i32,
    tcy: i32,
    sx: i32,
    sy: i32,
    xz: i32,
    yz: i32,
    black: i32,
    white: i32,
)
Expand description

Render one screen-space tile blit. Mirror of voxlap5.c:6954-7082.

Parameters mirror voxlap’s call signature:

  • target: framebuffer + dimensions. Z-buffer is unused.
  • tile_pixels: source pixels, row-major BGRA i32. Length must accommodate (ty - 1) * (tile_pitch_bytes / 4) + tx.
  • tile_pitch_bytes: byte stride between source rows (voxlap’s tp). Typically tx * 4.
  • (tx, ty): source tile dimensions in pixels.
  • (tcx, tcy): tile centre in source-pixel Q16.16 coordinates. Voxlap uses this to anchor the tile so the centre lands at (sx, sy) regardless of zoom.
  • (sx, sy): screen-space anchor in Q16.16. The tile centre (tcx, tcy) ends up at this screen position.
  • (xz, yz): per-axis zoom in Q16.16. 65536 = 1×; 32768 = 0.5× (triggers the 2×2-average fast path); anything else takes the texture-stretch path.
  • black, white: alpha-modulation endpoints. If the alpha bytes are equal, the alpha path is skipped (the colour modulation would be a constant tint applied to every pixel and voxlap special-cases it as “no alpha”). Otherwise: each source pixel’s bytes get linearly remapped from [0, 255] to [black_byte, white_byte], then the modulated alpha byte drives an alpha-blend onto the framebuffer.