egui/egui_demo_app/src/lib.rs

22 lines
739 B
Rust
Raw Normal View History

#[cfg(target_arch = "wasm32")]
use eframe::wasm_bindgen::{self, prelude::*};
2020-04-12 10:07:51 +00:00
/// This is the entry-point for all the web-assembly.
2020-11-17 22:24:14 +00:00
/// This is called once from the HTML.
/// It loads the app, installs some callbacks, then returns.
/// You can add more callbacks like this if you want to call in to your code.
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
2020-07-18 22:44:06 +00:00
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
// Make sure panics are logged using `console.error`.
console_error_panic_hook::set_once();
// Redirect tracing to console.log and friends:
tracing_wasm::set_as_global_default();
2022-03-18 13:23:07 +00:00
eframe::start_web(
canvas_id,
Box::new(|cc| Box::new(egui_demo_lib::WrapApp::new(cc))),
)
}