summaryrefslogtreecommitdiff
path: root/main/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.cpp')
-rw-r--r--main/main.cpp64
1 files changed, 42 insertions, 22 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 6cc877f8c2..4e63f8750a 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -83,6 +83,7 @@
#include "editor/doc_tools.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "editor/editor_translation.h"
#include "editor/progress_dialog.h"
#include "editor/project_manager.h"
#ifndef NO_EDITOR_SPLASH
@@ -163,7 +164,6 @@ static bool init_windowed = false;
static bool init_always_on_top = false;
static bool init_use_custom_pos = false;
static Vector2 init_custom_pos;
-static bool force_lowdpi = false;
// Debug
@@ -270,8 +270,8 @@ void finalize_navigation_server() {
void Main::print_help(const char *p_binary) {
print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
OS::get_singleton()->print("Free and open source software under the terms of the MIT license.\n");
- OS::get_singleton()->print("(c) 2007-2021 Juan Linietsky, Ariel Manzur.\n");
- OS::get_singleton()->print("(c) 2014-2021 Godot Engine contributors.\n");
+ OS::get_singleton()->print("(c) 2007-2022 Juan Linietsky, Ariel Manzur.\n");
+ OS::get_singleton()->print("(c) 2014-2022 Godot Engine contributors.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Usage: %s [options] [path to scene or 'project.godot' file]\n", p_binary);
OS::get_singleton()->print("\n");
@@ -325,6 +325,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print("].\n");
OS::get_singleton()->print(" --rendering-driver <driver> Rendering driver (depends on display driver).\n");
+ OS::get_singleton()->print(" --gpu-index <device_index> Use a specific GPU (run with --verbose to get available device list).\n");
OS::get_singleton()->print(" --text-driver <driver> Text driver (Fonts, BiDi, shaping)\n");
@@ -339,7 +340,6 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -t, --always-on-top Request an always-on-top window.\n");
OS::get_singleton()->print(" --resolution <W>x<H> Request window resolution.\n");
OS::get_singleton()->print(" --position <X>,<Y> Request window position.\n");
- OS::get_singleton()->print(" --low-dpi Force low-DPI mode (macOS and Windows only).\n");
OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n");
OS::get_singleton()->print(" --tablet-driver Pen tablet input driver.\n");
OS::get_singleton()->print("\n");
@@ -349,7 +349,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n");
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
OS::get_singleton()->print(" --vk-layers Enable Vulkan Validation layers for debugging.\n");
-#if DEBUG_ENABLED
+#ifdef DEBUG_ENABLED
OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n");
#endif
OS::get_singleton()->print(" --remote-debug <uri> Remote debug (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007).\n");
@@ -794,6 +794,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-w" || I->get() == "--windowed") { // force windowed window
init_windowed = true;
+ } else if (I->get() == "--gpu-index") {
+ if (I->next()) {
+ Engine::singleton->gpu_idx = I->next()->get().to_int();
+ N = I->next()->next();
+ } else {
+ OS::get_singleton()->print("Missing gpu index argument, aborting.\n");
+ goto error;
+ }
} else if (I->get() == "--vk-layers") {
Engine::singleton->use_validation_layers = true;
#ifdef DEBUG_ENABLED
@@ -869,9 +877,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
goto error;
}
- } else if (I->get() == "--low-dpi") { // force low DPI (macOS only)
-
- force_lowdpi = true;
} else if (I->get() == "--headless") { // enable headless mode (no audio, no rendering).
audio_driver = "Dummy";
@@ -1364,9 +1369,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF("internationalization/rendering/force_right_to_left_layout_direction", false);
GLOBAL_DEF("internationalization/locale/include_text_server_data", false);
- if (!force_lowdpi) {
- OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false);
- }
+ OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", true);
// FIXME: Restore support.
#if 0
@@ -1602,6 +1605,24 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
display_server->screen_set_orientation(window_orientation);
}
+ 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:
+ print_line("Requested V-Sync mode: Disabled");
+ break;
+ case DisplayServer::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:
+ print_line("Requested V-Sync mode: Adaptive");
+ break;
+ case DisplayServer::VSyncMode::VSYNC_MAILBOX:
+ print_line("Requested V-Sync mode: Mailbox");
+ break;
+ }
+ }
+
/* Initialize Pen Tablet Driver */
{
@@ -1773,7 +1794,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
GLOBAL_DEF("application/config/icon", String());
ProjectSettings::get_singleton()->set_custom_property_info("application/config/icon",
PropertyInfo(Variant::STRING, "application/config/icon",
- PROPERTY_HINT_FILE, "*.png,*.webp,*.svg,*.svgz"));
+ PROPERTY_HINT_FILE, "*.png,*.webp,*.svg"));
GLOBAL_DEF("application/config/macos_native_icon", String());
ProjectSettings::get_singleton()->set_custom_property_info("application/config/macos_native_icon",
@@ -1937,7 +1958,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
}
_start_success = true;
- locale = String();
ClassDB::set_current_api(ClassDB::API_NONE); //no more APIs are registered at this point
@@ -2049,6 +2069,11 @@ bool Main::start() {
// Needed to instance editor-only classes for their default values
Engine::get_singleton()->set_editor_hint(true);
+ // Translate the class reference only when `-l LOCALE` parameter is given.
+ if (!locale.is_empty() && locale != "en") {
+ load_doc_translations(locale);
+ }
+
{
DirAccessRef da = DirAccess::open(doc_tool_path);
ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");
@@ -2316,6 +2341,7 @@ bool Main::start() {
String stretch_aspect = GLOBAL_DEF_BASIC("display/window/stretch/aspect", "keep");
Size2i stretch_size = Size2i(GLOBAL_DEF_BASIC("display/window/size/width", 0),
GLOBAL_DEF_BASIC("display/window/size/height", 0));
+ real_t stretch_scale = GLOBAL_DEF_BASIC("display/window/stretch/scale", 1.0);
Window::ContentScaleMode cs_sm = Window::CONTENT_SCALE_MODE_DISABLED;
if (stretch_mode == "canvas_items") {
@@ -2338,6 +2364,7 @@ bool Main::start() {
sml->get_root()->set_content_scale_mode(cs_sm);
sml->get_root()->set_content_scale_aspect(cs_aspect);
sml->get_root()->set_content_scale_size(stretch_size);
+ sml->get_root()->set_content_scale_factor(stretch_scale);
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));
@@ -2522,13 +2549,6 @@ bool Main::start() {
}
if (project_manager || editor) {
- if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CONSOLE_WINDOW)) {
- // Hide console window if requested (Windows-only).
- bool hide_console = EditorSettings::get_singleton()->get_setting(
- "interface/editor/hide_console_window");
- DisplayServer::get_singleton()->console_set_visible(!hide_console);
- }
-
// Load SSL Certificates from Editor Settings (or builtin)
Crypto::load_default_certificates(
EditorSettings::get_singleton()->get_setting("network/ssl/editor_ssl_certificates").operator String());