pub struct SceneRenderer { /* private fields */ }Expand description
Unified renderer over the CPU and GPU paths. See the crate docs.
Implementations§
Source§impl SceneRenderer
impl SceneRenderer
Sourcepub fn new(window: Arc<Window>, opts: &RenderOptions) -> Self
pub fn new(window: Arc<Window>, opts: &RenderOptions) -> Self
Build a renderer for window. Selects the GPU backend when
opts.want_gpu and WGPU initialises; otherwise the CPU
backend. Never fails — a missing/incompatible GPU silently
yields the CPU path (the message is logged to stderr).
Sourcepub fn adapter_info(&self) -> Option<&str>
pub fn adapter_info(&self) -> Option<&str>
The GPU adapter description when on the GPU backend, else
None.
Sourcepub fn set_sky_panorama(&mut self, rgba: &[u8], w: u32, h: u32)
pub fn set_sky_panorama(&mut self, rgba: &[u8], w: u32, h: u32)
Upload an equirectangular sky panorama (RGBA8, w×h) for the
GPU marcher’s sky sampling. No-op on the CPU backend, which
samples the Sky passed in each FrameParams instead.
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Follow a window resize. CPU resizes its framebuffer lazily, so this only matters to the GPU swapchain — but it’s safe to call for both.
Sourcepub fn render(
&mut self,
scene: &mut Scene,
camera: &Camera,
frame: &FrameParams<'_>,
)
pub fn render( &mut self, scene: &mut Scene, camera: &Camera, frame: &FrameParams<'_>, )
Render scene from view with frame params and present to
the window. The CPU backend fills sky, runs the opticast
compositor, and presents via softbuffer; the GPU backend
uploads/refreshes the scene and runs the compute marcher, then
the sprite pass.
Sourcepub fn set_sprites(&mut self, set: &SpriteSet)
pub fn set_sprites(&mut self, set: &SpriteSet)
Register sprite models + instances. The CPU backend builds a per-instance draw list; the GPU backend builds an instanced model registry. Call once at setup (or again to replace).
Sourcepub fn carve_active_sprite(&mut self) -> u32
pub fn carve_active_sprite(&mut self) -> u32
Carve the next z-layer off the SpriteSet::carve_model and
re-upload (the demo’s G hotkey + GPU.12 copy-on-modify). GPU
only; a no-op on the CPU backend. Returns the voxels removed.
Sourcepub fn request_capture(&mut self)
pub fn request_capture(&mut self)
Request that the next render capture its
framebuffer for take_capture. CPU only
(the GPU swapchain isn’t read back) — a no-op on GPU.
Auto Trait Implementations§
impl !RefUnwindSafe for SceneRenderer
impl !Sync for SceneRenderer
impl !UnwindSafe for SceneRenderer
impl Freeze for SceneRenderer
impl Send for SceneRenderer
impl Unpin for SceneRenderer
impl UnsafeUnpin for SceneRenderer
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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