From f0d24de960d7617ebcbd8bd6f708d7bbd842152a Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 1 Mar 2018 23:17:34 +0200 Subject: [PATCH] Fix `--help` output, allow renderer override from command line (`--video-driver`). --- main/main.cpp | 7 +++++-- platform/osx/os_osx.mm | 2 -- platform/x11/os_x11.cpp | 20 ++++++++++---------- platform/x11/os_x11.h | 5 +++++ 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index efb5fa8dd90..82b79cd9a25 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -829,8 +829,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_cmdline(execpath, main_args); - //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))); + GLOBAL_DEF("rendering/quality/driver/driver_name", "GLES3"); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_name", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_name", PROPERTY_HINT_ENUM, "GLES3,GLES2")); + if (video_driver == "") { + video_driver = GLOBAL_GET("rendering/quality/driver/driver_name"); + } GLOBAL_DEF("display/window/size/width", 1024); GLOBAL_DEF("display/window/size/height", 600); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 6e42eb58bdc..a52c20cbeaa 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1169,8 +1169,6 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a /*** END OSX INITIALIZATION ***/ - bool use_gl2 = p_video_driver != 1; - AudioDriverManager::add_driver(&audio_driver); // only opengl support here... diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 76fc51d52cb..0cdd0f338ba 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -78,19 +78,23 @@ #include int OS_X11::get_video_driver_count() const { - return 1; + + return 2; } const char *OS_X11::get_video_driver_name(int p_driver) const { - String driver_name = GLOBAL_GET("rendering/quality/driver/driver_name"); - if (driver_name == "GLES2") { - return "GLES2"; + switch (p_driver) { + case VIDEO_DRIVER_GLES2: + return "GLES2"; + case VIDEO_DRIVER_GLES3: + default: + return "GLES3"; } - return "GLES3"; } int OS_X11::get_audio_driver_count() const { + return AudioDriverManager::get_driver_count(); } @@ -289,13 +293,9 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a //print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height)); #if defined(OPENGL_ENABLED) - String setting_name = "rendering/quality/driver/driver_name"; - ProjectSettings::get_singleton()->set_custom_property_info(setting_name, PropertyInfo(Variant::STRING, setting_name, PROPERTY_HINT_ENUM, "GLES3,GLES2")); - String video_driver_name = GLOBAL_DEF("rendering/quality/driver/driver_name", "GLES3"); - ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_3_0_COMPATIBLE; - if (video_driver_name == "GLES2") { + if (p_video_driver == VIDEO_DRIVER_GLES2) { opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE; } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 494845bc568..9aa742b0a75 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -53,6 +53,11 @@ #include #endif +enum VideoDriver { + VIDEO_DRIVER_GLES3, + VIDEO_DRIVER_GLES2 +}; + // Hints for X11 fullscreen typedef struct { unsigned long flags;