Make video mode initialization more intuitive, fixes #12022

This commit is contained in:
Juan Linietsky 2017-11-09 13:01:29 -03:00
parent e4effb4d53
commit d09160a8b6
17 changed files with 24 additions and 76 deletions

View File

@ -1,4 +1,4 @@
/*************************************************************************/ /************************************************************************* /
/* os.h */ /* os.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
@ -109,8 +109,6 @@ protected:
virtual int get_video_driver_count() const = 0; virtual int get_video_driver_count() const = 0;
virtual const char *get_video_driver_name(int p_driver) 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 int get_audio_driver_count() const = 0;
virtual const char *get_audio_driver_name(int p_driver) const = 0; virtual const char *get_audio_driver_name(int p_driver) const = 0;

View File

@ -321,8 +321,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
I = args.front(); I = args.front();
video_mode = OS::get_singleton()->get_default_video_mode();
String video_driver = ""; String video_driver = "";
String audio_driver = ""; String audio_driver = "";
String game_path = "."; 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 //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))); // 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")) if (use_custom_res) {
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 (!force_res && use_custom_res && globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) { if (!force_res) {
int tw = globals->get("display/window/size/test_width"); video_mode.width = GLOBAL_DEF("display/window/size/width", 1024);
int th = globals->get("display/window/size/test_height"); video_mode.height = GLOBAL_DEF("display/window/size/height", 600);
if (tw > 0 && th > 0) {
video_mode.width = tw; if (globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) {
video_mode.height = th; 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); if (!force_lowdpi) {
GLOBAL_DEF("display/window/size/height", video_mode.height); OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false);
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); use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", true);
GLOBAL_DEF("display/window/size/borderless", video_mode.borderless_window);
use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", use_vsync);
GLOBAL_DEF("display/window/size/test_width", 0); GLOBAL_DEF("display/window/size/test_width", 0);
GLOBAL_DEF("display/window/size/test_height", 0); GLOBAL_DEF("display/window/size/test_height", 0);
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2); GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2);

View File

@ -65,12 +65,6 @@ const char *OS_Android::get_video_driver_name(int p_driver) const {
return "GLES2"; return "GLES2";
} }
OS::VideoMode OS_Android::get_default_video_mode() const {
return OS::VideoMode();
}
int OS_Android::get_audio_driver_count() const { int OS_Android::get_audio_driver_count() const {
return 1; return 1;

View File

@ -141,8 +141,6 @@ public:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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 int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const; virtual const char *get_audio_driver_name(int p_driver) const;

View File

@ -79,10 +79,6 @@ const char *OS_Haiku::get_video_driver_name(int p_driver) const {
return "GLES2"; 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) { void OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
main_loop = NULL; main_loop = NULL;
current_video_mode = p_desired; current_video_mode = p_desired;

View File

@ -65,7 +65,6 @@ private:
protected: protected:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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 initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
virtual void finalize(); virtual void finalize();

View File

@ -64,11 +64,6 @@ const char *OS_JavaScript::get_video_driver_name(int p_driver) const {
return "GLES3"; return "GLES3";
} }
OS::VideoMode OS_JavaScript::get_default_video_mode() const {
return OS::VideoMode();
}
int OS_JavaScript::get_audio_driver_count() const { int OS_JavaScript::get_audio_driver_count() const {
return 1; return 1;

View File

@ -83,8 +83,6 @@ public:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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 int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const; virtual const char *get_audio_driver_name(int p_driver) const;

View File

@ -120,7 +120,6 @@ public:
protected: protected:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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_logger();
virtual void initialize_core(); virtual void initialize_core();

View File

@ -46,10 +46,6 @@ const char *OS_Server::get_video_driver_name(int p_driver) const {
return "Dummy"; 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) { void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {

View File

@ -66,7 +66,6 @@ class OS_Server : public OS_Unix {
protected: protected:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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 initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
virtual void finalize(); virtual void finalize();

View File

@ -72,11 +72,6 @@ const char *OSUWP::get_video_driver_name(int p_driver) const {
return "GLES2"; return "GLES2";
} }
OS::VideoMode OSUWP::get_default_video_mode() const {
return video_mode;
}
Size2 OSUWP::get_window_size() const { Size2 OSUWP::get_window_size() const {
Size2 size; Size2 size;
size.width = video_mode.width; size.width = video_mode.width;

View File

@ -154,8 +154,6 @@ protected:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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 int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const; virtual const char *get_audio_driver_name(int p_driver) const;

View File

@ -146,11 +146,6 @@ const char *OS_Windows::get_video_driver_name(int p_driver) const {
return "GLES2"; return "GLES2";
} }
OS::VideoMode OS_Windows::get_default_video_mode() const {
return VideoMode(1024, 600, false);
}
int OS_Windows::get_audio_driver_count() const { int OS_Windows::get_audio_driver_count() const {
return AudioDriverManager::get_driver_count(); return AudioDriverManager::get_driver_count();

View File

@ -142,8 +142,6 @@ protected:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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 int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const; virtual const char *get_audio_driver_name(int p_driver) const;

View File

@ -82,10 +82,6 @@ const char *OS_X11::get_video_driver_name(int p_driver) const {
return "GLES3"; 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 { int OS_X11::get_audio_driver_count() const {
return AudioDriverManager::get_driver_count(); return AudioDriverManager::get_driver_count();
} }

View File

@ -177,7 +177,6 @@ class OS_X11 : public OS_Unix {
protected: protected:
virtual int get_video_driver_count() const; virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) 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 int get_audio_driver_count() const;
virtual const char *get_audio_driver_name(int p_driver) const; virtual const char *get_audio_driver_name(int p_driver) const;