1786013239

This commit is contained in:
2026-08-06 12:47:19 +02:00
parent 86f391fc78
commit 8b62c96271
2 changed files with 11 additions and 24 deletions

View File

@@ -1,20 +1,10 @@
mod rgba; mod rgba;
mod trekstor; mod trekstor;
use embedded_graphics::{prelude::*, primitives::*};
use evdev::KeyCode;
use crate::trekstor::Trekstor; use crate::trekstor::Trekstor;
struct AppState {
x: i32,
y: i32,
}
fn main() { fn main() {
let app_state = AppState { x: 0, y: 0 }; let mut trekstor = Trekstor::new(30);
let mut trekstor = Trekstor::new(60, app_state);
trekstor.update(); trekstor.update();

View File

@@ -13,8 +13,6 @@ use crate::rgba::Rgba;
use self::input::InputState; use self::input::InputState;
use self::screen::Screen; use self::screen::Screen;
type UpdateFn<S> = fn(&mut Context, &mut S) -> bool;
mod input; mod input;
mod screen; mod screen;
@@ -23,8 +21,7 @@ pub struct Context {
pub input: InputState, pub input: InputState,
} }
pub struct Trekstor<S> { pub struct Trekstor {
state: S,
ctx: Context, ctx: Context,
window: Rc<MinimalSoftwareWindow>, window: Rc<MinimalSoftwareWindow>,
// buffer: Vec<Rgba8Pixel>, // buffer: Vec<Rgba8Pixel>,
@@ -33,14 +30,13 @@ pub struct Trekstor<S> {
update_timestep: Duration, update_timestep: Duration,
} }
impl<S> Trekstor<S> { impl Trekstor {
pub fn new(update_fps: i32, state: S) -> Self { pub fn new(update_fps: i32) -> Self {
let screen = Screen::new(); let screen = Screen::new();
let input = InputState::new(&screen); let input = InputState::new(&screen);
let window = MinimalSoftwareWindow::new(RepaintBufferType::ReusedBuffer); let window = MinimalSoftwareWindow::new(RepaintBufferType::ReusedBuffer);
Self { Self {
state,
ctx: Context { screen, input }, ctx: Context { screen, input },
window, window,
// buffer: Vec::new(), // buffer: Vec::new(),
@@ -95,13 +91,14 @@ impl<S> Trekstor<S> {
} }
self.window.draw_if_needed(|renderer| { self.window.draw_if_needed(|renderer| {
dbg!("Rendering");
renderer.render(&mut buffer1, self.ctx.screen.width() as usize); renderer.render(&mut buffer1, self.ctx.screen.width() as usize);
});
self.ctx self.ctx
.screen .screen
.fill_contiguous(&self.ctx.screen.rect(), buffer1) .fill_contiguous(&self.ctx.screen.rect(), buffer1)
.unwrap(); .ok();
});
self.ctx.screen.flush(); self.ctx.screen.flush();
self.ctx.input.finish(); self.ctx.input.finish();
@@ -109,7 +106,7 @@ impl<S> Trekstor<S> {
} }
} }
impl<S> Platform for Trekstor<S> { impl Platform for Trekstor {
fn create_window_adapter( fn create_window_adapter(
&self, &self,
) -> Result<Rc<dyn slint::platform::WindowAdapter>, slint::PlatformError> { ) -> Result<Rc<dyn slint::platform::WindowAdapter>, slint::PlatformError> {