why did they do it like that

This commit is contained in:
Quaternions 2023-10-19 20:02:40 -07:00
parent eb376c1e68
commit f8320c9df5

View File

@ -138,26 +138,23 @@ async fn setup<E: Example>(title: &str) -> Setup {
backends, backends,
dx12_shader_compiler, dx12_shader_compiler,
}); });
let (size, surface) = unsafe {
let size = window.inner_size();
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] let size = window.inner_size();
let surface = instance.create_surface(&window).unwrap();
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
let surface = { let surface=unsafe{instance.create_surface(&window)}.unwrap();
if let Some(offscreen_canvas_setup) = &offscreen_canvas_setup { #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
log::info!("Creating surface from OffscreenCanvas"); let surface={
instance.create_surface_from_offscreen_canvas( if let Some(offscreen_canvas_setup) = &offscreen_canvas_setup {
offscreen_canvas_setup.offscreen_canvas.clone(), log::info!("Creating surface from OffscreenCanvas");
) instance.create_surface_from_offscreen_canvas(
} else { offscreen_canvas_setup.offscreen_canvas.clone(),
instance.create_surface(&window) )
} } else {
instance.create_surface(&window)
} }
.unwrap(); }
.unwrap();
(size, surface)
};
let adapter; let adapter;