From c3fdf122bd874bd0aedf90eff0d57cc440fc6421 Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Thu, 13 Jun 2019 00:38:21 +0200 Subject: Split code into graphics and logic loop --- webhogg/wasm/src/context/graphics.rs | 11 +++++++++++ webhogg/wasm/src/context/logic.rs | 11 +++++++++++ webhogg/wasm/src/context/mod.rs | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 webhogg/wasm/src/context/graphics.rs create mode 100644 webhogg/wasm/src/context/logic.rs create mode 100644 webhogg/wasm/src/context/mod.rs (limited to 'webhogg/wasm/src/context') diff --git a/webhogg/wasm/src/context/graphics.rs b/webhogg/wasm/src/context/graphics.rs new file mode 100644 index 0000000..57955d0 --- /dev/null +++ b/webhogg/wasm/src/context/graphics.rs @@ -0,0 +1,11 @@ +use crate::error::WasmError; + +pub struct GraphicsContext { +} + +impl GraphicsContext { + pub fn from_canvas() -> Result { + Ok(Self { + }) + } +} diff --git a/webhogg/wasm/src/context/logic.rs b/webhogg/wasm/src/context/logic.rs new file mode 100644 index 0000000..71dfea4 --- /dev/null +++ b/webhogg/wasm/src/context/logic.rs @@ -0,0 +1,11 @@ +use crate::error::WasmError; + +pub struct LogicContext { +} + +impl LogicContext { + pub fn new() -> Result { + Ok(Self { + }) + } +} diff --git a/webhogg/wasm/src/context/mod.rs b/webhogg/wasm/src/context/mod.rs new file mode 100644 index 0000000..3e8261b --- /dev/null +++ b/webhogg/wasm/src/context/mod.rs @@ -0,0 +1,24 @@ +pub mod graphics; +pub mod logic; + +use graphics::GraphicsContext; +use logic::LogicContext; + +static mut GTX: Option = None; +static mut LTX: Option = None; + +pub fn get_graphics() -> &'static mut GraphicsContext { + unsafe { GTX.as_mut().unwrap() } +} + +pub fn get_logic() -> &'static mut LogicContext { + unsafe { LTX.as_mut().unwrap() } +} + +pub fn set_graphics(gtx: GraphicsContext) { + unsafe { GTX = Some(gtx) } +} + +pub fn set_logic(ltx: LogicContext) { + unsafe { LTX = Some(ltx) } +} -- cgit v1.3.1