Skip to main content

Renderer

Struct Renderer 

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

The wgpu renderer. Consumes scene deltas; owns only derived GPU/CPU caches.

Implementations§

Source§

impl Renderer

Source

pub fn new( device: Device, queue: Queue, format: TextureFormat, options: RendererOptions, ) -> Result<Self, RenderError>

Create a renderer drawing into targets of format.

The device should be created with limits no larger than [wgpu::Limits::downlevel_webgl2_defaults] needs; the renderer uses only WebGL2-compatible features on every backend.

§Errors

RenderError::Font if the bundled font fails to load (never expected).

Source

pub fn device(&self) -> &Device

The device.

Source

pub fn queue(&self) -> &Queue

The queue.

Source

pub fn format(&self) -> TextureFormat

Target format.

Source

pub fn sample_count(&self) -> u32

MSAA sample count in use.

Source

pub fn apply_delta_bytes(&mut self, bytes: &[u8]) -> Result<(), RenderError>

Apply a binary scene delta (dotloom-scene format).

§Errors

RenderError::Scene for malformed input; the scene is left unchanged.

Source

pub fn apply_delta(&mut self, delta: SceneDelta)

Apply a decoded scene delta.

Source

pub fn scene(&self) -> &SceneCache

The scene cache.

Source

pub fn set_view(&mut self, view: View) -> Result<(), RenderError>

Set the camera.

§Errors

RenderError::InvalidView for non-finite or out-of-range values.

Source

pub fn view(&self) -> View

Current camera.

Source

pub fn set_theme(&mut self, theme: Theme)

Set colors (rebuilds cached geometry).

Source

pub fn theme(&self) -> &Theme

Current theme.

Source

pub fn set_grid(&mut self, grid: Grid)

Set grid settings.

Source

pub fn set_overlay(&mut self, overlay: Overlay)

Set the interaction overlay.

Source

pub fn set_hover(&mut self, id: Option<u64>)

Highlight one item as hovered (drawn on top as feedback).

Source

pub fn last_stats(&self) -> FrameStats

Statistics of the last frame.

Source

pub fn render(&mut self, target: &Texture) -> Result<FrameStats, RenderError>

Draw one frame into target (its size defines the viewport in device pixels).

§Errors

RenderError::Disposed after Renderer::dispose.

Source

pub fn dispose(&mut self)

Release all GPU resources now (buffers, textures). The renderer cannot draw afterwards. Dropping the renderer also releases them.

Source

pub fn is_disposed(&self) -> bool

Whether Renderer::dispose was called.

Trait Implementations§

Source§

impl Debug for Renderer

Source§

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

Formats the value using the given formatter. 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
§

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,

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.

§

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

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

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,