diff options
Diffstat (limited to 'webhogg/wasm/src/graphics.rs')
-rw-r--r-- | webhogg/wasm/src/graphics.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/webhogg/wasm/src/graphics.rs b/webhogg/wasm/src/graphics.rs new file mode 100644 index 0000000..219c652 --- /dev/null +++ b/webhogg/wasm/src/graphics.rs @@ -0,0 +1,25 @@ +use wasm_bindgen::prelude::*; +use log::*; +use crate::*; + +#[wasm_bindgen] +pub fn start_graphics(canvas: web_sys::OffscreenCanvas) { + logger::init_logger(); + info!("graphics: wasm entry-point reached"); + //debug!("js value is?: undefined: {}", canvas.is_undefined()); + + match context::graphics::GraphicsContext::from_canvas(canvas) { + Ok(ctx) => context::set_graphics(ctx), + Err(e) => { + error!("graphics {}", e); + panic!() + } + } +} + +#[wasm_bindgen] +pub fn loop_graphics() { + context::get_graphics().update() + .map_err(|e| error!("gaphics loop {}", e)) + .unwrap(); +} |