2022-06-10 13:43:33 +03:00
|
|
|
#![allow(clippy::single_match)]
|
|
|
|
|
2022-12-25 09:57:27 +02:00
|
|
|
#[cfg(not(wasm_platform))]
|
2023-04-11 12:50:52 +01:00
|
|
|
fn main() -> Result<(), impl std::error::Error> {
|
2023-06-19 11:46:38 -07:00
|
|
|
use std::{sync::Arc, thread, time};
|
2021-12-11 03:02:48 +01:00
|
|
|
|
|
|
|
use simple_logger::SimpleLogger;
|
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
2022-04-09 18:32:02 -07:00
|
|
|
event_loop::EventLoop,
|
2021-12-11 03:02:48 +01:00
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
|
|
|
|
2023-06-19 11:46:38 -07:00
|
|
|
#[path = "util/fill.rs"]
|
|
|
|
mod fill;
|
|
|
|
|
2020-09-09 17:58:30 -08:00
|
|
|
SimpleLogger::new().init().unwrap();
|
2020-02-15 19:38:29 +01:00
|
|
|
let event_loop = EventLoop::new();
|
|
|
|
|
2023-06-19 11:46:38 -07:00
|
|
|
let window = {
|
|
|
|
let window = WindowBuilder::new()
|
|
|
|
.with_title("A fantastic window!")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
Arc::new(window)
|
|
|
|
};
|
2020-02-15 19:38:29 +01:00
|
|
|
|
2023-06-19 11:46:38 -07:00
|
|
|
thread::spawn({
|
|
|
|
let window = window.clone();
|
|
|
|
move || loop {
|
|
|
|
thread::sleep(time::Duration::from_secs(1));
|
|
|
|
window.request_redraw();
|
|
|
|
}
|
2020-02-15 19:38:29 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2023-01-27 07:18:58 +03:00
|
|
|
println!("{event:?}");
|
2020-02-15 19:38:29 +01:00
|
|
|
|
2022-04-09 18:32:02 -07:00
|
|
|
control_flow.set_wait();
|
2020-02-15 19:38:29 +01:00
|
|
|
|
|
|
|
match event {
|
2022-06-10 13:43:33 +03:00
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
..
|
|
|
|
} => control_flow.set_exit(),
|
2020-02-15 19:38:29 +01:00
|
|
|
Event::RedrawRequested(_) => {
|
|
|
|
println!("\nredrawing!\n");
|
2023-06-19 11:46:38 -07:00
|
|
|
fill::fill_window(&window);
|
2020-02-15 19:38:29 +01:00
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
}
|
2023-04-11 12:50:52 +01:00
|
|
|
})
|
2020-02-15 19:38:29 +01:00
|
|
|
}
|
2021-10-26 20:05:01 +02:00
|
|
|
|
2022-12-25 09:57:27 +02:00
|
|
|
#[cfg(wasm_platform)]
|
2021-10-26 20:05:01 +02:00
|
|
|
fn main() {
|
|
|
|
unimplemented!() // `Window` can't be sent between threads
|
|
|
|
}
|