1786013239
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -1,20 +1,10 @@
|
||||
mod rgba;
|
||||
mod trekstor;
|
||||
|
||||
use embedded_graphics::{prelude::*, primitives::*};
|
||||
use evdev::KeyCode;
|
||||
|
||||
use crate::trekstor::Trekstor;
|
||||
|
||||
struct AppState {
|
||||
x: i32,
|
||||
y: i32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let app_state = AppState { x: 0, y: 0 };
|
||||
|
||||
let mut trekstor = Trekstor::new(60, app_state);
|
||||
let mut trekstor = Trekstor::new(30);
|
||||
|
||||
trekstor.update();
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ use crate::rgba::Rgba;
|
||||
use self::input::InputState;
|
||||
use self::screen::Screen;
|
||||
|
||||
type UpdateFn<S> = fn(&mut Context, &mut S) -> bool;
|
||||
|
||||
mod input;
|
||||
mod screen;
|
||||
|
||||
@@ -23,8 +21,7 @@ pub struct Context {
|
||||
pub input: InputState,
|
||||
}
|
||||
|
||||
pub struct Trekstor<S> {
|
||||
state: S,
|
||||
pub struct Trekstor {
|
||||
ctx: Context,
|
||||
window: Rc<MinimalSoftwareWindow>,
|
||||
// buffer: Vec<Rgba8Pixel>,
|
||||
@@ -33,14 +30,13 @@ pub struct Trekstor<S> {
|
||||
update_timestep: Duration,
|
||||
}
|
||||
|
||||
impl<S> Trekstor<S> {
|
||||
pub fn new(update_fps: i32, state: S) -> Self {
|
||||
impl Trekstor {
|
||||
pub fn new(update_fps: i32) -> Self {
|
||||
let screen = Screen::new();
|
||||
let input = InputState::new(&screen);
|
||||
let window = MinimalSoftwareWindow::new(RepaintBufferType::ReusedBuffer);
|
||||
|
||||
Self {
|
||||
state,
|
||||
ctx: Context { screen, input },
|
||||
window,
|
||||
// buffer: Vec::new(),
|
||||
@@ -95,13 +91,14 @@ impl<S> Trekstor<S> {
|
||||
}
|
||||
|
||||
self.window.draw_if_needed(|renderer| {
|
||||
dbg!("Rendering");
|
||||
renderer.render(&mut buffer1, self.ctx.screen.width() as usize);
|
||||
});
|
||||
|
||||
self.ctx
|
||||
.screen
|
||||
.fill_contiguous(&self.ctx.screen.rect(), buffer1)
|
||||
.unwrap();
|
||||
self.ctx
|
||||
.screen
|
||||
.fill_contiguous(&self.ctx.screen.rect(), buffer1)
|
||||
.ok();
|
||||
});
|
||||
|
||||
self.ctx.screen.flush();
|
||||
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(
|
||||
&self,
|
||||
) -> Result<Rc<dyn slint::platform::WindowAdapter>, slint::PlatformError> {
|
||||
|
||||
Reference in New Issue
Block a user