Expand description
roxlap-render — unified CPU/GPU renderer facade.
One SceneRenderer hides the choice between the CPU opticast
path (roxlap-core / roxlap-scene, presented via softbuffer)
and the GPU compute-shader path (roxlap-gpu, presented via its
own wgpu surface). Construction picks the GPU backend when asked
and able, and falls back to CPU automatically when WGPU init
fails — so a host never has to branch on GPU availability or carry
the Scene→GPU upload/refresh/transform glue itself.
Hosts stay thin: build a Scene, advance it from input, then call
SceneRenderer::render each frame. The facade owns the window
surface, the framebuffer/z-buffer (CPU) or the resident scene +
dirty-chunk tracking (GPU), and presentation.
This is the RF.0 skeleton: backend selection + fallback + a clear-to-sky frame. RF.1/RF.2 fill in the real CPU/GPU scene render; RF.3 adds sprites; RF.4 adds framebuffer capture.
Structs§
- Frame
Params - Per-frame inputs both backends consume. The host builds the
OpticastSettings(it owns scan distance etc.); the facade does everything else (pool config, sky fill, render, present). - GpuRenderer
Settings - Caller-controllable knobs for
GpuRenderer::new. Defaults target “highest-performance GPU, prefer Mailbox/Immediate over vsync” — i.e. the same configuration the GPU.0 probe used to measure the FPS ceiling. - PickHit
- Result of
SceneRenderer::pick— a resolved screen→world voxel hit.worldis the surface point (cam.pos + t · normalize(ray));grid+voxelare the owning grid and its grid-local voxel (transform-correct for rotated / translated grids). - Ray
- A world-space view ray: the canonical unproject output of
SceneRenderer::view_ray.diris unit-length. Feed it straight toroxlap_scene::Scene::raycastfor depth-free, backend-agnostic voxel picking (scene.raycast(ray.origin, ray.dir, max_dist)), or intersect it with a plane for tile selection. - Render
Options - Construction-time options for
SceneRenderer::new. - Scene
Renderer - Unified renderer over the CPU and GPU paths. See the crate docs.
- Sprite
- A KV6 voxel sprite positioned in world space.
- Sprite
Instance Desc - One placed sprite instance: which
SpriteSet::modelsentry and where in the world. - Sprite
Set - Backend-agnostic sprite description. The facade builds the CPU
per-instance draw list and the GPU instanced registry from the
same data, so both backends show identical sprites. The host owns
content (which models, where, recolouring) — building a recoloured
variant is just a second
Spritemodel with editedkv6.voxels.
Enums§
- Backend
- Which renderer a
SceneRendererresolved to at construction. - GpuInit
Error - Errors
GpuRenderer::newsurfaces to the host. The host’s expected flow is “try this, fall back to the CPU path on Err”.
Traits§
- HasDisplay
Handle - A display that acts as a wrapper around a display handle.
- HasWindow
Handle - A handle to a window.