intégration execution example

This commit is contained in:
jerome
2026-07-03 14:07:44 +02:00
parent f66519eeab
commit f46209a43c
3 changed files with 67 additions and 2 deletions
+3
View File
@@ -6,3 +6,6 @@ edition = "2024"
[dependencies]
# On pointe vers le chemin relatif de la librairie
wsg-lib = { path = "../lib" }
pollster = "0.4.0"
tokio = { version = "1", features = ["rt-multi-thread"] }
winit = "0.30"
+46 -2
View File
@@ -1,3 +1,47 @@
fn main() {
todo!("later");
use winit::{
application::ApplicationHandler,
event::WindowEvent,
event_loop::{ActiveEventLoop, EventLoop},
window::{WindowAttributes, WindowId},
};
use std::sync::Arc;
use wsg_lib::context::Context;
struct AppState {
context: Option<Context>,
}
impl ApplicationHandler for AppState {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let window_attributes = WindowAttributes::default()
.with_title("Test WSG");
let window = Arc::new(
event_loop
.create_window(window_attributes)
.unwrap(),
);
let rt = tokio::runtime::Runtime::new().unwrap();
self.context = Some(rt.block_on(Context::new(window)).unwrap());
}
fn window_event(
&mut self,
_event_loop: &ActiveEventLoop,
_window_id: WindowId,
event: WindowEvent,
) {
match event {
WindowEvent::CloseRequested => {}, // stop the app
_ => (),
}
}
}
fn main() {
let mut app_state = AppState { context: None };
let event_loop = EventLoop::new().unwrap();
event_loop.run_app(&mut app_state).unwrap();
}