Begin add Window Render Context
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 26m40s

This commit is contained in:
Florian RICHER 2025-04-13 19:23:05 +02:00
parent e2616a0ef5
commit a04c769438
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
5 changed files with 163 additions and 14 deletions

View file

@ -1,23 +1,22 @@
use std::sync::Arc;
use bevy_ecs::world::World;
use winit::{
application::ApplicationHandler,
event::WindowEvent,
event_loop::ActiveEventLoop,
window::{Window, WindowId},
application::ApplicationHandler, event::WindowEvent, event_loop::ActiveEventLoop,
window::WindowId,
};
use crate::core::app::App;
use super::config::WindowConfig;
use super::{config::WindowConfig, raw_handle::WindowWrapper};
pub struct WindowState {
app: App,
window: Option<Window>,
}
impl WindowState {
pub fn new(app: App) -> Self {
Self { app, window: None }
Self { app }
}
fn world(&self) -> &World {
@ -30,7 +29,9 @@ impl ApplicationHandler for WindowState {
let window_config = self.world().get_resource::<WindowConfig>().unwrap();
let window = event_loop.create_window(window_config.into()).unwrap();
self.window = Some(window);
self.app
.world_mut()
.insert_resource(WindowWrapper(Arc::new(window)));
}
fn window_event(&mut self, event_loop: &ActiveEventLoop, _id: WindowId, event: WindowEvent) {