pub trait Backend:
Sized
+ Sync
+ Send
+ 'static {
type Frame: FrameOperations;
// Required methods
fn init(
handle: impl GPUSurfaceHandle,
width: u32,
height: u32,
sender: InitSender<Self>,
);
fn acquire(&mut self) -> Result<Self::Frame, AcquireError>;
fn present(&mut self, frame: Self::Frame);
// Provided method
fn resize(&mut self, width: u32, height: u32) { ... }
}Expand description
A unified graphics backend for both native and web targets.
Implement this trait to integrate a concrete graphics API (e.g. wgpu).
Initialisation is always done via the InitSender channel so that
implementations can choose to do it synchronously or on a background thread.
Required Associated Types§
Sourcetype Frame: FrameOperations
type Frame: FrameOperations
The per-frame type that exposes rendering operations.
Required Methods§
Sourcefn init(
handle: impl GPUSurfaceHandle,
width: u32,
height: u32,
sender: InitSender<Self>,
)
fn init( handle: impl GPUSurfaceHandle, width: u32, height: u32, sender: InitSender<Self>, )
Begin initialisation. Send the finished backend through sender when ready.
Sourcefn acquire(&mut self) -> Result<Self::Frame, AcquireError>
fn acquire(&mut self) -> Result<Self::Frame, AcquireError>
Acquire the next frame for rendering.
Returns AcquireError::Transient for recoverable failures (e.g.
swapchain out of date) and AcquireError::Fatal for unrecoverable ones.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".