feat: Added swappability of the renderer and added a Renderer trait to make custom renderers if needed. Also renamed Renderer2D component to Render2D because it is a "render component" and not a renderer (but also name to avoid name clashes)

This commit is contained in:
lisk77 2024-11-29 01:29:57 +01:00
parent 29355335e6
commit a3df3f4f17
5 changed files with 133 additions and 129 deletions

View file

@ -0,0 +1,12 @@
use std::sync::Arc;
use winit::dpi::PhysicalSize;
use winit::window::Window;
use comet_colors::LinearRgba;
pub trait Renderer: Sized {
async fn new(window: Arc<Window>, clear_color: Option<LinearRgba>) -> Self;
fn size(&self) -> PhysicalSize<u32>;
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>);
fn update(&mut self) -> f32;
fn render(&mut self) -> Result<(), wgpu::SurfaceError>;
}