From 985f41f7204cf387eceae815156e9afca76967e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophyl=20Hoguet?= Date: Sun, 20 Mar 2022 22:35:45 +0100 Subject: [PATCH] fullscreen with f11 WIP --- model.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/model.c b/model.c index 7af695c..02eea1a 100644 --- a/model.c +++ b/model.c @@ -423,6 +423,13 @@ void render(SDL_Window* win, SDL_Renderer* ren, Env* env) { /* **************************************************************** */ +void ToggleFullscreen(SDL_Window* Window) { + Uint32 FullscreenFlag = SDL_WINDOW_FULLSCREEN; + bool IsFullscreen = SDL_GetWindowFlags(Window) & FullscreenFlag; + SDL_SetWindowFullscreen(Window, IsFullscreen ? 0 : FullscreenFlag); + SDL_ShowCursor(IsFullscreen); +} + bool process(SDL_Window* win, Env* env, SDL_Event* e) { int w, h; SDL_GetWindowSize(win, &w, &h); @@ -491,6 +498,10 @@ bool process(SDL_Window* win, Env* env, SDL_Event* e) { } } } + } else if (e->type == SDL_KEYDOWN) { + const Uint8* state = SDL_GetKeyboardState(NULL); + if (state[SDL_SCANCODE_F11]) + ToggleFullscreen(win); } #endif return false;