1use osmic_core::error::OsmicResult;
2
3use crate::scene::SceneGraph;
4
5#[derive(Debug, Clone)]
7pub struct RenderConfig {
8 pub width: u32,
9 pub height: u32,
10 pub background: osmic_core::Color,
11 pub pixel_ratio: f32,
13}
14
15impl Default for RenderConfig {
16 fn default() -> Self {
17 Self {
18 width: 1024,
19 height: 1024,
20 background: osmic_core::Color::from_hex("#f8f4f0").unwrap(),
21 pixel_ratio: 1.0,
22 }
23 }
24}
25
26pub trait RenderBackend {
28 fn init(config: &RenderConfig) -> OsmicResult<Self>
30 where
31 Self: Sized;
32
33 fn render(&mut self, scene: &SceneGraph) -> OsmicResult<()>;
35
36 fn read_pixels(&self) -> Option<Vec<u8>>;
38
39 fn resize(&mut self, width: u32, height: u32);
41}