diff options
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/main/main.cpp b/main/main.cpp index bb6ab11362..2a08b03b96 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -36,6 +36,7 @@ #include "core/crypto/crypto.h" #include "core/debugger/engine_debugger.h" #include "core/extension/extension_api_dump.h" +#include "core/extension/gdnative_interface_dump.gen.h" #include "core/extension/native_extension_manager.h" #include "core/input/input.h" #include "core/input/input_map.h" @@ -199,6 +200,7 @@ static MovieWriter *movie_writer = nullptr; static bool disable_vsync = false; static bool print_fps = false; #ifdef TOOLS_ENABLED +static bool dump_gdnative_interface = false; static bool dump_extension_api = false; #endif bool profile_gpu = false; @@ -231,7 +233,7 @@ static String get_full_version_string() { void initialize_physics() { /// 3D Physics Server physics_server_3d = PhysicsServer3DManager::get_singleton()->new_server( - ProjectSettings::get_singleton()->get(PhysicsServer3DManager::setting_property_name)); + GLOBAL_GET(PhysicsServer3DManager::setting_property_name)); if (!physics_server_3d) { // Physics server not found, Use the default physics physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server(); @@ -241,7 +243,7 @@ void initialize_physics() { // 2D Physics server physics_server_2d = PhysicsServer2DManager::get_singleton()->new_server( - ProjectSettings::get_singleton()->get(PhysicsServer2DManager::get_singleton()->setting_property_name)); + GLOBAL_GET(PhysicsServer2DManager::get_singleton()->setting_property_name)); if (!physics_server_2d) { // Physics server not found, Use the default physics physics_server_2d = PhysicsServer2DManager::get_singleton()->new_default_server(); @@ -414,6 +416,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" --doctool [<path>] Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n"); OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n"); OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n"); + OS::get_singleton()->print(" --dump-gdextension-interface Generate GDExtension header file 'gdnative_interface.h' in the current folder. This file is the base file required to implement a GDExtension.\n"); OS::get_singleton()->print(" --dump-extension-api Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder.\n"); OS::get_singleton()->print(" --startup-benchmark Benchmark the startup time and print it to console.\n"); OS::get_singleton()->print(" --startup-benchmark-file <path> Benchmark the startup time and save it to a given file in JSON format.\n"); @@ -1054,6 +1057,16 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph auto_build_solutions = true; editor = true; cmdline_tool = true; + } else if (I->get() == "--dump-gdextension-interface") { + // Register as an editor instance to use low-end fallback if relevant. + editor = true; + cmdline_tool = true; + dump_gdnative_interface = true; + print_line("Dumping gdnative interface header file"); + // Hack. Not needed but otherwise we end up detecting that this should + // run the project instead of a cmdline tool. + // Needs full refactoring to fix properly. + main_args.push_back(I->get()); } else if (I->get() == "--dump-extension-api") { // Register as an editor instance to use low-end fallback if relevant. editor = true; @@ -1446,10 +1459,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph input_map->load_from_project_settings(); //keys for game } - if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stdout"))) { + if (bool(GLOBAL_GET("application/run/disable_stdout"))) { quiet_stdout = true; } - if (bool(ProjectSettings::get_singleton()->get("application/run/disable_stderr"))) { + if (bool(GLOBAL_GET("application/run/disable_stderr"))) { CoreGlobals::print_error_enabled = false; }; @@ -1457,7 +1470,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph CoreGlobals::print_line_enabled = false; } - Logger::set_flush_stdout_on_print(ProjectSettings::get_singleton()->get("application/run/flush_stdout_on_print")); + Logger::set_flush_stdout_on_print(GLOBAL_GET("application/run/flush_stdout_on_print")); OS::get_singleton()->set_cmdline(execpath, main_args, user_args); @@ -1530,6 +1543,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph if (default_renderer_mobile.is_empty()) { default_renderer_mobile = "gl_compatibility"; } + // Default to Compatibility when using the project manager. + if (rendering_driver.is_empty() && rendering_method.is_empty() && project_manager) { + rendering_driver = "opengl3"; + rendering_method = "gl_compatibility"; + } #endif if (renderer_hints.is_empty()) { ERR_PRINT("No renderers available."); @@ -1590,11 +1608,17 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // Now validate whether the selected driver matches with the renderer. bool valid_combination = false; Vector<String> available_drivers; +#ifdef VULKAN_ENABLED if (rendering_method == "forward_plus" || rendering_method == "mobile") { available_drivers.push_back("vulkan"); - } else if (rendering_method == "gl_compatibility") { + } +#endif +#ifdef GLES3_ENABLED + if (rendering_method == "gl_compatibility") { available_drivers.push_back("opengl3"); - } else { + } +#endif + if (available_drivers.is_empty()) { OS::get_singleton()->print("Unknown renderer name '%s', aborting.\n", rendering_method.utf8().get_data()); goto error; } @@ -1807,6 +1831,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph PROPERTY_HINT_RANGE, "0,33200,1,or_greater")); // No negative numbers + GLOBAL_DEF("display/window/ios/allow_high_refresh_rate", true); GLOBAL_DEF("display/window/ios/hide_home_indicator", true); GLOBAL_DEF("display/window/ios/hide_status_bar", true); GLOBAL_DEF("display/window/ios/suppress_ui_gesture", true); @@ -1956,9 +1981,15 @@ Error Main::setup2(Thread::ID p_main_tid_override) { { String display_driver = DisplayServer::get_create_function_name(display_driver_idx); + Vector2i *window_position = nullptr; + Vector2i position = init_custom_pos; + if (init_use_custom_pos) { + window_position = &position; + } + // rendering_driver now held in static global String in main and initialized in setup() Error err; - display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_size, err); + display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, err); if (err != OK || display_server == nullptr) { // We can't use this display server, try other ones as fallback. // Skip headless (always last registered) because that's not what users @@ -1967,7 +1998,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { if (i == display_driver_idx) { continue; // Don't try the same twice. } - display_server = DisplayServer::create(i, rendering_driver, window_mode, window_vsync_mode, window_flags, window_size, err); + display_server = DisplayServer::create(i, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, err); if (err == OK && display_server != nullptr) { break; } @@ -2315,11 +2346,11 @@ Error Main::setup2(Thread::ID p_main_tid_override) { "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp")); - if (String(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")) != String()) { + if (String(GLOBAL_GET("display/mouse_cursor/custom_image")) != String()) { Ref<Texture2D> cursor = ResourceLoader::load( - ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")); + GLOBAL_GET("display/mouse_cursor/custom_image")); if (cursor.is_valid()) { - Vector2 hotspot = ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image_hotspot"); + Vector2 hotspot = GLOBAL_GET("display/mouse_cursor/custom_image_hotspot"); Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot); } } @@ -2551,8 +2582,15 @@ bool Main::start() { return false; } + if (dump_gdnative_interface) { + GDNativeInterfaceDump::generate_gdnative_interface_file("gdnative_interface.h"); + } + if (dump_extension_api) { NativeExtensionAPIDump::generate_extension_json_file("extension_api.json"); + } + + if (dump_gdnative_interface || dump_extension_api) { return false; } @@ -2801,7 +2839,7 @@ bool Main::start() { sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true)); sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true)); - String appname = ProjectSettings::get_singleton()->get("application/config/name"); + String appname = GLOBAL_GET("application/config/name"); appname = TranslationServer::get_singleton()->translate(appname); #ifdef DEBUG_ENABLED // Append a suffix to the window title to denote that the project is running |