feat(client): implement main event loop and tracing initialization
Added winit event loop with ControlFlow::Poll for continuous rendering, and initialized tracing-subscriber for standardized logging. Also integrated anyhow for robust error handling in the client binary.
This commit is contained in:
parent
fdf39ceaa3
commit
9e56bccb05
761
Cargo.lock
generated
761
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,5 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
image = "0.25.10"
|
anyhow = "1.0.102"
|
||||||
|
tracing = "0.1.44"
|
||||||
|
tracing-subscriber = "0.3.23"
|
||||||
winit = "0.30.13"
|
winit = "0.30.13"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use tracing::info;
|
||||||
use winit::application::ApplicationHandler;
|
use winit::application::ApplicationHandler;
|
||||||
use winit::event::WindowEvent;
|
use winit::event::WindowEvent;
|
||||||
use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop};
|
use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop};
|
||||||
|
|
@ -42,13 +44,15 @@ impl ApplicationHandler for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() -> Result<()> {
|
||||||
let event_loop = EventLoop::new().unwrap();
|
tracing_subscriber::fmt().init();
|
||||||
|
info!("Starting Project Catalyst client");
|
||||||
|
|
||||||
|
let event_loop = EventLoop::new().context("Failed to create event loop")?;
|
||||||
|
|
||||||
// ControlFlow::Poll continuously runs the event loop, even if the OS hasn't
|
|
||||||
// dispatched any events. This is ideal for games and similar applications.
|
|
||||||
event_loop.set_control_flow(ControlFlow::Poll);
|
event_loop.set_control_flow(ControlFlow::Poll);
|
||||||
|
|
||||||
let mut app = App::default();
|
let mut app = App::default();
|
||||||
event_loop.run_app(&mut app).unwrap();
|
event_loop.run_app(&mut app).context("Failed to run event loop")?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue