From d09160a8b67fdc60e8108962c4e9bd4c0bc7f13e Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 9 Nov 2017 13:01:29 -0300 Subject: [PATCH] Make video mode initialization more intuitive, fixes #12022 --- core/os/os.h | 4 +-- main/main.cpp | 51 ++++++++++++--------------- platform/android/os_android.cpp | 6 ---- platform/android/os_android.h | 2 -- platform/haiku/os_haiku.cpp | 4 --- platform/haiku/os_haiku.h | 1 - platform/javascript/os_javascript.cpp | 5 --- platform/javascript/os_javascript.h | 2 -- platform/osx/os_osx.h | 1 - platform/server/os_server.cpp | 4 --- platform/server/os_server.h | 1 - platform/uwp/os_uwp.cpp | 5 --- platform/uwp/os_uwp.h | 2 -- platform/windows/os_windows.cpp | 5 --- platform/windows/os_windows.h | 2 -- platform/x11/os_x11.cpp | 4 --- platform/x11/os_x11.h | 1 - 17 files changed, 24 insertions(+), 76 deletions(-) diff --git a/core/os/os.h b/core/os/os.h index f5e479ac0b2..4ac6e81b154 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -1,4 +1,4 @@ -/*************************************************************************/ +/************************************************************************* / /* os.h */ /*************************************************************************/ /* This file is part of: */ @@ -109,8 +109,6 @@ protected: virtual int get_video_driver_count() const = 0; virtual const char *get_video_driver_name(int p_driver) const = 0; - virtual VideoMode get_default_video_mode() const = 0; - virtual int get_audio_driver_count() const = 0; virtual const char *get_audio_driver_name(int p_driver) const = 0; diff --git a/main/main.cpp b/main/main.cpp index 5e8e52d3e59..37d233dff35 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -321,8 +321,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph I = args.front(); - video_mode = OS::get_singleton()->get_default_video_mode(); - String video_driver = ""; String audio_driver = ""; String game_path = "."; @@ -779,36 +777,33 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph //if (video_driver == "") // useless for now, so removing // video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0))); - if (!force_res && use_custom_res && globals->has_setting("display/window/size/width")) - video_mode.width = globals->get("display/window/size/width"); - if (!force_res && use_custom_res && globals->has_setting("display/window/size/height")) - video_mode.height = globals->get("display/window/size/height"); - if (!editor && ((globals->has_setting("display/window/dpi/allow_hidpi") && !globals->get("display/window/dpi/allow_hidpi")) || force_lowdpi)) { - OS::get_singleton()->_allow_hidpi = false; - } - if (use_custom_res && globals->has_setting("display/window/size/fullscreen")) - video_mode.fullscreen = globals->get("display/window/size/fullscreen"); - if (use_custom_res && globals->has_setting("display/window/size/resizable")) - video_mode.resizable = globals->get("display/window/size/resizable"); - if (use_custom_res && globals->has_setting("display/window/size/borderless")) - video_mode.borderless_window = globals->get("display/window/size/borderless"); + if (use_custom_res) { - if (!force_res && use_custom_res && globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) { - int tw = globals->get("display/window/size/test_width"); - int th = globals->get("display/window/size/test_height"); - if (tw > 0 && th > 0) { - video_mode.width = tw; - video_mode.height = th; + if (!force_res) { + video_mode.width = GLOBAL_DEF("display/window/size/width", 1024); + video_mode.height = GLOBAL_DEF("display/window/size/height", 600); + + if (globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) { + int tw = globals->get("display/window/size/test_width"); + int th = globals->get("display/window/size/test_height"); + if (tw > 0 && th > 0) { + video_mode.width = tw; + video_mode.height = th; + } + } } + + video_mode.resizable = GLOBAL_DEF("display/window/size/resizable", true); + video_mode.borderless_window = GLOBAL_DEF("display/window/size/borderless", false); + video_mode.fullscreen = GLOBAL_DEF("display/window/size/fullscreen", false); } - GLOBAL_DEF("display/window/size/width", video_mode.width); - GLOBAL_DEF("display/window/size/height", video_mode.height); - GLOBAL_DEF("display/window/dpi/allow_hidpi", false); - GLOBAL_DEF("display/window/size/fullscreen", video_mode.fullscreen); - GLOBAL_DEF("display/window/size/resizable", video_mode.resizable); - GLOBAL_DEF("display/window/size/borderless", video_mode.borderless_window); - use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", use_vsync); + if (!force_lowdpi) { + OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false); + } + + use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", true); + GLOBAL_DEF("display/window/size/test_width", 0); GLOBAL_DEF("display/window/size/test_height", 0); GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 9d43adf788c..970e0cdf688 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -65,12 +65,6 @@ const char *OS_Android::get_video_driver_name(int p_driver) const { return "GLES2"; } - -OS::VideoMode OS_Android::get_default_video_mode() const { - - return OS::VideoMode(); -} - int OS_Android::get_audio_driver_count() const { return 1; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index d9a66b4e3a3..fee91b9a557 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -141,8 +141,6 @@ public: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 7a681d46f71..0c34e396554 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -79,10 +79,6 @@ const char *OS_Haiku::get_video_driver_name(int p_driver) const { return "GLES2"; } -OS::VideoMode OS_Haiku::get_default_video_mode() const { - return OS::VideoMode(800, 600, false); -} - void OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { main_loop = NULL; current_video_mode = p_desired; diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 501650c94f2..86148f1fb4b 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -65,7 +65,6 @@ private: protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); virtual void finalize(); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 3a57de26462..e5bdcec30de 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -64,11 +64,6 @@ const char *OS_JavaScript::get_video_driver_name(int p_driver) const { return "GLES3"; } -OS::VideoMode OS_JavaScript::get_default_video_mode() const { - - return OS::VideoMode(); -} - int OS_JavaScript::get_audio_driver_count() const { return 1; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 07720e95ecb..f478f95dd28 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -83,8 +83,6 @@ public: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index fba53f61b6c..53f45511f94 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -120,7 +120,6 @@ public: protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual void initialize_logger(); virtual void initialize_core(); diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 80c04aa5ad3..ca73f610e41 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -46,10 +46,6 @@ const char *OS_Server::get_video_driver_name(int p_driver) const { return "Dummy"; } -OS::VideoMode OS_Server::get_default_video_mode() const { - - return OS::VideoMode(800, 600, false); -} void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { diff --git a/platform/server/os_server.h b/platform/server/os_server.h index 630c82ccdd0..03f7c2a6c87 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -66,7 +66,6 @@ class OS_Server : public OS_Unix { protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); virtual void finalize(); diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 8db2a749df5..acb0ba4bcaa 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -72,11 +72,6 @@ const char *OSUWP::get_video_driver_name(int p_driver) const { return "GLES2"; } -OS::VideoMode OSUWP::get_default_video_mode() const { - - return video_mode; -} - Size2 OSUWP::get_window_size() const { Size2 size; size.width = video_mode.width; diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index e46e4cc0201..2931e9b07dc 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -154,8 +154,6 @@ protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 01201beccb7..0f62dbb9e8c 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -146,11 +146,6 @@ const char *OS_Windows::get_video_driver_name(int p_driver) const { return "GLES2"; } -OS::VideoMode OS_Windows::get_default_video_mode() const { - - return VideoMode(1024, 600, false); -} - int OS_Windows::get_audio_driver_count() const { return AudioDriverManager::get_driver_count(); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index c9c00b5e36d..fbd60e5f0df 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -142,8 +142,6 @@ protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index fbcc22c58e4..f018145d827 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -82,10 +82,6 @@ const char *OS_X11::get_video_driver_name(int p_driver) const { return "GLES3"; } -OS::VideoMode OS_X11::get_default_video_mode() const { - return OS::VideoMode(1024, 600, false); -} - int OS_X11::get_audio_driver_count() const { return AudioDriverManager::get_driver_count(); } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index bfa8b5b375e..0ea5bbfdb64 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -177,7 +177,6 @@ class OS_X11 : public OS_Unix { protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const;