diff options
| author | LLLL Colonq <llll@colonq> | 2025-01-31 13:50:31 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-01-31 13:50:31 -0500 |
| commit | 94fa96fe2091ee9f758b79b4c1a5d2c5ca60d1ac (patch) | |
| tree | d6b0f4c1ad387b0a5ef16afb6576443a96f97ba2 | |
| parent | fddfed5b8524a1f7592b0200a8e6546e0aca4390 (diff) | |
Option flags
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | Cargo.toml | 1 | ||||
| -rw-r--r-- | src/lib.rs | 18 |
3 files changed, 18 insertions, 2 deletions
@@ -2405,6 +2405,7 @@ name = "teleia" version = "0.1.0" dependencies = [ "bimap", + "bitflags 1.3.2", "bytes", "console_error_panic_hook", "console_log", @@ -33,6 +33,7 @@ enum-map = "*" # fast maps with enums as keys bimap = "*" # bijective maps reqwest = "*" # http requests bytes = "*" # bytes for http responses +bitflags = "*" # bitwise flags [target.'cfg(target_arch = "wasm32")'.dependencies] winit = {version = "*", features = ["serde"]} # windowing and events @@ -26,6 +26,9 @@ use wasm_bindgen::JsCast; #[cfg(not(target_arch = "wasm32"))] use glfw::Context; +#[cfg(not(target_arch = "wasm32"))] +use bitflags::bitflags; + static mut CTX: Option<*const context::Context> = None; static mut ST: Option<*mut state::State> = None; static mut G: Option<*mut std::ffi::c_void> = None; @@ -42,8 +45,15 @@ where } } +bitflags! { + pub struct Options: u32 { + const OVERLAY = 0b00000001; + const HIDDEN = 0b00000010; + } +} + #[cfg(not(target_arch = "wasm32"))] -pub async fn run<'a, F, G, Fut>(title: &str, w: u32, h: u32, overlay: bool, gnew: F) +pub async fn run<'a, F, G, Fut>(title: &str, w: u32, h: u32, options: Options, gnew: F) where Fut: std::future::Future<Output = G>, G: state::Game + 'static, @@ -62,7 +72,11 @@ where // gl_attr.set_context_profile(sdl2::video::GLProfile::Core); // gl_attr.set_context_version(3, 0); let (mut window, events) = glfw.with_primary_monitor(|glfw, primary| { - if overlay { + if options.contains(Options::HIDDEN) { + glfw.window_hint(glfw::WindowHint::Visible(false)); + glfw.create_window(w as _, h as _, title, glfw::WindowMode::Windowed) + .expect("failed to create window") + } else if options.contains(Options::OVERLAY) { let mon = primary.expect("failed to get monitor"); let mode = mon.get_video_mode().expect("failed to get video mode"); glfw.window_hint(glfw::WindowHint::RedBits(Some(mode.red_bits))); |
