Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer {
Show 15 fields pub width: usize, pub height: usize, pub frame: Vec<u32>, col_pix: Vec<u32>, col_depth: Vec<f32>, col_mask: Vec<u32>, masked: Vec<Vec<MaskSeg>>, visited: Vec<AtomicU8>, pub sky_scale: f64, pub y_stretch: f64, pub phase_ms: [f64; 4], pub keep_rows: bool, col_portals: Vec<Vec<u32>>, pub stats_sectors: usize, pub stats_kinds: [usize; 5],
}

Fields§

§width: usize§height: usize§frame: Vec<u32>

Row-major output, 0x00RRGGBB.

§col_pix: Vec<u32>§col_depth: Vec<f32>§col_mask: Vec<u32>

Per pixel: id of the portal it was drawn through (0 = none).

§masked: Vec<Vec<MaskSeg>>§visited: Vec<AtomicU8>§sky_scale: f64

Horizontal sky texels per full turn multiplier (tuning knob).

§y_stretch: f64

Vertical stretch emulating the 320x200 pixel aspect (1.2 in the original).

§phase_ms: [f64; 4]

Milliseconds spent in the last frame: walls/planes, portal sprites + projection, masked walls + sprites, output copy.

§keep_rows: bool

Also produce the row-major Renderer::frame. Callers that scale the column-major image themselves (Renderer::columns) turn this off to skip a full-frame copy.

§col_portals: Vec<Vec<u32>>

Portal ids seen in each column during the wall pass.

§stats_sectors: usize§stats_kinds: [usize; 5]

Projected sprites by kind (face, wall, floor, voxel) and masked wall segments.

Implementations§

Source§

impl Renderer

Source

pub fn new(width: usize, height: usize) -> Self

Source

pub fn resize(&mut self, width: usize, height: usize)

Source

pub fn columns(&self) -> (&[u32], usize, usize)

The last frame in column-major order: (pixels, width, height), pixels[x * h + y].

Source

fn view(&self, cam: &Camera) -> View

Source

fn vis_shade(vis: f64, t: f64) -> i32

Distance in xy units for a depth value (used for fog/visibility shading).

Source

pub fn render(&mut self, scene: &Scene<'_>, cam: &Camera)

Source

pub fn depth_at(&self, x: usize, y: usize) -> f32

Depth (perpendicular distance) at screen pixel, for hit tests and debugging.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.