Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }
Expand description

Voxel engine state.

Implementations§

Source§

impl Engine

Source

pub fn new() -> Self

Construct a new Engine with default state — voxlap-blue sky, no fog, no per-side shading, default kv6 colour, no lights, no sky texture.

§Examples
use roxlap_core::Engine;

let mut engine = Engine::new();
engine.set_sky_color(0x80aa_ddff);
assert_eq!(engine.sky_color(), 0x80aa_ddff);
Source

pub fn set_camera(&mut self, camera: Camera)

Source

pub fn camera(&self) -> Camera

Source

pub fn set_sky_color(&mut self, color: u32)

Override the sky / background colour. Bytes are 0xAARRGGBB where AA is the voxlap-style “brightness” channel (0x80 is “normal” intensity, matching the engine’s other surface colours).

Source

pub fn sky_color(&self) -> u32

Source

pub fn set_fog(&mut self, color: u32, max_scan_dist: i32)

Configure fog. max_scan_dist <= 0 disables fog. Otherwise pixels at the maximum scan distance blend fully to fog_color (low 24 bits — alpha byte ignored). Voxlap’s vx5.maxscandist-based foglut is rebuilt downstream by ScanScratch::set_fog.

Source

pub fn fog_color(&self) -> u32

Source

pub fn fog_max_scan_dist(&self) -> i32

Source

pub fn set_side_shades( &mut self, top: i8, bot: i8, left: i8, right: i8, up: i8, down: i8, )

Voxlap’s setsideshades(top, bot, left, right, up, down) — per-side voxel darkening intensities. Each i8 is stamped onto the high byte of gcsub[2..7] (downstream by ScanScratch::set_side_shades). Pass (0,…,0) to disable (the oracle baseline); positive values like 15 / 31 give the directional darkening typical of voxlap’s classic games.

Source

pub fn side_shades(&self) -> [i8; 6]

Source

pub fn set_kv6col(&mut self, color: u32)

Sprite material colour — packed BGRA bytes, voxlap’s vx5.kv6col. R/G/B equal triggers update_reflects’s nolighta fast path.

Source

pub fn kv6col(&self) -> u32

Source

pub fn set_lightmode(&mut self, mode: u32)

Sprite lighting mode — voxlap’s vx5.lightmode. 0 / 1 → directional tint; 2 → point-light shading from Engine::lights. Other values clamp to 2 in voxlap.

Source

pub fn lightmode(&self) -> u32

Source

pub fn add_light(&mut self, light: LightSrc)

Append a light source. No upper bound enforced here — voxlap’s MAXLIGHTS (16) is the practical limit, but the rendering math just iterates whatever’s in the slice.

Source

pub fn clear_lights(&mut self)

Source

pub fn lights(&self) -> &[LightSrc]

Source

pub fn set_sky(&mut self, sky: Option<Sky>)

Set the sky texture used by the textured-startsky path. None reverts to the cheap solid-fill default.

Source

pub fn sky(&self) -> Option<&Sky>

Source

pub fn render( &mut self, pixels: &mut [u32], width: u32, height: u32, pitch_pixels: u32, )

Render one frame into the caller-owned ARGB framebuffer.

pixels is a row-major u32 buffer; pitch_pixels is the row stride in u32 elements (which equals width for a tightly- packed buffer, but may be larger when the host is e.g. an SDL2 streaming texture with per-row padding).

R3 is a stub that fills the visible region with sky_color. R4 replaces this with the real raycaster.

§Panics

Panics if pixels.len() < (height as usize) * (pitch_pixels as usize) or if width > pitch_pixels — i.e. when the buffer would not contain height rows of pitch_pixels u32 each, or when the visible width would overflow each row.

Trait Implementations§

Source§

impl Clone for Engine

Source§

fn clone(&self) -> Engine

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Engine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Engine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.