Skip to main content

WgpuBackend

Struct WgpuBackend 

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

wgpu-based render backend. Works with WebGL2/WebGPU in browser, Vulkan/Metal/DX12 natively.

Implementations§

Source§

impl WgpuBackend

Source

pub async fn new( surface: Surface<'static>, adapter: &Adapter, width: u32, height: u32, scale_factor: f32, ) -> Result<Self, RenderError>

Create a new WgpuBackend from an existing wgpu surface + adapter.

Trait Implementations§

Source§

impl RenderBackend for WgpuBackend

Source§

fn begin_frame(&mut self, _clear_color: Color) -> Result<(), RenderError>

Begin a new frame with the given clear color.
Source§

fn submit(&mut self, commands: &[RenderCommand]) -> Result<(), RenderError>

Submit render commands for the current frame.
Source§

fn present(&mut self) -> Result<(), RenderError>

Present the frame to the screen.
Source§

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

Resize the render surface.
Source§

fn load_texture( &mut self, width: u32, height: u32, data: &[u8], ) -> Result<u64, RenderError>

Load a texture from RGBA bytes, returns a texture ID.
Source§

fn size(&self) -> (u32, u32)

Get the current surface size.
Source§

fn scale_factor(&self) -> f32

Get the current scale factor.

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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

impl<T> Upcast<T> for T

Source§

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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