mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
upgrade wgpu and winit
This commit is contained in:
parent
e1fb86ef8e
commit
133cbe7846
2 changed files with 13 additions and 19 deletions
|
@ -7,9 +7,9 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
legion = { git = "https://github.com/TomGillen/legion.git", rev = "940ef3bfcb77e5d074ee3184b776ff1600da228d" }
|
legion = { git = "https://github.com/TomGillen/legion.git", rev = "940ef3bfcb77e5d074ee3184b776ff1600da228d" }
|
||||||
legion_transform = { path = "src/transform" }
|
legion_transform = { path = "src/transform" }
|
||||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "44fa1bc2fa208fa92f80944253e0da56cb7ac1fe"}
|
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "4a0da16fe6764c4e1dc918a31cbd7467d404df51"}
|
||||||
glam = "0.8.4"
|
glam = "0.8.4"
|
||||||
winit = "0.20.0-alpha4"
|
winit = "0.20.0-alpha6"
|
||||||
glsl-to-spirv = "0.1"
|
glsl-to-spirv = "0.1"
|
||||||
zerocopy = "0.2"
|
zerocopy = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -18,15 +18,15 @@ pub struct App {
|
||||||
pub window: Option<Window>,
|
pub window: Option<Window>,
|
||||||
pub render_graph: RenderGraph,
|
pub render_graph: RenderGraph,
|
||||||
pub swap_chain: Option<wgpu::SwapChain>,
|
pub swap_chain: Option<wgpu::SwapChain>,
|
||||||
pub scheduler: Schedule,
|
pub schedule: Schedule,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(world: World, schedule: Schedule, render_graph: RenderGraph) -> App {
|
pub fn new(world: World, schedule: Schedule, render_graph: RenderGraph) -> App {
|
||||||
App {
|
App {
|
||||||
world: world,
|
world,
|
||||||
scheduler: schedule,
|
schedule: schedule,
|
||||||
render_graph: render_graph,
|
render_graph,
|
||||||
swap_chain: None,
|
swap_chain: None,
|
||||||
window: None,
|
window: None,
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ impl App {
|
||||||
let mut time = self.world.resources.get_mut::<Time>().unwrap();
|
let mut time = self.world.resources.get_mut::<Time>().unwrap();
|
||||||
time.start();
|
time.start();
|
||||||
}
|
}
|
||||||
self.scheduler.execute(&mut self.world);
|
self.schedule.execute(&mut self.world);
|
||||||
self.render();
|
self.render();
|
||||||
{
|
{
|
||||||
let mut time = self.world.resources.get_mut::<Time>().unwrap();
|
let mut time = self.world.resources.get_mut::<Time>().unwrap();
|
||||||
|
@ -79,9 +79,8 @@ impl App {
|
||||||
let (window, size, surface) = {
|
let (window, size, surface) = {
|
||||||
let window = winit::window::Window::new(&event_loop).unwrap();
|
let window = winit::window::Window::new(&event_loop).unwrap();
|
||||||
window.set_title("bevy");
|
window.set_title("bevy");
|
||||||
window.set_inner_size((1280, 720).into());
|
window.set_inner_size(winit::dpi::LogicalSize::new(1280, 720));
|
||||||
let hidpi_factor = window.hidpi_factor();
|
let size = window.inner_size();
|
||||||
let size = window.inner_size().to_physical(hidpi_factor);
|
|
||||||
let surface = wgpu::Surface::create(&window);
|
let surface = wgpu::Surface::create(&window);
|
||||||
(window, size, surface)
|
(window, size, surface)
|
||||||
};
|
};
|
||||||
|
@ -89,8 +88,8 @@ impl App {
|
||||||
let swap_chain_descriptor = wgpu::SwapChainDescriptor {
|
let swap_chain_descriptor = wgpu::SwapChainDescriptor {
|
||||||
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
|
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
|
||||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||||
width: size.width.round() as u32,
|
width: size.width,
|
||||||
height: size.height.round() as u32,
|
height: size.height,
|
||||||
present_mode: wgpu::PresentMode::Vsync,
|
present_mode: wgpu::PresentMode::Vsync,
|
||||||
};
|
};
|
||||||
let swap_chain = device.create_swap_chain(&surface, &swap_chain_descriptor);
|
let swap_chain = device.create_swap_chain(&surface, &swap_chain_descriptor);
|
||||||
|
@ -118,12 +117,7 @@ impl App {
|
||||||
event: WindowEvent::Resized(size),
|
event: WindowEvent::Resized(size),
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let hidpi_factor = self.window.as_ref().unwrap().hidpi_factor();
|
self.resize(size.width, size.height);
|
||||||
let physical = size.to_physical(hidpi_factor);
|
|
||||||
log::info!("Resizing to {:?}", physical);
|
|
||||||
let width = physical.width.round() as u32;
|
|
||||||
let height = physical.height.round() as u32;
|
|
||||||
self.resize(width, height);
|
|
||||||
}
|
}
|
||||||
event::Event::WindowEvent { event, .. } => match event {
|
event::Event::WindowEvent { event, .. } => match event {
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
|
@ -142,7 +136,7 @@ impl App {
|
||||||
self.handle_event(event);
|
self.handle_event(event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
event::Event::EventsCleared => {
|
event::Event::MainEventsCleared => {
|
||||||
self.update();
|
self.update();
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
Loading…
Reference in a new issue