Compare commits

...

2 Commits

Author SHA1 Message Date
Benjamin Hansen 202012b76d switch to `Backends::PRIMARY` 1 month ago
Benjamin Hansen 3e618336bd not crashing 1 month ago

@ -13,7 +13,7 @@ pub fn run() {
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init_with_level(log::Level::Warn).expect("Couldn't initialize logger");
console_log::init_with_level(log::Level::Debug).expect("Couldn't initialize logger");
} else {
env_logger::init();
}
@ -27,7 +27,7 @@ pub fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()
@ -43,6 +43,9 @@ pub fn run() {
event_loop
.run(move |event, control_flow| match event {
Event::Resumed => {
log::debug!("Resumed");
}
Event::WindowEvent {
ref event,
window_id,

@ -28,7 +28,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -85,7 +85,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
view_formats: vec![],
};
surface.configure(&device, &config);
let clear_color = wgpu::Color::BLACK;

@ -29,7 +29,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -83,7 +83,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
view_formats: vec![],
};
surface.configure(&device, &config);
Self {
surface,
@ -161,7 +160,7 @@ pub async fn run() {
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init_with_level(log::Level::Warn).expect("Couldn't initialize logger");
console_log::init_with_level(log::Level::Info).expect("Couldn't initialize logger");
} else {
env_logger::init();
}
@ -175,7 +174,6 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
//window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
use winit::platform::web::WindowExtWebSys;
web_sys::window()
@ -187,6 +185,8 @@ pub async fn run() {
Some(())
})
.expect("Couldn't append canvas to document body.");
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
}
// State::new uses async code, so we're going to wait for it to finish
@ -213,6 +213,7 @@ pub async fn run() {
..
} => control_flow.exit(),
WindowEvent::Resized(physical_size) => {
log::info!("physical_size: {physical_size:?}");
state.resize(*physical_size);
}
WindowEvent::RedrawRequested => {

@ -26,7 +26,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -79,7 +79,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Shader"),

@ -28,7 +28,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -81,7 +81,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Shader"),
@ -233,7 +232,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -89,7 +89,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -146,7 +146,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Shader"),

@ -85,7 +85,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -142,7 +142,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Shader"),
@ -311,7 +310,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -91,7 +91,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -147,7 +147,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {

@ -91,7 +91,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -143,7 +143,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let diffuse_bytes = include_bytes!("happy-tree.png");
let diffuse_texture =
@ -357,7 +356,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -241,7 +241,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -293,7 +293,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let diffuse_bytes = include_bytes!("happy-tree.png");
let diffuse_texture =

@ -241,7 +241,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -293,7 +293,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let diffuse_bytes = include_bytes!("happy-tree.png");
let diffuse_texture =
@ -566,7 +565,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -295,7 +295,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -347,7 +347,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let diffuse_bytes = include_bytes!("happy-tree.png");
let diffuse_texture =

@ -302,7 +302,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -354,7 +354,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let diffuse_bytes = include_bytes!("happy-tree.png");
let diffuse_texture =
@ -664,7 +663,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -494,7 +494,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -546,7 +546,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let diffuse_bytes = include_bytes!("happy-tree.png");
let diffuse_texture =

@ -312,7 +312,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -364,7 +364,6 @@ impl<'a> State<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let diffuse_bytes = include_bytes!("happy-tree.png");
let diffuse_texture =
@ -691,7 +690,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -252,7 +252,10 @@ impl<'a> State<'a> {
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
log::warn!("WGPU setup");
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
#[cfg(not(target_arch="wasm32"))]
backends: wgpu::Backends::PRIMARY,
#[cfg(target_arch="wasm32")]
backends: wgpu::Backends::GL,
..Default::default()
});
@ -308,7 +311,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -588,7 +590,7 @@ pub async fn run() {
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init_with_level(log::Level::Warn).expect("Could't initialize logger");
console_log::init_with_level(log::Level::Info).expect("Could't initialize logger");
} else {
env_logger::init();
}
@ -606,7 +608,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -122,7 +122,6 @@ where
camera_bind_group: &'b wgpu::BindGroup,
) {
for mesh in &model.meshes {
log::warn!("materials: {}", model.materials.len());
let material = &model.materials[mesh.material];
self.draw_mesh_instanced(mesh, material, instances.clone(), camera_bind_group);
}

@ -144,6 +144,7 @@ pub async fn load_model(
usage: wgpu::BufferUsages::INDEX,
});
log::info!("{}", m.name);
model::Mesh {
name: file_name.to_string(),
vertex_buffer,

@ -16,8 +16,8 @@ impl Texture {
label: &str,
) -> Self {
let size = wgpu::Extent3d {
width: config.width,
height: config.height,
width: config.width.max(1),
height: config.height.max(1),
depth_or_array_layers: 1,
};
let desc = wgpu::TextureDescriptor {

@ -347,7 +347,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -400,7 +400,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -743,7 +742,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -347,7 +347,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -400,7 +400,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -794,7 +793,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -227,7 +227,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -280,7 +280,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -697,7 +696,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -250,7 +250,7 @@ impl<'a> State<'a> {
#[cfg(target_arch = "wasm32")]
backends: wgpu::Backends::BROWSER_WEBGPU,
#[cfg(not(target_arch = "wasm32"))]
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -299,7 +299,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -827,7 +826,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -228,7 +228,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -281,7 +281,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -747,7 +746,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -166,7 +166,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -219,7 +219,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {

@ -36,7 +36,7 @@ impl<'a> Display<'a> {
pub async fn new(window: &'a Window) -> Result<Display<'a>, Error> {
let size = window.inner_size();
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
let surface = instance.create_surface(window).unwrap();
@ -85,7 +85,6 @@ impl<'a> Display<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
Ok(Self {
surface,

@ -232,7 +232,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -285,7 +285,6 @@ impl<'a> State<'a> {
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -743,7 +742,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -41,7 +41,7 @@ impl<'a> Render<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -87,7 +87,6 @@ impl<'a> Render<'a> {
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
bind_group_layouts: &[],

@ -226,7 +226,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// BackendBit::PRIMARY => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -279,7 +279,6 @@ impl<'a> State<'a> {
view_formats: vec![],
};
surface.configure(&device, &config);
let texture_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@ -704,7 +703,7 @@ pub async fn run() {
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -181,7 +181,7 @@ Next, after we create our event loop and window, we need to add a canvas to the
// Winit prevents sizing with CSS, so we have to set
// the size manually when on web.
use winit::dpi::PhysicalSize;
window.request_inner_size(PhysicalSize::new(450, 400)).unwrap();
let _ = window.request_inner_size(PhysicalSize::new(450, 400));
use winit::platform::web::WindowExtWebSys;
web_sys::window()

@ -61,7 +61,7 @@ impl<'a> State<'a> {
// The instance is a handle to our GPU
// Backends::all => Vulkan + Metal + DX12 + Browser WebGPU
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
@ -175,7 +175,6 @@ The `limits` field describes the limit of certain types of resources that we can
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
```
Here we are defining a config for our surface. This will define how the surface creates its underlying `SurfaceTexture`s. We will talk about `SurfaceTexture` when we get to the `render` function. For now, let's talk about the config's fields.

Loading…
Cancel
Save