Allow describe example to run on the web

This commit is contained in:
Joshua Groves
2020-04-12 14:42:07 -02:30
committed by Josh Groves
parent 8ee80efe59
commit 95c69a192c

View File

@@ -1,11 +1,4 @@
/// This example shows how to describe the adapter in use.
#[cfg(not(target_arch = "wasm32"))]
fn main() {
env_logger::init();
futures::executor::block_on(run());
}
#[cfg(not(target_arch = "wasm32"))]
async fn run() {
let adapter = wgpu::Adapter::request(
&wgpu::RequestAdapterOptions {
@@ -17,5 +10,25 @@ async fn run() {
.await
.unwrap();
#[cfg(not(target_arch = "wasm32"))]
println!("{:?}", adapter.get_info())
}
fn main() {
#[cfg(not(target_arch = "wasm32"))]
{
env_logger::init();
futures::executor::block_on(run());
}
#[cfg(target_arch = "wasm32")]
{
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
wasm_bindgen_futures::spawn_local(run());
}
}
#[cfg(target_arch = "wasm32")]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
pub fn wasm_main() {
main();
}