feat: updated engine

This commit is contained in:
Sara Gerretsen 2026-07-10 17:04:34 +02:00
parent cbe99774ff
commit f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions

View file

@ -30,6 +30,7 @@
#include "main.h"
#include "core/config/engine.h"
#include "core/config/project_settings.h"
#include "core/core_globals.h"
#include "core/crypto/crypto.h"
@ -45,23 +46,24 @@
#include "core/io/file_access_zip.h"
#include "core/io/image.h"
#include "core/io/image_loader.h"
#include "core/io/ip.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/object/class_db.h"
#include "core/object/message_queue.h"
#include "core/object/script_language.h"
#include "core/os/os.h"
#include "core/os/process_id.h"
#include "core/os/time.h"
#include "core/profiling/profiling.h"
#include "core/register_core_types.h"
#include "core/string/translation_server.h"
#include "core/variant/variant_parser.h"
#include "core/version.h"
#include "drivers/register_driver_types.h"
#include "main/app_icon.gen.h"
#include "main/main_timer_sync.h"
#include "main/performance.h"
#include "main/splash.gen.h"
#include "modules/register_module_types.h"
#include "platform/register_platform_apis.h"
#include "scene/main/scene_tree.h"
#include "scene/main/window.h"
#include "scene/property_list_helper.h"
@ -71,17 +73,22 @@
#include "servers/audio/audio_driver_dummy.h"
#include "servers/audio/audio_server.h"
#include "servers/camera/camera_server.h"
#include "servers/display/accessibility_server.h"
#include "servers/display/display_server.h"
#include "servers/movie_writer/movie_writer.h"
#include "servers/register_server_types.h"
#include "servers/rendering/rendering_device.h"
#include "servers/rendering/rendering_server.h"
#include "servers/rendering/rendering_server_default.h"
#include "servers/text/text_server.h"
#include "servers/text/text_server_dummy.h"
#include "modules/register_module_types.h"
#include "platform/register_platform_apis.h"
// 2D
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_2d/navigation_server_2d.h"
#include "servers/navigation_2d/navigation_server_2d_dummy.h"
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
@ -92,7 +99,6 @@
// 3D
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_3d/navigation_server_3d.h"
#include "servers/navigation_3d/navigation_server_3d_dummy.h"
#endif // NAVIGATION_3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
@ -105,6 +111,7 @@
#endif // XR_DISABLED
#ifdef TESTS_ENABLED
#include "servers/rendering/dummy/rasterizer_dummy.h"
#include "tests/test_main.h"
#endif
@ -173,6 +180,7 @@ static SteamTracker *steam_tracker = nullptr;
// Initialized in setup2()
static AudioServer *audio_server = nullptr;
static CameraServer *camera_server = nullptr;
static AccessibilityServer *accessibility_server = nullptr;
static DisplayServer *display_server = nullptr;
static RenderingServer *rendering_server = nullptr;
static TextServerManager *tsman = nullptr;
@ -196,14 +204,13 @@ static bool _start_success = false;
String display_driver = "";
String tablet_driver = "";
String text_driver = "";
String rendering_driver = "";
String rendering_method = "";
static int text_driver_idx = -1;
static int audio_driver_idx = -1;
// Engine config/tools
static DisplayServer::AccessibilityMode accessibility_mode = DisplayServer::AccessibilityMode::ACCESSIBILITY_AUTO;
static AccessibilityServerEnums::AccessibilityMode accessibility_mode = AccessibilityServerEnums::AccessibilityMode::ACCESSIBILITY_AUTO;
static String accessibility_driver_name;
static bool accessibility_mode_set = false;
static bool single_window = false;
static bool editor = false;
@ -213,7 +220,7 @@ static String locale;
static String log_file;
static bool show_help = false;
static uint64_t quit_after = 0;
static OS::ProcessID editor_pid = 0;
static ProcessID editor_pid = 0;
#ifdef TOOLS_ENABLED
static bool found_project = false;
static bool recovery_mode = false;
@ -232,13 +239,13 @@ static bool single_threaded_scene = false;
// Display
static DisplayServer::WindowMode window_mode = DisplayServer::WINDOW_MODE_WINDOWED;
static DisplayServer::ScreenOrientation window_orientation = DisplayServer::SCREEN_LANDSCAPE;
static DisplayServer::VSyncMode window_vsync_mode = DisplayServer::VSYNC_ENABLED;
static DisplayServerEnums::WindowMode window_mode = DisplayServerEnums::WINDOW_MODE_WINDOWED;
static DisplayServerEnums::ScreenOrientation window_orientation = DisplayServerEnums::SCREEN_LANDSCAPE;
static DisplayServerEnums::VSyncMode window_vsync_mode = DisplayServerEnums::VSYNC_ENABLED;
static uint32_t window_flags = 0;
static Size2i window_size = Size2i(1152, 648);
static int init_screen = DisplayServer::SCREEN_PRIMARY;
static int init_screen = DisplayServerEnums::SCREEN_PRIMARY;
static bool init_fullscreen = false;
static bool init_maximized = false;
static bool init_windowed = false;
@ -408,6 +415,7 @@ void finalize_display() {
memdelete(rendering_server);
memdelete(display_server);
memdelete(accessibility_server);
}
void initialize_theme_db() {
@ -567,8 +575,11 @@ void Main::print_help(const char *p_binary) {
#if defined(OVERRIDE_PATH_ENABLED)
print_help_option("--path <directory>", "Path to a project (<directory> must contain a \"project.godot\" file).\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
print_help_option("--scene <path>", "Path or UID of a scene in the project that should be started.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
print_help_option("--main-pack <file>", "Path to a pack (.pck) file to load.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
#endif // defined(OVERRIDE_PATH_ENABLED)
#if defined(OVERRIDE_PATH_ENABLED) || defined(ANDROID_ENABLED) || defined(WEB_ENABLED)
print_help_option("--main-pack <file>", "Path to a pack (.pck) file to load.\n", CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE);
#endif // defined(OVERRIDE_PATH_ENABLED) || defined(ANDROID_ENABLED) || defined(WEB_ENABLED)
#ifdef DISABLE_DEPRECATED
print_help_option("--render-thread <mode>", "Render thread mode (\"safe\", \"separate\").\n");
#else
@ -609,7 +620,7 @@ void Main::print_help(const char *p_binary) {
print_help_option("--rendering-method <renderer>", "Renderer name. Requires driver support.\n");
print_help_option("--rendering-driver <driver>", "Rendering driver (depends on display driver).\n");
print_help_option("--gpu-index <device_index>", "Use a specific GPU (run with --verbose to get a list of available devices).\n");
print_help_option("--gpu-index <device_index>", "Use a specific GPU (only available on the Forward+/Mobile renderers; run with --verbose to get a list of available devices).\n");
print_help_option("--text-driver <driver>", "Text driver (used for font rendering, bidirectional support and shaping).\n");
print_help_option("--tablet-driver <driver>", "Pen tablet input driver.\n");
print_help_option("--headless", "Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script.\n");
@ -634,6 +645,7 @@ void Main::print_help(const char *p_binary) {
#endif
print_help_option("--wid <window_id>", "Request parented to window.\n");
print_help_option("--accessibility <mode>", "Select accessibility mode ['auto' (when screen reader is running, default), 'always', 'disabled'].\n");
print_help_option("--accessibility-driver <driver>", "Select accessibility driver ['accesskit', 'dummy'].\n");
print_help_title("Debug options");
print_help_option("-d, --debug", "Debug (local stdout debugger).\n");
@ -723,7 +735,12 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print("\n");
}
#ifdef TESTS_ENABLED
#ifndef TESTS_ENABLED
Error Main::test_setup() {
ERR_FAIL_V(ERR_UNAVAILABLE);
}
void Main::test_cleanup() {}
#else
// The order is the same as in `Main::setup()`, only core and some editor types
// are initialized here. This also combines `Main::setup2()` initialization.
Error Main::test_setup() {
@ -732,6 +749,8 @@ Error Main::test_setup() {
OS::get_singleton()->initialize();
CoreGlobals::print_ready = true;
engine = memnew(Engine);
register_core_types();
@ -788,6 +807,13 @@ Error Main::test_setup() {
translation_server->load_project_translations(translation_server->get_main_domain());
ResourceLoader::load_translation_remaps(); //load remaps for resources
message_queue = memnew(MessageQueue);
RasterizerDummy::make_current();
rendering_server = memnew(RenderingServerDefault());
rendering_server->init();
rendering_server->set_render_loop_enabled(false);
// Initialize ThemeDB early so that scene types can register their theme items.
// Default theme will be initialized later, after modules and ScriptServer are ready.
initialize_theme_db();
@ -858,6 +884,9 @@ Error Main::test_setup() {
void Main::test_cleanup() {
ERR_FAIL_COND(!_start_success);
// Printing in the usual way can become problematic during/after cleanup.
CoreGlobals::print_ready = false;
for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) {
TextServerManager::get_singleton()->get_interface(i)->cleanup();
}
@ -881,6 +910,17 @@ void Main::test_cleanup() {
finalize_theme_db();
if (rendering_server) {
rendering_server->sync();
rendering_server->global_shader_parameters_clear();
rendering_server->finish();
memdelete(rendering_server);
}
if (message_queue) {
message_queue->flush();
memdelete(message_queue);
}
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2DManager::finalize_server();
NavigationServer2DManager::finalize_server_manager();
@ -932,7 +972,7 @@ void Main::test_cleanup() {
OS::get_singleton()->finalize_core();
}
#endif
#endif // TESTS_ENABLED
int Main::test_entrypoint(int argc, char *argv[], bool &tests_need_run) {
for (int x = 0; x < argc; x++) {
@ -994,6 +1034,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->initialize();
CoreGlobals::print_ready = true;
#if !defined(OVERRIDE_PATH_ENABLED) && !defined(TOOLS_ENABLED)
String old_cwd = OS::get_singleton()->get_cwd();
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
@ -1083,6 +1125,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
bool delta_smoothing_override = false;
bool load_shell_env = false;
String rendering_driver = "";
String rendering_method = "";
OS::RenderingSource rendering_driver_source = OS::RenderingSource::RENDERING_SOURCE_DEFAULT;
OS::RenderingSource rendering_method_source = OS::RenderingSource::RENDERING_SOURCE_DEFAULT;
String default_renderer = "";
String default_renderer_mobile = "";
String renderer_hints = "";
@ -1280,6 +1326,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (arg == "--rendering-driver") {
if (N) {
rendering_driver = N->get();
rendering_driver_source = OS::RenderingSource::RENDERING_SOURCE_COMMANDLINE;
N = N->next();
} else {
OS::get_singleton()->print("Missing rendering driver argument, aborting.\n");
@ -1287,10 +1334,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (arg == "-f" || arg == "--fullscreen") { // force fullscreen
init_fullscreen = true;
window_mode = DisplayServer::WINDOW_MODE_FULLSCREEN;
window_mode = DisplayServerEnums::WINDOW_MODE_FULLSCREEN;
} else if (arg == "-m" || arg == "--maximized") { // force maximized window
init_maximized = true;
window_mode = DisplayServer::WINDOW_MODE_MAXIMIZED;
window_mode = DisplayServerEnums::WINDOW_MODE_MAXIMIZED;
} else if (arg == "-w" || arg == "--windowed") { // force windowed window
init_windowed = true;
@ -1354,13 +1401,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (N) {
String string = N->get();
if (string == "auto") {
accessibility_mode = DisplayServer::AccessibilityMode::ACCESSIBILITY_AUTO;
accessibility_mode = AccessibilityServerEnums::AccessibilityMode::ACCESSIBILITY_AUTO;
accessibility_mode_set = true;
} else if (string == "always") {
accessibility_mode = DisplayServer::AccessibilityMode::ACCESSIBILITY_ALWAYS;
accessibility_mode = AccessibilityServerEnums::AccessibilityMode::ACCESSIBILITY_ALWAYS;
accessibility_mode_set = true;
} else if (string == "disabled") {
accessibility_mode = DisplayServer::AccessibilityMode::ACCESSIBILITY_DISABLED;
accessibility_mode = AccessibilityServerEnums::AccessibilityMode::ACCESSIBILITY_DISABLED;
accessibility_mode_set = true;
} else {
OS::get_singleton()->print("Accessibility mode argument not recognized, aborting.\n");
@ -1371,6 +1418,15 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->print("Missing accessibility mode argument, aborting.\n");
goto error;
}
} else if (arg == "--accessibility-driver") {
if (N) {
String string = N->get();
accessibility_driver_name = string;
N = N->next();
} else {
OS::get_singleton()->print("Missing accessibility driver argument, aborting.\n");
goto error;
}
} else if (arg == "-t" || arg == "--always-on-top") { // force always-on-top window
init_always_on_top = true;
@ -1801,10 +1857,28 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
goto error;
}
} else if (arg == "--main-pack") {
#if defined(OVERRIDE_PATH_ENABLED) || defined(WEB_ENABLED) // Note: main-pack is always used on web and can't be disabled.
// Note: main-pack is always used on web and can't be disabled.
// Note: main-pack can be used on Android so long as it's located within the 'assets' directory which is in the executable.
#if defined(OVERRIDE_PATH_ENABLED) || defined(WEB_ENABLED) || defined(ANDROID_ENABLED)
if (N) {
main_pack = N->get();
N = N->next();
#if defined(ANDROID_ENABLED) && !defined(OVERRIDE_PATH_ENABLED)
// Validate that `main_pack` is located within the 'assets' directory.
Ref<FileAccess> main_pack_fa = FileAccess::create_for_path(main_pack);
if (main_pack_fa.is_valid()) {
if (main_pack_fa->get_access_type() != FileAccess::ACCESS_RESOURCES) {
ERR_PRINT(
"--main-pack is attempting to load from outside of the executable, but this Godot binary was compiled without support for path overrides. Aborting.\n"
"To be able to use it, use the `disable_path_overrides=no` SCons option when compiling Godot.\n");
goto error;
}
} else {
ERR_PRINT("Invalid path to main pack file, aborting.\n");
goto error;
}
#endif // defined(ANDROID_ENABLED) && !defined(OVERRIDE_PATH_ENABLED)
} else {
OS::get_singleton()->print("Missing path to main pack file, aborting.\n");
goto error;
@ -1814,7 +1888,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
"`--main-pack` was specified on the command line, but this Godot binary was compiled without support for path overrides. Aborting.\n"
"To be able to use it, use the `disable_path_overrides=no` SCons option when compiling Godot.\n");
goto error;
#endif // defined(OVERRIDE_PATH_ENABLED) || defined(WEB_ENABLED)
#endif // defined(OVERRIDE_PATH_ENABLED) || defined(WEB_ENABLED) || defined(ANDROID_ENABLED)
} else if (arg == "-d" || arg == "--debug") {
debug_uri = "local://";
@ -2150,7 +2224,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
main_args.push_back("--editor");
if (!init_windowed && !init_fullscreen) {
init_maximized = true;
window_mode = DisplayServer::WINDOW_MODE_MAXIMIZED;
window_mode = DisplayServerEnums::WINDOW_MODE_MAXIMIZED;
}
}
@ -2336,11 +2410,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
Array force_angle_list;
#define FORCE_ANGLE(m_vendor, m_name) \
{ \
Dictionary device; \
device["vendor"] = m_vendor; \
device["name"] = m_name; \
#define FORCE_ANGLE(m_vendor, m_name) \
{ \
Dictionary device; \
device["vendor"] = m_vendor; \
device["name"] = m_name; \
force_angle_list.push_back(device); \
}
@ -2572,6 +2646,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// Default to ProjectSettings default if nothing set on the command line.
if (rendering_method.is_empty()) {
rendering_method = GLOBAL_GET("rendering/renderer/rendering_method");
rendering_method_source = OS::RenderingSource::RENDERING_SOURCE_PROJECT_SETTING;
}
if (rendering_driver.is_empty()) {
@ -2579,16 +2654,18 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
rendering_driver = "dummy";
} else if (rendering_method == "gl_compatibility") {
rendering_driver = GLOBAL_GET("rendering/gl_compatibility/driver");
rendering_driver_source = OS::RenderingSource::RENDERING_SOURCE_PROJECT_SETTING;
} else {
rendering_driver = GLOBAL_GET("rendering/rendering_device/driver");
rendering_driver_source = OS::RenderingSource::RENDERING_SOURCE_PROJECT_SETTING;
}
}
// always convert to lower case for consistency in the code
rendering_driver = rendering_driver.to_lower();
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
OS::get_singleton()->set_current_rendering_method(rendering_method);
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver, rendering_driver_source);
OS::get_singleton()->set_current_rendering_method(rendering_method, rendering_method_source);
#ifdef TOOLS_ENABLED
if (!force_res && project_manager) {
@ -2618,33 +2695,33 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
if (!bool(GLOBAL_GET("display/window/size/resizable"))) {
window_flags |= DisplayServer::WINDOW_FLAG_RESIZE_DISABLED_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_RESIZE_DISABLED_BIT;
}
if (bool(GLOBAL_GET("display/window/size/minimize_disabled"))) {
window_flags |= DisplayServer::WINDOW_FLAG_MINIMIZE_DISABLED_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_MINIMIZE_DISABLED_BIT;
}
if (bool(GLOBAL_GET("display/window/size/maximize_disabled"))) {
window_flags |= DisplayServer::WINDOW_FLAG_MAXIMIZE_DISABLED_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_MAXIMIZE_DISABLED_BIT;
}
if (bool(GLOBAL_GET("display/window/size/borderless"))) {
window_flags |= DisplayServer::WINDOW_FLAG_BORDERLESS_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_BORDERLESS_BIT;
}
if (bool(GLOBAL_GET("display/window/size/always_on_top"))) {
window_flags |= DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_ALWAYS_ON_TOP_BIT;
}
if (bool(GLOBAL_GET("display/window/size/transparent"))) {
window_flags |= DisplayServer::WINDOW_FLAG_TRANSPARENT_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_TRANSPARENT_BIT;
}
if (bool(GLOBAL_GET("display/window/size/extend_to_title"))) {
window_flags |= DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_EXTEND_TO_TITLE_BIT;
}
if (bool(GLOBAL_GET("display/window/size/no_focus"))) {
window_flags |= DisplayServer::WINDOW_FLAG_NO_FOCUS_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_NO_FOCUS_BIT;
}
if (bool(GLOBAL_GET("display/window/size/sharp_corners"))) {
window_flags |= DisplayServer::WINDOW_FLAG_SHARP_CORNERS_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_SHARP_CORNERS_BIT;
}
window_mode = (DisplayServer::WindowMode)(GLOBAL_GET("display/window/size/mode").operator int());
window_mode = (DisplayServerEnums::WindowMode)(GLOBAL_GET("display/window/size/mode").operator int());
int initial_position_type = GLOBAL_GET("display/window/size/initial_position_type").operator int();
if (initial_position_type == Window::WINDOW_INITIAL_POSITION_ABSOLUTE) { // Absolute.
if (!init_use_custom_pos) {
@ -2653,7 +2730,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_PRIMARY_SCREEN || initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN) { // Center of Primary Screen.
if (!init_use_custom_screen) {
init_screen = DisplayServer::SCREEN_PRIMARY;
init_screen = DisplayServerEnums::SCREEN_PRIMARY;
init_use_custom_screen = true;
}
} else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN) { // Center of Other Screen.
@ -2663,12 +2740,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_MOUSE_FOCUS) { // Center of Screen With Mouse Pointer.
if (!init_use_custom_screen) {
init_screen = DisplayServer::SCREEN_WITH_MOUSE_FOCUS;
init_screen = DisplayServerEnums::SCREEN_WITH_MOUSE_FOCUS;
init_use_custom_screen = true;
}
} else if (initial_position_type == Window::WINDOW_INITIAL_POSITION_CENTER_SCREEN_WITH_KEYBOARD_FOCUS) { // Center of Screen With Keyboard Focus.
if (!init_use_custom_screen) {
init_screen = DisplayServer::SCREEN_WITH_KEYBOARD_FOCUS;
init_screen = DisplayServerEnums::SCREEN_WITH_KEYBOARD_FOCUS;
init_use_custom_screen = true;
}
}
@ -2751,12 +2828,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
{
window_orientation = DisplayServer::ScreenOrientation(int(GLOBAL_DEF_BASIC("display/window/handheld/orientation", DisplayServer::ScreenOrientation::SCREEN_LANDSCAPE)));
window_orientation = DisplayServerEnums::ScreenOrientation(int(GLOBAL_DEF_BASIC("display/window/handheld/orientation", DisplayServerEnums::ScreenOrientation::SCREEN_LANDSCAPE)));
}
{
window_vsync_mode = DisplayServer::VSyncMode(int(GLOBAL_DEF_BASIC("display/window/vsync/vsync_mode", DisplayServer::VSyncMode::VSYNC_ENABLED)));
window_vsync_mode = DisplayServerEnums::VSyncMode(int(GLOBAL_DEF_BASIC("display/window/vsync/vsync_mode", DisplayServerEnums::VSyncMode::VSYNC_ENABLED)));
if (disable_vsync) {
window_vsync_mode = DisplayServer::VSyncMode::VSYNC_DISABLED;
window_vsync_mode = DisplayServerEnums::VSyncMode::VSYNC_DISABLED;
}
}
@ -2797,6 +2874,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/environment_blend_mode", PROPERTY_HINT_ENUM, "Opaque,Additive,Alpha"), "0");
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/foveation_level", PROPERTY_HINT_ENUM, "Off,Low,Medium,High"), "0");
GLOBAL_DEF_BASIC("xr/openxr/foveation_dynamic", false);
GLOBAL_DEF_BASIC("xr/openxr/foveation_eye_tracked", true);
GLOBAL_DEF_BASIC("xr/openxr/foveation_with_subsampled_images", true);
GLOBAL_DEF_BASIC("xr/openxr/submit_depth_buffer", false);
GLOBAL_DEF_BASIC("xr/openxr/startup_alert", true);
@ -2821,6 +2900,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/extensions/spatial_entity/april_tag_dict", PROPERTY_HINT_ENUM, "4x4H5,5x5H9,6x6H10,6x6H11"), "3");
GLOBAL_DEF_RST_BASIC("xr/openxr/extensions/eye_gaze_interaction", false);
GLOBAL_DEF_BASIC("xr/openxr/extensions/render_model", false);
GLOBAL_DEF_BASIC("xr/openxr/extensions/user_presence", false);
// OpenXR Binding modifier settings
GLOBAL_DEF_BASIC("xr/openxr/binding_modifiers/analog_threshold", false);
@ -2998,9 +3078,9 @@ Error Main::setup2(bool p_show_boot_logo) {
bool ac_found = false;
if (editor) {
screen_property = "interface/editor/editor_screen";
screen_property = "interface/editor/appearance/editor_screen";
} else if (project_manager) {
screen_property = "interface/editor/project_manager_screen";
screen_property = "interface/editor/appearance/project_manager_screen";
} else {
// Skip.
screen_found = true;
@ -3033,13 +3113,13 @@ Error Main::setup2(bool p_show_boot_logo) {
if (!ac_found && assign == "interface/accessibility/accessibility_support") {
accessibility_mode_editor = value;
ac_found = true;
} else if (!init_expand_to_title_found && assign == "interface/editor/expand_to_title") {
} else if (!init_expand_to_title_found && assign == "interface/editor/appearance/expand_to_title") {
init_expand_to_title = value;
init_expand_to_title_found = true;
} else if (!init_display_scale_found && assign == "interface/editor/display_scale") {
} else if (!init_display_scale_found && assign == "interface/editor/appearance/display_scale") {
init_display_scale = value;
init_display_scale_found = true;
} else if (!init_custom_scale_found && assign == "interface/editor/custom_display_scale") {
} else if (!init_custom_scale_found && assign == "interface/editor/appearance/custom_display_scale") {
init_custom_scale = value;
init_custom_scale_found = true;
} else if (!prefer_wayland_found && assign == "run/platforms/linuxbsd/prefer_wayland") {
@ -3050,7 +3130,7 @@ Error Main::setup2(bool p_show_boot_logo) {
prefer_wayland = value;
}
prefer_wayland_found = true;
} else if (!tablet_found && assign == "interface/editor/tablet_driver") {
} else if (!tablet_found && assign == "interface/editor/input/tablet_driver") {
tablet_driver_editor = value;
tablet_found = true;
}
@ -3087,13 +3167,13 @@ Error Main::setup2(bool p_show_boot_logo) {
String mode = config->get_value("EditorWindow", "mode", "maximized");
window_size = config->get_value("EditorWindow", "size", window_size);
if (mode == "windowed") {
window_mode = DisplayServer::WINDOW_MODE_WINDOWED;
window_mode = DisplayServerEnums::WINDOW_MODE_WINDOWED;
init_windowed = true;
} else if (mode == "fullscreen") {
window_mode = DisplayServer::WINDOW_MODE_FULLSCREEN;
window_mode = DisplayServerEnums::WINDOW_MODE_FULLSCREEN;
init_fullscreen = true;
} else {
window_mode = DisplayServer::WINDOW_MODE_MAXIMIZED;
window_mode = DisplayServerEnums::WINDOW_MODE_MAXIMIZED;
init_maximized = true;
}
@ -3105,7 +3185,7 @@ Error Main::setup2(bool p_show_boot_logo) {
}
if (init_screen == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO) {
init_screen = DisplayServer::SCREEN_PRIMARY;
init_screen = DisplayServerEnums::SCREEN_PRIMARY;
}
OS::get_singleton()->benchmark_end_measure("Startup", "Initialize Early Settings");
@ -3194,46 +3274,93 @@ Error Main::setup2(bool p_show_boot_logo) {
Color boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color);
DisplayServer::set_early_window_clear_color_override(true, boot_bg_color);
DisplayServer::Context context;
DisplayServerEnums::Context context;
if (editor) {
context = DisplayServer::CONTEXT_EDITOR;
context = DisplayServerEnums::CONTEXT_EDITOR;
} else if (project_manager) {
context = DisplayServer::CONTEXT_PROJECTMAN;
context = DisplayServerEnums::CONTEXT_PROJECTMAN;
} else {
context = DisplayServer::CONTEXT_ENGINE;
context = DisplayServerEnums::CONTEXT_ENGINE;
}
if (init_embed_parent_window_id) {
// Reset flags and other settings to be sure it's borderless and windowed. The position and size should have been initialized correctly
// from --position and --resolution parameters.
window_mode = DisplayServer::WINDOW_MODE_WINDOWED;
window_flags = DisplayServer::WINDOW_FLAG_BORDERLESS_BIT;
window_mode = DisplayServerEnums::WINDOW_MODE_WINDOWED;
window_flags = DisplayServerEnums::WINDOW_FLAG_BORDERLESS_BIT;
if (bool(GLOBAL_GET("display/window/size/transparent"))) {
window_flags |= DisplayServer::WINDOW_FLAG_TRANSPARENT_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_TRANSPARENT_BIT;
}
}
#ifdef TOOLS_ENABLED
if ((project_manager || editor) && init_expand_to_title) {
window_flags |= DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE_BIT;
window_flags |= DisplayServerEnums::WINDOW_FLAG_EXTEND_TO_TITLE_BIT;
}
#endif
if (!accessibility_mode_set) {
#ifdef TOOLS_ENABLED
if (editor || project_manager || cmdline_tool) {
accessibility_mode = (DisplayServer::AccessibilityMode)accessibility_mode_editor;
accessibility_mode = (AccessibilityServerEnums::AccessibilityMode)accessibility_mode_editor;
} else {
#else
{
#endif
accessibility_mode = (DisplayServer::AccessibilityMode)GLOBAL_GET("accessibility/general/accessibility_support").operator int64_t();
accessibility_mode = (AccessibilityServerEnums::AccessibilityMode)GLOBAL_GET("accessibility/general/accessibility_support").operator int64_t();
}
}
if (accessibility_driver_name.is_empty()) {
if (!editor && !project_manager) {
accessibility_driver_name = GLOBAL_GET("accessibility/general/accessibility_driver");
} else {
accessibility_driver_name = "accesskit";
}
}
if (display_driver == NULL_DISPLAY_DRIVER || display_driver == EMBEDDED_DISPLAY_DRIVER || accessibility_mode == AccessibilityServerEnums::AccessibilityMode::ACCESSIBILITY_DISABLED) {
accessibility_driver_name = "dummy";
}
int accessibility_driver_idx = -1;
if (accessibility_driver_name.is_empty() || accessibility_driver_name == "default") {
accessibility_driver_idx = 0;
} else {
for (int i = 0; i < AccessibilityServer::get_create_function_count(); i++) {
String name = AccessibilityServer::get_create_function_name(i);
if (accessibility_driver_name == name) {
accessibility_driver_idx = i;
break;
}
}
if (accessibility_driver_idx < 0) {
// If the requested driver wasn't found, pick the first entry.
// If all else failed it would be the headless server.
accessibility_driver_idx = 0;
}
}
DisplayServer::accessibility_set_mode(accessibility_mode);
// rendering_driver now held in static global String in main and initialized in setup()
Error err;
accessibility_server = AccessibilityServer::create(accessibility_driver_idx, err);
if (err != OK || accessibility_server == nullptr) {
String last_name = AccessibilityServer::get_create_function_name(accessibility_driver_idx);
for (int i = 0; i < AccessibilityServer::get_create_function_count(); i++) {
if (i == accessibility_driver_idx) {
continue; // Don't try the same twice.
}
String name = AccessibilityServer::get_create_function_name(i);
WARN_VERBOSE(vformat("Accessibility driver %s failed, falling back to %s.", last_name, name));
accessibility_server = AccessibilityServer::create(i, err);
if (err == OK && accessibility_server != nullptr) {
break;
}
}
}
accessibility_server->set_mode(accessibility_mode);
String rendering_driver = OS::get_singleton()->get_current_rendering_driver_name();
display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, init_embed_parent_window_id, err);
if (err != OK || display_server == nullptr) {
String last_name = DisplayServer::get_create_function_name(display_driver_idx);
@ -3315,20 +3442,20 @@ Error Main::setup2(bool p_show_boot_logo) {
break;
}
if (!(force_res || use_custom_res)) {
display_server->window_set_size(Size2(window_size) * ui_scale, DisplayServer::MAIN_WINDOW_ID);
display_server->window_set_size(Size2(window_size) * ui_scale, DisplayServerEnums::MAIN_WINDOW_ID);
}
if (display_server->has_feature(DisplayServer::FEATURE_SUBWINDOWS) && !display_server->has_feature(DisplayServer::FEATURE_SELF_FITTING_WINDOWS)) {
if (display_server->has_feature(DisplayServerEnums::FEATURE_SUBWINDOWS) && !display_server->has_feature(DisplayServerEnums::FEATURE_SELF_FITTING_WINDOWS)) {
Size2 real_size = DisplayServer::get_singleton()->window_get_size();
Rect2i scr_rect = display_server->screen_get_usable_rect(init_screen);
display_server->window_set_position(scr_rect.position + (scr_rect.size - real_size) / 2, DisplayServer::MAIN_WINDOW_ID);
display_server->window_set_position(scr_rect.position + (scr_rect.size - real_size) / 2, DisplayServerEnums::MAIN_WINDOW_ID);
}
}
#endif
if (display_server->has_feature(DisplayServer::FEATURE_SUBWINDOWS)) {
display_server->show_window(DisplayServer::MAIN_WINDOW_ID);
if (display_server->has_feature(DisplayServerEnums::FEATURE_SUBWINDOWS)) {
display_server->show_window(DisplayServerEnums::MAIN_WINDOW_ID);
}
if (display_server->has_feature(DisplayServer::FEATURE_ORIENTATION)) {
if (display_server->has_feature(DisplayServerEnums::FEATURE_ORIENTATION)) {
display_server->screen_set_orientation(window_orientation);
}
@ -3347,7 +3474,7 @@ Error Main::setup2(bool p_show_boot_logo) {
if (editor && init_windowed) {
// We still need to check we are actually in windowed mode, because
// certain platform might only support one fullscreen window.
if (DisplayServer::get_singleton()->window_get_mode() == DisplayServer::WINDOW_MODE_WINDOWED) {
if (DisplayServer::get_singleton()->window_get_mode() == DisplayServerEnums::WINDOW_MODE_WINDOWED) {
Vector2i current_size = DisplayServer::get_singleton()->window_get_size();
Vector2i current_pos = DisplayServer::get_singleton()->window_get_position();
int screen = DisplayServer::get_singleton()->window_get_current_screen();
@ -3368,16 +3495,16 @@ Error Main::setup2(bool p_show_boot_logo) {
if (GLOBAL_GET("debug/settings/stdout/print_fps") || print_fps) {
// Print requested V-Sync mode at startup to diagnose the printed FPS not going above the monitor refresh rate.
switch (window_vsync_mode) {
case DisplayServer::VSyncMode::VSYNC_DISABLED:
case DisplayServerEnums::VSyncMode::VSYNC_DISABLED:
print_line("Requested V-Sync mode: Disabled");
break;
case DisplayServer::VSyncMode::VSYNC_ENABLED:
case DisplayServerEnums::VSyncMode::VSYNC_ENABLED:
print_line("Requested V-Sync mode: Enabled - FPS will likely be capped to the monitor refresh rate.");
break;
case DisplayServer::VSyncMode::VSYNC_ADAPTIVE:
case DisplayServerEnums::VSyncMode::VSYNC_ADAPTIVE:
print_line("Requested V-Sync mode: Adaptive");
break;
case DisplayServer::VSyncMode::VSYNC_MAILBOX:
case DisplayServerEnums::VSyncMode::VSYNC_MAILBOX:
print_line("Requested V-Sync mode: Mailbox");
break;
}
@ -3497,12 +3624,12 @@ Error Main::setup2(bool p_show_boot_logo) {
if (init_windowed) {
//do none..
} else if (init_maximized) {
DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_MAXIMIZED);
DisplayServer::get_singleton()->window_set_mode(DisplayServerEnums::WINDOW_MODE_MAXIMIZED);
} else if (init_fullscreen) {
DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_FULLSCREEN);
DisplayServer::get_singleton()->window_set_mode(DisplayServerEnums::WINDOW_MODE_FULLSCREEN);
}
if (init_always_on_top) {
DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP, true);
DisplayServer::get_singleton()->window_set_flag(DisplayServerEnums::WINDOW_FLAG_ALWAYS_ON_TOP, true);
}
}
@ -3595,7 +3722,7 @@ Error Main::setup2(bool p_show_boot_logo) {
if (!text_driver.is_empty()) {
/* Load user selected text server. */
for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) {
if (TextServerManager::get_singleton()->get_interface(i)->get_name() == text_driver) {
if (TextServerManager::get_singleton()->get_interface(i)->get_short_name() == text_driver || TextServerManager::get_singleton()->get_interface(i)->get_name() == text_driver) {
text_driver_idx = i;
break;
}
@ -3718,7 +3845,7 @@ Error Main::setup2(bool p_show_boot_logo) {
GLOBAL_GET("display/mouse_cursor/custom_image"));
if (cursor.is_valid()) {
Vector2 hotspot = GLOBAL_GET("display/mouse_cursor/custom_image_hotspot");
Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot);
Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CursorShape::CURSOR_ARROW, hotspot);
}
}
@ -3800,7 +3927,7 @@ void Main::setup_boot_logo() {
if (show_logo) { //boot logo!
const bool boot_logo_image = GLOBAL_DEF_BASIC("application/boot_splash/show_image", true);
const RenderingServer::SplashStretchMode boot_stretch_mode = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "application/boot_splash/stretch_mode", PROPERTY_HINT_ENUM, "Disabled,Keep,Keep Width,Keep Height,Cover,Ignore"), 1);
const RSE::SplashStretchMode boot_stretch_mode = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "application/boot_splash/stretch_mode", PROPERTY_HINT_ENUM, "Disabled,Keep,Keep Width,Keep Height,Cover,Ignore"), 1);
const bool boot_logo_filter = GLOBAL_DEF_BASIC("application/boot_splash/use_filter", true);
String boot_logo_path = GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "application/boot_splash/image", PROPERTY_HINT_FILE, "*.png"), String());
@ -3854,12 +3981,12 @@ void Main::setup_boot_logo() {
MAIN_PRINT("Main: ClearColor");
RenderingServer::get_singleton()->set_default_clear_color(boot_bg_color);
MAIN_PRINT("Main: Image");
RenderingServer::get_singleton()->set_boot_image_with_stretch(splash, boot_bg_color, RenderingServer::SPLASH_STRETCH_MODE_DISABLED);
RenderingServer::get_singleton()->set_boot_image_with_stretch(splash, boot_bg_color, RSE::SPLASH_STRETCH_MODE_DISABLED);
#endif
}
#if defined(TOOLS_ENABLED) && defined(MACOS_ENABLED)
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_ICON) && OS::get_singleton()->get_bundle_icon_path().is_empty()) {
if (DisplayServer::get_singleton()->has_feature(DisplayServerEnums::FEATURE_ICON) && OS::get_singleton()->get_bundle_icon_path().is_empty()) {
Ref<Image> icon = memnew(Image(app_icon_png));
DisplayServer::get_singleton()->set_icon(icon);
}
@ -3869,10 +3996,6 @@ void Main::setup_boot_logo() {
GLOBAL_GET("rendering/environment/defaults/default_clear_color"));
}
String Main::get_rendering_driver_name() {
return rendering_driver;
}
String Main::get_locale_override() {
return locale;
}
@ -4243,7 +4366,7 @@ int Main::start() {
ERR_FAIL_COND_V_MSG(script_res.is_null(), EXIT_FAILURE, "Can't load script: " + script);
if (check_only) {
return script_res->is_valid() ? EXIT_SUCCESS : EXIT_FAILURE;
return script_res->is_script_valid() ? EXIT_SUCCESS : EXIT_FAILURE;
}
if (script_res->can_instantiate()) {
@ -4360,7 +4483,7 @@ int Main::start() {
bool embed_subwindows = GLOBAL_GET("display/window/subwindows/embed_subwindows");
if (single_window || (!project_manager && !editor && embed_subwindows) || !DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) {
if (single_window || (!project_manager && !editor && embed_subwindows) || !DisplayServer::get_singleton()->has_feature(DisplayServerEnums::FEATURE_SUBWINDOWS)) {
sml->get_root()->set_embedding_subwindows(true);
}
@ -4371,7 +4494,7 @@ int Main::start() {
if (!game_path.is_empty() || !script.is_empty()) {
//autoload
OS::get_singleton()->benchmark_begin_measure("Startup", "Load Autoloads");
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list();
HashMap<StringName, ProjectSettings::AutoloadInfo> autoloads(ProjectSettings::get_singleton()->get_autoload_list());
//first pass, add the constants so they exist before any script is loaded
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) {
@ -4565,12 +4688,12 @@ int Main::start() {
#ifdef TOOLS_ENABLED
if (editor) {
bool editor_embed_subwindows = EDITOR_GET("interface/editor/single_window_mode");
bool editor_embed_subwindows = EDITOR_GET("interface/editor/display/single_window_mode");
if (editor_embed_subwindows) {
sml->get_root()->set_embedding_subwindows(true);
}
restore_editor_window_layout = EDITOR_GET("interface/editor/editor_screen").operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO;
restore_editor_window_layout = EDITOR_GET("interface/editor/appearance/editor_screen").operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO;
}
#endif
@ -4610,7 +4733,7 @@ int Main::start() {
#ifdef TOOLS_ENABLED
if (editor) {
if (!recovery_mode && (game_path != ResourceUID::ensure_path(String(GLOBAL_GET("application/run/main_scene"))) || !editor_node->has_scenes_in_session())) {
Error serr = editor_node->load_scene(local_game_path);
Error serr = editor_node->open_scene(local_game_path);
if (serr != OK) {
ERR_PRINT("Failed to load scene");
}
@ -4647,7 +4770,7 @@ int Main::start() {
}
#endif
String mac_icon_path = GLOBAL_GET("application/config/macos_native_icon");
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_ICON) && !mac_icon_path.is_empty() && !has_icon) {
if (DisplayServer::get_singleton()->has_feature(DisplayServerEnums::FEATURE_NATIVE_ICON) && !mac_icon_path.is_empty() && !has_icon) {
DisplayServer::get_singleton()->set_native_icon(mac_icon_path);
has_icon = true;
}
@ -4655,14 +4778,14 @@ int Main::start() {
#ifdef WINDOWS_ENABLED
String win_icon_path = GLOBAL_GET("application/config/windows_native_icon");
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_ICON) && !win_icon_path.is_empty()) {
if (DisplayServer::get_singleton()->has_feature(DisplayServerEnums::FEATURE_NATIVE_ICON) && !win_icon_path.is_empty()) {
DisplayServer::get_singleton()->set_native_icon(win_icon_path);
has_icon = true;
}
#endif
String icon_path = GLOBAL_GET("application/config/icon");
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_ICON) && !icon_path.is_empty() && !has_icon) {
if (DisplayServer::get_singleton()->has_feature(DisplayServerEnums::FEATURE_ICON) && !icon_path.is_empty() && !has_icon) {
Ref<Image> icon;
icon.instantiate();
if (ImageLoader::load_image(icon_path, icon) == OK) {
@ -4705,7 +4828,7 @@ int Main::start() {
#endif
}
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_ICON) && !has_icon && OS::get_singleton()->get_bundle_icon_path().is_empty()) {
if (DisplayServer::get_singleton()->has_feature(DisplayServerEnums::FEATURE_ICON) && !has_icon && OS::get_singleton()->get_bundle_icon_path().is_empty()) {
Ref<Image> icon = memnew(Image(app_icon_png));
DisplayServer::get_singleton()->set_icon(icon);
}
@ -5093,6 +5216,9 @@ void Main::cleanup(bool p_force) {
ERR_FAIL_COND(!_start_success);
}
// Printing in the usual way can become problematic during/after cleanup.
CoreGlobals::print_ready = false;
#ifdef DEBUG_ENABLED
if (input) {
input->flush_frame_parsed_events();