pub struct ScanlineInterp { /* private fields */ }Expand description
Per-scanline interpolator for z-buffer depth and (u, v) texture coordinates.
Pre-computes Q16.16 per-pixel step values for z, u, and v so the
inner loop only does three wrapping additions instead of floating-point
divisions per pixel — useful for MCU scanline rasterization.
§Usage
let mut interp = ScanlineInterp::new(
left_z, right_z, // u32 depth values (Q16.16)
left_u, right_u, // u32 U texture coords (Q16.16)
left_v, right_v, // u32 V texture coords (Q16.16)
span_pixels, // number of pixels across the scanline
);
for _x in 0..=span_pixels {
let z = interp.z();
let u = interp.u();
let v = interp.v();
// ... depth test, texture sample, write pixel ...
interp.step();
}Implementations§
Source§impl ScanlineInterp
impl ScanlineInterp
Sourcepub fn new(
z_left: u32,
z_right: u32,
u_left: u32,
u_right: u32,
v_left: u32,
v_right: u32,
span: i32,
) -> Self
pub fn new( z_left: u32, z_right: u32, u_left: u32, u_right: u32, v_left: u32, v_right: u32, span: i32, ) -> Self
Create a new scanline interpolator.
§Arguments
z_left,z_right— depth at the left and right scanline endpoints (Q16.16u32)u_left,u_right— U texture coordinates (Q16.16u32, range[0, 65536])v_left,v_right— V texture coordinates (Q16.16u32, range[0, 65536])span— number of pixels across the scanline (0 is valid — returns left values)
Sourcepub fn depth_only(z_left: u32, z_right: u32, span: i32) -> Self
pub fn depth_only(z_left: u32, z_right: u32, span: i32) -> Self
Create an interpolator for depth-only scanlines (no texture mapping).
Trait Implementations§
Source§impl Clone for ScanlineInterp
impl Clone for ScanlineInterp
Source§fn clone(&self) -> ScanlineInterp
fn clone(&self) -> ScanlineInterp
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ScanlineInterp
Auto Trait Implementations§
impl Freeze for ScanlineInterp
impl RefUnwindSafe for ScanlineInterp
impl Send for ScanlineInterp
impl Sync for ScanlineInterp
impl Unpin for ScanlineInterp
impl UnsafeUnpin for ScanlineInterp
impl UnwindSafe for ScanlineInterp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more