Skip to content

Commit

Permalink
Make video mode initialization more intuitive, fixes #12022
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Nov 9, 2017
1 parent e4effb4 commit d09160a
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 77 deletions.
4 changes: 1 addition & 3 deletions core/os/os.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*************************************************************************/
/************************************************************************* /
/* os.h */
/*************************************************************************/
/* This file is part of: */
Expand Down Expand Up @@ -109,8 +109,6 @@ class OS {
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;

Expand Down
53 changes: 24 additions & 29 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ".";
Expand Down Expand Up @@ -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 (!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 (use_custom_res) {

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);
Expand Down
6 changes: 0 additions & 6 deletions platform/android/os_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions platform/android/os_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ class OS_Android : public OS_Unix {
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;

Expand Down
4 changes: 0 additions & 4 deletions platform/haiku/os_haiku.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion platform/haiku/os_haiku.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class OS_Haiku : 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();
Expand Down
5 changes: 0 additions & 5 deletions platform/javascript/os_javascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions platform/javascript/os_javascript.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ class OS_JavaScript : public OS_Unix {
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;

Expand Down
1 change: 0 additions & 1 deletion platform/osx/os_osx.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class OS_OSX : 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_logger();
virtual void initialize_core();
Expand Down
4 changes: 0 additions & 4 deletions platform/server/os_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
1 change: 0 additions & 1 deletion platform/server/os_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions platform/uwp/os_uwp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions platform/uwp/os_uwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ class OSUWP : public OS {
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;

Expand Down
5 changes: 0 additions & 5 deletions platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions platform/windows/os_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ class OS_Windows : public OS {
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;

Expand Down
4 changes: 0 additions & 4 deletions platform/x11/os_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 0 additions & 1 deletion platform/x11/os_x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

2 comments on commit d09160a

@bruvzg
Copy link
Member

@bruvzg bruvzg commented on d09160a Nov 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS and iOS get_default_video_mode implementations are'n removed and cause out-of-line definition build errors

OS::VideoMode OS_OSX::get_default_video_mode() const {
OS::VideoMode OSIPhone::get_default_video_mode() const {
virtual VideoMode get_default_video_mode() const;

@akien-mga
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bruvzg, should now be fixed with ed57f0a.

Please sign in to comment.