Create event loop

This commit is contained in:
Hanno Braun 2024-10-30 01:44:03 +01:00
parent 99275c1404
commit 3c0ff8bffc

View File

@ -1,5 +1,38 @@
use winit::{
application::ApplicationHandler,
event::WindowEvent,
event_loop::{ActiveEventLoop, EventLoop},
window::{Window, WindowAttributes, WindowId},
};
use crate::mesh::Mesh;
pub fn render(_: &Mesh) -> anyhow::Result<()> {
let event_loop = EventLoop::new()?;
let mut app = App { window: None };
event_loop.run_app(&mut app)?;
Ok(())
}
struct App {
window: Option<Window>,
}
impl ApplicationHandler for App {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let window = event_loop
.create_window(WindowAttributes::default())
.unwrap();
self.window = Some(window);
}
fn window_event(
&mut self,
_: &ActiveEventLoop,
_: WindowId,
_: WindowEvent,
) {
}
}