cd examples

cargo run -p wsg-examples
This commit is contained in:
jerome
2026-07-03 14:46:59 +02:00
parent f46209a43c
commit 039f113831
7 changed files with 2675 additions and 420 deletions
+2406
View File
File diff suppressed because it is too large Load Diff
+6 -4
View File
@@ -1,11 +1,13 @@
[package]
name = "wsg-examples"
name = "wsg-examples" # On change le nom du package pour éviter le conflit "examples"
version = "0.1.0"
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"
winit = "=0.29" # Pinned — matches lib/ version exactly
[[bin]]
name = "demo" # Un nom de binaire qui ne risque pas de conflits
path = "main.rs" # On pointe directement vers le fichier à la racine du dossier
+17
View File
@@ -0,0 +1,17 @@
use std::sync::Arc;
use winit::event_loop::EventLoop;
use winit::window::WindowBuilder;
use wsg_lib::context::Context;
fn main() {
let event_loop = EventLoop::new().unwrap();
let window = Arc::new(WindowBuilder::new().build(&event_loop).unwrap());
// Utilisation de pollster pour le bloc async
let context = pollster::block_on(Context::new(window.clone()));
match context {
Ok(_) => println!("Succès : WGPU context initialisé !"),
Err(e) => eprintln!("Erreur lors de l'initialisation : {:?}", e),
}
}
-47
View File
@@ -1,47 +0,0 @@
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();
}