summaryrefslogtreecommitdiff
path: root/main/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.cpp')
-rwxr-xr-x[-rw-r--r--]main/main.cpp90
1 files changed, 52 insertions, 38 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 5e8e52d3e5..c9b84d2cd1 100644..100755
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -35,6 +35,7 @@
#include "message_queue.h"
#include "modules/register_module_types.h"
#include "os/os.h"
+#include "platform/register_platform_apis.h"
#include "project_settings.h"
#include "scene/register_scene_types.h"
#include "script_debugger_local.h"
@@ -176,7 +177,7 @@ static String get_full_version_string() {
void Main::print_help(const char *p_binary) {
- print_line(String(_MKSTR(VERSION_NAME)) + " v" + get_full_version_string() + " - https://godotengine.org");
+ print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - https://godotengine.org");
OS::get_singleton()->print("(c) 2007-2017 Juan Linietsky, Ariel Manzur.\n");
OS::get_singleton()->print("(c) 2014-2017 Godot Engine contributors.\n");
OS::get_singleton()->print("\n");
@@ -289,12 +290,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
register_core_settings(); //here globals is present
- OS::get_singleton()->initialize_logger();
-
translation_server = memnew(TranslationServer);
performance = memnew(Performance);
ClassDB::register_class<Performance>();
- globals->add_singleton(ProjectSettings::Singleton("Performance", performance));
+ engine->add_singleton(Engine::Singleton("Performance", performance));
GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues"));
@@ -321,8 +320,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 = ".";
@@ -428,6 +425,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-m" || I->get() == "--maximized") { // force maximized window
init_maximized = true;
+ video_mode.maximized = true;
} else if (I->get() == "-w" || I->get() == "--windowed") { // force windowed window
init_windowed = true;
@@ -745,10 +743,20 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#endif
}
+ GLOBAL_DEF("logging/file_logging/enable_file_logging", false);
+ GLOBAL_DEF("logging/file_logging/log_path", "user://logs/log.txt");
+ GLOBAL_DEF("logging/file_logging/max_log_files", 10);
+ if (FileAccess::get_create_func(FileAccess::ACCESS_USERDATA) && GLOBAL_GET("logging/file_logging/enable_file_logging")) {
+ String base_path = GLOBAL_GET("logging/file_logging/log_path");
+ int max_files = GLOBAL_GET("logging/file_logging/max_log_files");
+ OS::get_singleton()->add_logger(memnew(RotatedFileLogger(base_path, max_files)));
+ }
+
if (editor) {
Engine::get_singleton()->set_editor_hint(true);
main_args.push_back("--editor");
init_maximized = true;
+ video_mode.maximized = true;
use_custom_res = false;
}
@@ -779,38 +787,41 @@ 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;
+ GLOBAL_DEF("display/window/size/width", 1024);
+ GLOBAL_DEF("display/window/size/height", 600);
+ GLOBAL_DEF("display/window/size/resizable", true);
+ GLOBAL_DEF("display/window/size/borderless", false);
+ GLOBAL_DEF("display/window/size/fullscreen", false);
+ GLOBAL_DEF("display/window/size/test_width", 0);
+ GLOBAL_DEF("display/window/size/test_height", 0);
+
+ if (use_custom_res) {
+
+ if (!force_res) {
+ video_mode.width = GLOBAL_GET("display/window/size/width");
+ video_mode.height = GLOBAL_GET("display/window/size/height");
+
+ 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_GET("display/window/size/resizable");
+ video_mode.borderless_window = GLOBAL_GET("display/window/size/borderless");
+ video_mode.fullscreen = GLOBAL_GET("display/window/size/fullscreen");
}
- 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);
- GLOBAL_DEF("display/window/size/test_width", 0);
- GLOBAL_DEF("display/window/size/test_height", 0);
+ 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("rendering/quality/intended_usage/framebuffer_allocation", 2);
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3);
@@ -821,8 +832,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->_keep_screen_on = GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true);
if (rtm == -1) {
rtm = GLOBAL_DEF("rendering/threads/thread_model", OS::RENDER_THREAD_SAFE);
- if (rtm >= 1) //hack for now
- rtm = 1;
}
if (rtm >= 0 && rtm < 3) {
@@ -901,6 +910,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
frame_delay = GLOBAL_DEF("application/run/frame_delay_msec", 0);
}
+ OS::get_singleton()->set_low_processor_usage_mode(GLOBAL_DEF("application/run/low_processor_mode", false));
+ OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(GLOBAL_DEF("application/run/low_processor_mode_sleep_usec", 8000));
+
Engine::get_singleton()->set_frame_delay(frame_delay);
message_queue = memnew(MessageQueue);
@@ -1107,6 +1119,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts");
+ register_platform_apis();
register_module_types();
initialize_physics();
@@ -1763,7 +1776,7 @@ bool Main::iteration() {
return exit;
if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw())
- OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max)
+ OS::get_singleton()->delay_usec(OS::get_singleton()->get_low_processor_usage_mode_sleep_usec()); //apply some delay to force idle time (results in about 60 FPS max)
else {
uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
if (frame_delay)
@@ -1824,6 +1837,7 @@ void Main::cleanup() {
unregister_driver_types();
unregister_module_types();
+ unregister_platform_apis();
unregister_scene_types();
unregister_server_types();