summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-01-31 13:50:31 -0500
committerLLLL Colonq <llll@colonq>2025-01-31 13:50:31 -0500
commit94fa96fe2091ee9f758b79b4c1a5d2c5ca60d1ac (patch)
treed6b0f4c1ad387b0a5ef16afb6576443a96f97ba2 /src
parentfddfed5b8524a1f7592b0200a8e6546e0aca4390 (diff)
Option flags
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 383a28d..6d6fc9d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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)));