mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Update wgpu and winit
This commit is contained in:
@@ -27,14 +27,14 @@ vulkan = ["wgn/vulkan-portability"]
|
||||
package = "wgpu-native"
|
||||
version = "0.4"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "c293d6dcea0170bfa3835cfbd919f300560e0da6"
|
||||
rev = "c0fa61a064c3572ee60d6c4c6a59ca0571394200"
|
||||
#path = "../wgpu/wgpu-native"
|
||||
|
||||
[dependencies.wgc]
|
||||
package = "wgpu-core"
|
||||
version = "0.1"
|
||||
git = "https://github.com/gfx-rs/wgpu"
|
||||
rev = "c293d6dcea0170bfa3835cfbd919f300560e0da6"
|
||||
rev = "c0fa61a064c3572ee60d6c4c6a59ca0571394200"
|
||||
#path = "../wgpu/wgpu-core"
|
||||
|
||||
[dependencies]
|
||||
@@ -48,7 +48,7 @@ env_logger = "0.7"
|
||||
glsl-to-spirv = "0.1"
|
||||
log = "0.4"
|
||||
png = "0.15"
|
||||
winit = "=0.20.0-alpha6"
|
||||
winit = "0.20"
|
||||
rand = "0.7.2"
|
||||
zerocopy = "0.2"
|
||||
futures = "0.3"
|
||||
|
||||
@@ -63,17 +63,16 @@ pub fn run<E: Example>(title: &str) {
|
||||
log::info!("Initializing the window...");
|
||||
|
||||
#[cfg(not(feature = "gl"))]
|
||||
let (window, hidpi_factor, size, surface) = {
|
||||
let (window, size, surface) = {
|
||||
let window = winit::window::Window::new(&event_loop).unwrap();
|
||||
window.set_title(title);
|
||||
let hidpi_factor = window.hidpi_factor();
|
||||
let size = window.inner_size().to_physical(hidpi_factor);
|
||||
let size = window.inner_size();
|
||||
let surface = wgpu::Surface::create(&window);
|
||||
(window, hidpi_factor, size, surface)
|
||||
(window, size, surface)
|
||||
};
|
||||
|
||||
#[cfg(feature = "gl")]
|
||||
let (window, instance, hidpi_factor, size, surface) = {
|
||||
let (window, instance, size, surface) = {
|
||||
let wb = winit::WindowBuilder::new();
|
||||
let cb = wgpu::glutin::ContextBuilder::new().with_vsync(true);
|
||||
let context = cb.build_windowed(wb, &event_loop).unwrap();
|
||||
@@ -91,7 +90,7 @@ pub fn run<E: Example>(title: &str) {
|
||||
let instance = wgpu::Instance::new(context);
|
||||
let surface = instance.get_surface();
|
||||
|
||||
(window, instance, hidpi_factor, size, surface)
|
||||
(window, instance, size, surface)
|
||||
};
|
||||
|
||||
let adapter = wgpu::Adapter::request(
|
||||
@@ -112,8 +111,8 @@ pub fn run<E: Example>(title: &str) {
|
||||
let mut sc_desc = wgpu::SwapChainDescriptor {
|
||||
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
|
||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||
width: size.width.round() as u32,
|
||||
height: size.height.round() as u32,
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
present_mode: wgpu::PresentMode::Vsync,
|
||||
};
|
||||
let mut swap_chain = device.create_swap_chain(&surface, &sc_desc);
|
||||
@@ -137,10 +136,9 @@ pub fn run<E: Example>(title: &str) {
|
||||
event: WindowEvent::Resized(size),
|
||||
..
|
||||
} => {
|
||||
let physical = size.to_physical(hidpi_factor);
|
||||
log::info!("Resizing to {:?}", physical);
|
||||
sc_desc.width = physical.width.round() as u32;
|
||||
sc_desc.height = physical.height.round() as u32;
|
||||
log::info!("Resizing to {:?}", size);
|
||||
sc_desc.width = size.width;
|
||||
sc_desc.height = size.height;
|
||||
swap_chain = device.create_swap_chain(&surface, &sc_desc);
|
||||
let command_buf = example.resize(&sc_desc, &device);
|
||||
if let Some(command_buf) = command_buf {
|
||||
|
||||
@@ -10,8 +10,7 @@ fn main() {
|
||||
#[cfg(not(feature = "gl"))]
|
||||
let (window, size, surface) = {
|
||||
let window = winit::window::Window::new(&event_loop).unwrap();
|
||||
let size = window.inner_size().to_physical(window.hidpi_factor());
|
||||
|
||||
let size = window.inner_size();
|
||||
let surface = wgpu::Surface::create(&window);
|
||||
(window, size, surface)
|
||||
};
|
||||
@@ -104,8 +103,8 @@ fn main() {
|
||||
let mut sc_desc = wgpu::SwapChainDescriptor {
|
||||
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
|
||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||
width: size.width.round() as u32,
|
||||
height: size.height.round() as u32,
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
present_mode: wgpu::PresentMode::Vsync,
|
||||
};
|
||||
|
||||
@@ -116,9 +115,8 @@ fn main() {
|
||||
match event {
|
||||
event::Event::MainEventsCleared => window.request_redraw(),
|
||||
event::Event::WindowEvent { event: event::WindowEvent::Resized(size), .. } => {
|
||||
let physical = size.to_physical(window.hidpi_factor());
|
||||
sc_desc.width = physical.width.round() as u32;
|
||||
sc_desc.height = physical.height.round() as u32;
|
||||
sc_desc.width = size.width;
|
||||
sc_desc.height = size.height;
|
||||
swap_chain = device.create_swap_chain(&surface, &sc_desc);
|
||||
}
|
||||
event::Event::RedrawRequested(_) => {
|
||||
|
||||
Reference in New Issue
Block a user