Engine structure

This commit is contained in:
2026-01-28 10:27:18 +01:00
parent 665b502a09
commit 011b1ab963
6 changed files with 178 additions and 93 deletions
+32
View File
@@ -0,0 +1,32 @@
pub mod benchmark;
pub mod console;
pub use benchmark::*;
pub use console::*;
use std::sync::Arc;
use crate::{prelude::Context, render::Area, DrawContext, View};
pub trait Engine {
fn run<F: Fn(&Arc<Context>) -> View + Send + Sync + 'static>(&self, component: F) {
let cx = self.init(component);
loop {
self.render(&cx);
self.render_delay();
}
}
fn init<F: Fn(&Arc<Context>) -> View + Send + Sync + 'static>(
&self,
component: F,
) -> Arc<Context>;
fn render(&self, cx: &Arc<Context>);
fn render_delay(&self) {
std::thread::sleep(std::time::Duration::from_millis(16))
}
fn render_view(&self, area: &Area, view: &View) -> DrawContext;
fn draw_context(&self, ctx: &DrawContext);
}