Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit a10c2e3

Browse files
committed
Allow describe example to run on the web
1 parent 0a39ef2 commit a10c2e3

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

examples/describe/main.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
/// This example shows how to describe the adapter in use.
2-
#[cfg(not(target_arch = "wasm32"))]
3-
fn main() {
4-
env_logger::init();
5-
futures::executor::block_on(run());
6-
}
7-
8-
#[cfg(not(target_arch = "wasm32"))]
92
async fn run() {
103
let adapter = wgpu::Adapter::request(
114
&wgpu::RequestAdapterOptions {
@@ -17,5 +10,25 @@ async fn run() {
1710
.await
1811
.unwrap();
1912

13+
#[cfg(not(target_arch = "wasm32"))]
2014
println!("{:?}", adapter.get_info())
2115
}
16+
17+
fn main() {
18+
#[cfg(not(target_arch = "wasm32"))]
19+
{
20+
env_logger::init();
21+
futures::executor::block_on(run());
22+
}
23+
#[cfg(target_arch = "wasm32")]
24+
{
25+
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
26+
wasm_bindgen_futures::spawn_local(run());
27+
}
28+
}
29+
30+
#[cfg(target_arch = "wasm32")]
31+
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
32+
pub fn wasm_main() {
33+
main();
34+
}

0 commit comments

Comments
 (0)