diff options
author | Matthew Michelotti <michelotti.matthew@gmail.com> | 2018-08-02 20:01:00 -0500 |
---|---|---|
committer | Matthew Michelotti <michelotti.matthew@gmail.com> | 2018-08-02 20:01:00 -0500 |
commit | 23ac1942dde9327f91e9d937258998b04cd4247d (patch) | |
tree | 227a8bd6b15e3cd587f94485145089ac48d54a1a | |
parent | ed76abcec6b4ec5444f893425e9a8a4c0509546b (diff) |
adding fullscreen functionality for SDL2 build
-rw-r--r-- | gate/src/core/sdl/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gate/src/core/sdl/mod.rs b/gate/src/core/sdl/mod.rs index 60831c9..b808c3a 100644 --- a/gate/src/core/sdl/mod.rs +++ b/gate/src/core/sdl/mod.rs @@ -24,7 +24,7 @@ use std::fs::File; use std::io::BufReader; use sdl2::{self, VideoSubsystem}; -use sdl2::video::GLProfile; +use sdl2::video::{FullscreenType, GLProfile}; use sdl2::video::gl_attr::GLAttr; use sdl2::image::LoadTexture; use sdl2::mixer::{Sdl2MixerContext, INIT_OGG, DEFAULT_CHANNELS, AUDIO_S16LSB}; @@ -107,6 +107,18 @@ pub fn run<AS: AppAssetId, AP: App<AS>>(info: AppInfo, mut app: AP) { let elapsed = clock.step(); + match (ctx.is_fullscreen(), ctx.desires_fullscreen()) { + (false, true) => { + let success = sdl_renderer.window_mut().unwrap().set_fullscreen(FullscreenType::True).is_ok(); + ctx.set_is_fullscreen(success); + }, + (true, false) => { + let success = sdl_renderer.window_mut().unwrap().set_fullscreen(FullscreenType::Off).is_ok(); + ctx.set_is_fullscreen(!success); + }, + (false, false) | (true, true) => {}, + } + let continuing = event_handler.process_events(&mut app, &mut ctx, &renderer); if !continuing { break; } app.advance(elapsed.min(::MAX_TIMESTEP), &mut ctx); |