DeviceBackend

Trait DeviceBackend 

Source
pub trait DeviceBackend {
Show 18 methods // Required methods fn api_name(&self) -> &str; fn stats(&self) -> GpuStats; fn reset_stats(&mut self); fn create_pipeline( &mut self, vertex_source: &[u8], fragment_source: &[u8], vertex_attrs: &[VertexAttr], texture_locations: &[(u32, String)], options: PipelineOptions, ) -> Result<u64, String>; fn create_vertex_buffer( &mut self, attrs: &[VertexAttr], step_mode: VertexStepMode, ) -> Result<u64, String>; fn create_index_buffer( &mut self, format: IndexFormat, ) -> Result<u64, String>; fn create_uniform_buffer( &mut self, slot: u32, name: &str, ) -> Result<u64, String>; fn set_buffer_data(&mut self, buffer: u64, data: &[u8]); fn render(&mut self, commands: &[Commands], target: Option<u64>); fn clean(&mut self, to_clean: &[ResourceId]); fn set_size(&mut self, width: u32, height: u32); fn set_dpi(&mut self, scale_factor: f64); fn create_texture( &mut self, source: TextureSourceKind, info: TextureInfo, ) -> Result<(u64, TextureInfo), String>; fn create_render_texture( &mut self, texture_id: u64, info: &TextureInfo, ) -> Result<u64, String>; fn update_texture( &mut self, texture: u64, source: TextureUpdaterSourceKind<'_>, opts: TextureUpdate, ) -> Result<(), String>; fn read_pixels( &mut self, texture: u64, bytes: &mut [u8], opts: &TextureRead, ) -> Result<(), String>; fn as_any_mut(&mut self) -> &mut (dyn Any + 'static); // Provided method fn limits(&self) -> Limits { ... }
}
Expand description

Represents a the implementation graphics backend like glow, wgpu or another

Required Methods§

Source

fn api_name(&self) -> &str

Returns the name of the api used (like webgl, wgpu, etc…)

Source

fn stats(&self) -> GpuStats

Return the GPU stats

Source

fn reset_stats(&mut self)

Reset the GPU stats

Source

fn create_pipeline( &mut self, vertex_source: &[u8], fragment_source: &[u8], vertex_attrs: &[VertexAttr], texture_locations: &[(u32, String)], options: PipelineOptions, ) -> Result<u64, String>

Create a new pipeline and returns the id

Source

fn create_vertex_buffer( &mut self, attrs: &[VertexAttr], step_mode: VertexStepMode, ) -> Result<u64, String>

Create a new vertex buffer object and returns the id

Source

fn create_index_buffer(&mut self, format: IndexFormat) -> Result<u64, String>

Create a new index buffer object and returns the id

Source

fn create_uniform_buffer( &mut self, slot: u32, name: &str, ) -> Result<u64, String>

Create a new uniform buffer and returns the id

Source

fn set_buffer_data(&mut self, buffer: u64, data: &[u8])

Upload to the GPU the buffer data slice

Source

fn render(&mut self, commands: &[Commands], target: Option<u64>)

Create a new renderer using the size of the graphics

Source

fn clean(&mut self, to_clean: &[ResourceId])

Clean all the dropped resources

Source

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

Sets the render size

Source

fn set_dpi(&mut self, scale_factor: f64)

Sets the screen dpi

Source

fn create_texture( &mut self, source: TextureSourceKind, info: TextureInfo, ) -> Result<(u64, TextureInfo), String>

Create a new texture and returns the id

Source

fn create_render_texture( &mut self, texture_id: u64, info: &TextureInfo, ) -> Result<u64, String>

Create a new render target and returns the id

Source

fn update_texture( &mut self, texture: u64, source: TextureUpdaterSourceKind<'_>, opts: TextureUpdate, ) -> Result<(), String>

Update texture data

Source

fn read_pixels( &mut self, texture: u64, bytes: &mut [u8], opts: &TextureRead, ) -> Result<(), String>

Read texture pixels

Source

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Provided Methods§

Source

fn limits(&self) -> Limits

Return the device limits

Implementors§