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