mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Combine wasm_main/main and add console_log
This commit is contained in:
committed by
Josh Groves
parent
349f992a7a
commit
f0ab842d6e
@@ -114,19 +114,16 @@ async fn run() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
|
||||
pub fn wasm_main() {
|
||||
console_log::init().expect("could not initialize log");
|
||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
wasm_bindgen_futures::spawn_local(run());
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn main() {}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
futures::executor::block_on(run());
|
||||
#[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));
|
||||
console_log::init().expect("could not initialize logger");
|
||||
wasm_bindgen_futures::spawn_local(run());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,7 @@ fn main() {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
console_log::init().expect("could not initialize logger");
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -159,6 +159,7 @@ pub fn run<E: Example>(title: &str) {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
console_log::init().expect("could not initialize logger");
|
||||
use winit::platform::web::WindowExtWebSys;
|
||||
// On wasm, append the canvas to the document body
|
||||
web_sys::window()
|
||||
|
||||
@@ -124,21 +124,18 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
|
||||
pub fn wasm_main() {
|
||||
console_log::init().expect("could not initialize log");
|
||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
wasm_bindgen_futures::spawn_local(run());
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn main() {}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
futures::executor::block_on(run());
|
||||
#[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));
|
||||
console_log::init().expect("could not initialize logger");
|
||||
wasm_bindgen_futures::spawn_local(run());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -137,12 +137,6 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
|
||||
pub fn wasm_main() {
|
||||
main();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let event_loop = EventLoop::new();
|
||||
let window = winit::window::Window::new(&event_loop).unwrap();
|
||||
@@ -154,6 +148,7 @@ fn main() {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
console_log::init().expect("could not initialize logger");
|
||||
use winit::platform::web::WindowExtWebSys;
|
||||
// On wasm, append the canvas to the document body
|
||||
web_sys::window()
|
||||
|
||||
@@ -268,12 +268,6 @@ impl framework::Example for Example {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
|
||||
pub fn wasm_main() {
|
||||
main();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
framework::run::<Example>("msaa-line");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user