Skip to main content

WgpuRenderer

Struct WgpuRenderer 

Source
pub struct WgpuRenderer<'a> { /* private fields */ }
Expand description

WGPU-based renderer implementation.

Implementations§

Source§

impl<'a> WgpuRenderer<'a>

Source

pub fn viewport(&self) -> (f64, f64)

Get current viewport size.

Source

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

Set the active camera.

Source

pub fn clear(&self, color: &str)

Clear the frame to a solid background color.

Source

pub fn project(&self, world: Vec3) -> Option<ScreenPoint>

Project a world-space point to screen space.

Source

pub fn clear_node_positions(&mut self)

Clear tracked node positions (call before each render).

Source

pub fn get_node_positions(&self) -> &[(usize, ScreenPoint, f64)]

Get tracked node positions (for epistemic anchor coordination).

Source

pub fn hit_test(&self, point: ScreenPoint) -> Option<usize>

Hit test: find which node contains the given screen point.

Returns the binary node index if a hit is found, None otherwise. Zero-heap: uses stack-allocated f64 values for ray calculations.

Source

pub fn pick_anchor(&self, x: f64, y: f64) -> Option<usize>

Coordinate epistemic anchor at screen coordinates (x, y in physical pixels).

Source

pub fn pick(&self, x: f64, y: f64) -> Option<usize>

👎Deprecated:

Use pick_anchor() for epistemic anchor coordination

Legacy method for backward compatibility - use pick_anchor() for epistemic anchor coordination.

Source

pub fn hover_anchor(&self, x: f64, y: f64) -> Option<usize>

Check if mouse is hovering over epistemic anchor at screen coordinates (x, y in physical pixels).

Source

pub fn hover(&self, x: f64, y: f64) -> Option<usize>

👎Deprecated:

Use hover_anchor() for epistemic anchor coordination

Legacy method for backward compatibility - use hover_anchor() for epistemic anchor coordination.

Source

pub fn line( &self, a: ScreenPoint, b: ScreenPoint, color: &str, alpha: f64, width: f64, )

Draw a screen-space line segment.

Source

pub fn point(&self, p: ScreenPoint, radius: f64, color: &str, alpha: f64)

Draw a filled screen-space disc (billboarded point).

Source

pub fn fill_polygon(&self, points: &[ScreenPoint], color: &str, alpha: f64)

Fill a screen-space polygon.

Source§

impl<'a> WgpuRenderer<'a>

Source

pub fn read_pixels_with_receipt(&self) -> PixelReadback

Attempt a bounded pixel readback and return both bytes and evidence.

Source

pub fn read_pixels(&self) -> Option<Vec<u8>>

Read the offscreen target to a tightly-packed RGBA8 buffer (width * height * 4 bytes, row-major). Returns None for refusal.

Source

pub fn runtime_receipt(&self) -> WebGpuRuntimeReceipt

Return a complete bounded runtime receipt after attempting readback.

Source

pub fn read_png(&self) -> Option<Vec<u8>>

Read the offscreen target back as PNG-encoded bytes, ready to hand to a webview as a data-URI or via a custom protocol. Returns None for surface targets or if there is no GPU frame to read. Native-only (the wasm build renders to a <canvas> and never reads back).

Source

pub fn read_data_uri(&self) -> Option<String>

Read the offscreen frame back as a data:image/png;base64,... URI — drop straight into a webview <img src>. Native-only.

Source§

impl<'a> WgpuRenderer<'a>

Source

pub async fn new( surface: Surface<'a>, width: u32, height: u32, ) -> Result<Self, String>

Create a new WgpuRenderer that draws to a window surface.

Source

pub async fn new_offscreen( width: u32, height: u32, ) -> Result<WgpuRenderer<'static>, String>

Create a headless renderer that draws to an offscreen texture.

Source

pub fn capabilities(&self) -> &WebGpuCapabilityReport

Return the bounded capability facts observed while constructing this renderer.

Source

pub fn offscreen_extent(&self) -> Option<(u32, u32)>

Return the effective offscreen extent, or None for a surface target.

Source

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

Resize the render target.

Source

pub fn try_resize( &mut self, width: u32, height: u32, ) -> Result<(u32, u32), String>

Resize while retaining the old target if the shared graphics budget cannot admit the replacement. Offscreen targets may degrade by powers of two and return their effective dimensions.

Auto Trait Implementations§

§

impl<'a> !Freeze for WgpuRenderer<'a>

§

impl<'a> !RefUnwindSafe for WgpuRenderer<'a>

§

impl<'a> !UnwindSafe for WgpuRenderer<'a>

§

impl<'a> Send for WgpuRenderer<'a>

§

impl<'a> Sync for WgpuRenderer<'a>

§

impl<'a> Unpin for WgpuRenderer<'a>

§

impl<'a> UnsafeUnpin for WgpuRenderer<'a>

Blanket Implementations§

§

impl<S, A> Aggregate<Result<S, Error>> for A
where A: Aggregate<S>,

§

fn from_shares<T>(iter: T) -> Result<A, Error>
where T: IntoIterator<Item = Result<S, Error>>,

Aggregate shares in an MPC protocol.
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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more