Updated the init_window function to use SDL_WINDOW_FULLSCREEN

instead of SDL_WINDOW_FULLSCREEN_DESKTOP
This commit is contained in:
abdelrahman committed 2022-12-21 22:24:47 +00:00
1 parent 5aa475c577
commit e1806bafc2
1 file changed
+17 -14
+17 -14
View File
@@ -1,4 +1,5 @@
#include "Window.h"
#include "GameEngine.h"
#include "Renderer.h"
#include "SDL_platform.h"
#include "SDL_video.h"
@@ -28,6 +29,10 @@ bool init_window(Window *wnd, const char *title, WindowSize size,
Uint32 window_flags = SDL_WINDOW_ALLOW_HIGHDPI;
// Temporary variable to store the user defined size when running the game
// in full screen so it can be used to calculate the drawing area
WindowSize user_defined_size = {0, 0};
if (strcmp(current_platform, "Android") == 0 ||
strcmp(current_platform, "iOS") == 0) {
// Mobile platforms should always be full screen
@@ -57,7 +62,15 @@ bool init_window(Window *wnd, const char *title, WindowSize size,
size.height = max_int(mode.w, mode.h);
}
} else if (full_screen) {
window_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
window_flags |= SDL_WINDOW_FULLSCREEN;
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode);
user_defined_size = size;
size.width = mode.w;
size.height = mode.h;
}
wnd->SDL_base_window =
@@ -95,8 +108,10 @@ bool init_window(Window *wnd, const char *title, WindowSize size,
// Fit the window into the screen when running in full screen mode on
// a non-mobile platform. Mobile platforms will be handled differently
// f32 window_size_ratio =
// (f32)wnd->defined_size.width / (f32)wnd->defined_size.height;
f32 window_size_ratio =
(f32)wnd->defined_size.width / (f32)wnd->defined_size.height;
(f32)user_defined_size.width / (f32)user_defined_size.height;
// Fit the drawing area size to the smallest dimension of the screen and
// make sure the drawing area is centered
@@ -111,18 +126,6 @@ bool init_window(Window *wnd, const char *title, WindowSize size,
wnd->drawing_area.y =
0.0f + ((wnd->real_size.height - wnd->drawing_area.height) / 2.0f);
}
// Update the defined size, because in full screen mode, it would be equal
// to the screen dimensions
SDL_DisplayMode mode;
if (SDL_GetWindowDisplayMode(wnd->SDL_base_window, &mode) != 0) {
destroy_window(wnd);
return false;
}
wnd->defined_size.width = mode.w;
wnd->defined_size.height = mode.h;
} else if (strcmp(current_platform, "Android") == 0 ||
strcmp(current_platform, "iOS") == 0) {
// Get the correct real_size and drawing_area when running on a mobile