First vulkan init working
This commit is contained in:
parent
6639f0bb1e
commit
99be029ff8
4 changed files with 36 additions and 28 deletions
|
@ -1,4 +1,4 @@
|
|||
use bevy_app::{App, AppExit, PluginsState};
|
||||
use bevy_app::{App, AppExit, Plugin, PluginsState};
|
||||
use config::WindowConfig;
|
||||
use raw_handle::{DisplayHandleWrapper, EventLoopProxyWrapper};
|
||||
use state::WindowState;
|
||||
|
@ -14,23 +14,24 @@ pub enum WindowError {
|
|||
FailedToCreateEventLoop,
|
||||
}
|
||||
|
||||
pub struct Window;
|
||||
pub struct WindowPlugin {
|
||||
pub window_config: WindowConfig,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(app: &mut App, window_config: WindowConfig) -> Result<(), WindowError> {
|
||||
impl Plugin for WindowPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
let world = app.world_mut();
|
||||
world.insert_resource(window_config);
|
||||
world.insert_resource(self.window_config.clone());
|
||||
|
||||
let mut event_loop_builder = EventLoop::with_user_event();
|
||||
let event_loop = event_loop_builder
|
||||
.build()
|
||||
.map_err(|_| WindowError::FailedToCreateEventLoop)?;
|
||||
.map_err(|_| WindowError::FailedToCreateEventLoop)
|
||||
.expect("Failed to create event loop");
|
||||
|
||||
world.insert_resource(DisplayHandleWrapper(event_loop.owned_display_handle()));
|
||||
|
||||
app.set_runner(Box::new(move |app| runner(app, event_loop)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue