summaryrefslogtreecommitdiff
path: root/src/video/sdl2_v.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-01-14 21:53:06 +0100
committerGitHub <noreply@github.com>2021-01-14 21:53:06 +0100
commitfa60c1f8b94dd5584a5d5331de277ca23a203422 (patch)
tree7849166d1c2ee40f4d48f4fc4442af1ee24b3b2f /src/video/sdl2_v.cpp
parent711723d7387df67b1abe98ca9ed4d7f2bd7de57d (diff)
downloadopenttd-fa60c1f8b94dd5584a5d5331de277ca23a203422.tar.xz
Feature: Choose a sensible window size on a fresh OTTD config file. (#8536)
Diffstat (limited to 'src/video/sdl2_v.cpp')
-rw-r--r--src/video/sdl2_v.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp
index dee0ff93d..f2fbd6d5a 100644
--- a/src/video/sdl2_v.cpp
+++ b/src/video/sdl2_v.cpp
@@ -674,6 +674,8 @@ const char *VideoDriver_SDL::Start(const StringList &parm)
}
if (ret_code < 0) return SDL_GetError();
+ this->UpdateAutoResolution();
+
GetVideoModes();
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height, false)) {
return SDL_GetError();
@@ -930,4 +932,12 @@ void VideoDriver_SDL::ReleaseBlitterLock()
if (_draw_mutex != nullptr) _draw_mutex->unlock();
}
+Dimension VideoDriver_SDL::GetScreenSize() const
+{
+ SDL_DisplayMode mode;
+ if (SDL_GetCurrentDisplayMode(0, &mode) != 0) return VideoDriver::GetScreenSize();
+
+ return { static_cast<uint>(mode.w), static_cast<uint>(mode.h) };
+}
+
#endif /* WITH_SDL2 */