summaryrefslogtreecommitdiff
path: root/src/win.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/win.rs')
-rw-r--r--src/win.rs33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/win.rs b/src/win.rs
index c4dfc89..3f64892 100644
--- a/src/win.rs
+++ b/src/win.rs
@@ -985,8 +985,22 @@ impl Drop for Framebuffer {
}
}
+pub struct WindowProperties {
+ shown: bool,
+ resizable: bool,
+}
+
+impl Default for WindowProperties {
+ fn default() -> Self {
+ Self {
+ shown: true,
+ resizable: true,
+ }
+ }
+}
+
impl Window {
- pub fn new(title: &str, width: i32, height: i32, shown: bool) -> Result<Self, String> {
+ pub fn new(title: &str, width: i32, height: i32, properties: &WindowProperties) -> Result<Self, String> {
{
static WINDOW_CREATED: Mutex<bool> = Mutex::new(false);
let guard = WINDOW_CREATED.lock();
@@ -1009,9 +1023,12 @@ impl Window {
sdl::gl_set_context_version(3, 0);
}
let mut flags = sdl::SDL_WINDOW_OPENGL;
- if !shown {
+ if !properties.shown {
flags |= sdl::SDL_WINDOW_HIDDEN;
}
+ if properties.resizable {
+ flags |= sdl::SDL_WINDOW_RESIZABLE;
+ }
let sdlwin = unsafe { sdl::create_window(title, width, height, flags) }?;
let ctx = unsafe { sdl::gl_create_context(sdlwin) }?;
gl::load_with(|name| unsafe { sdl::gl_get_proc_address(name) });
@@ -1048,6 +1065,18 @@ impl Window {
sdl::gl_set_swap_interval(vsync.into());
}
}
+
+ pub fn set_fullscreen(&mut self, fullscreen: bool) {
+ unsafe {
+ // i dont care if going fullscreen fails
+ let _ = sdl::set_window_fullscreen(self.sdlwin,
+ if fullscreen {
+ sdl::SDL_WINDOW_FULLSCREEN_DESKTOP
+ } else {
+ 0
+ });
+ }
+ }
pub fn show(&mut self) {
unsafe { sdl::show_window(self.sdlwin) };