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
Generated
+18
View File
@@ -1242,6 +1242,12 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "pollster"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"
[[package]]
name = "portable-atomic"
version = "1.13.1"
@@ -1668,6 +1674,15 @@ dependencies = [
"strict-num",
]
[[package]]
name = "tokio"
version = "1.52.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe"
dependencies = [
"pin-project-lite",
]
[[package]]
name = "toml_datetime"
version = "1.1.1+spec-1.1.0"
@@ -2401,6 +2416,9 @@ checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
name = "wsg-examples"
version = "0.1.0"
dependencies = [
"pollster",
"tokio",
"winit",
"wsg-lib",
]
+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();
}