summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp65
1 files changed, 62 insertions, 3 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 309ca33264..f3c56c7205 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -65,6 +65,8 @@
#include "servers/audio_server.h"
#include "servers/camera_server.h"
#include "servers/display_server.h"
+#include "servers/movie_writer/movie_writer.h"
+#include "servers/movie_writer/movie_writer_mjpeg.h"
#include "servers/navigation_server_2d.h"
#include "servers/navigation_server_3d.h"
#include "servers/physics_server_2d.h"
@@ -179,6 +181,9 @@ static bool debug_navigation = false;
static int frame_delay = 0;
static bool disable_render_loop = false;
static int fixed_fps = -1;
+static String write_movie_path;
+static MovieWriter *movie_writer = nullptr;
+static bool disable_vsync = false;
static bool print_fps = false;
#ifdef TOOLS_ENABLED
static bool dump_extension_api = false;
@@ -326,6 +331,8 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --text-driver <driver> Text driver (Fonts, BiDi, shaping)\n");
OS::get_singleton()->print(" --tablet-driver <driver> Pen tablet input driver.\n");
OS::get_singleton()->print(" --headless Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script.\n");
+ OS::get_singleton()->print(" --write-movie <file> Run the engine in a way that a movie is written (by default .avi MJPEG). Fixed FPS is forced when enabled, but can be used to change movie FPS. Disabling vsync can speed up movie writing but makes interaction more difficult.\n");
+ OS::get_singleton()->print(" --disable-vsync Force disabling of vsync. Run the engine in a way that a movie is written (by default .avi MJPEG). Fixed FPS is forced when enabled, but can be used to change movie FPS.\n");
OS::get_singleton()->print("\n");
@@ -605,7 +612,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF_RST("application/run/flush_stdout_on_print.debug", true);
GLOBAL_DEF("debug/settings/crash_handler/message",
- String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues"));
+ String("Please include this when reporting the bug to the project developer."));
+ GLOBAL_DEF("debug/settings/crash_handler/message.editor",
+ String("Please include this when reporting the bug on: https://github.com/godotengine/godot/issues"));
MAIN_PRINT("Main: Parse CMDLine");
@@ -1138,6 +1147,20 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->print("Missing fixed-fps argument, aborting.\n");
goto error;
}
+ } else if (I->get() == "--write-movie") {
+ if (I->next()) {
+ write_movie_path = I->next()->get();
+ N = I->next()->next();
+ if (fixed_fps == -1) {
+ fixed_fps = 60;
+ }
+ OS::get_singleton()->_writing_movie = true;
+ } else {
+ OS::get_singleton()->print("Missing write-movie argument, aborting.\n");
+ goto error;
+ }
+ } else if (I->get() == "--disable-vsync") {
+ disable_vsync = true;
} else if (I->get() == "--print-fps") {
print_fps = true;
} else if (I->get() == "--profile-gpu") {
@@ -1464,7 +1487,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
if (audio_driver_idx < 0) {
- audio_driver_idx = 0;
+ audio_driver_idx = 0; // 0 Is always available as the dummy driver (no sound)
+ }
+
+ if (write_movie_path != String()) {
+ // Always use dummy driver for audio driver (which is last), also in no threaded mode.
+ audio_driver_idx = AudioDriverManager::get_driver_count() - 1;
+ AudioDriverDummy::get_dummy_singleton()->set_use_threads(false);
}
{
@@ -1472,6 +1501,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
{
window_vsync_mode = DisplayServer::VSyncMode(int(GLOBAL_DEF("display/window/vsync/vsync_mode", DisplayServer::VSyncMode::VSYNC_ENABLED)));
+ if (disable_vsync) {
+ window_vsync_mode = DisplayServer::VSyncMode::VSYNC_DISABLED;
+ }
}
Engine::get_singleton()->set_physics_ticks_per_second(GLOBAL_DEF_BASIC("physics/common/physics_ticks_per_second", 60));
ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_ticks_per_second",
@@ -1511,7 +1543,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
"0,33200,1,or_greater")); // No negative numbers
GLOBAL_DEF("display/window/ios/hide_home_indicator", true);
- GLOBAL_DEF("input_devices/pointing/ios/touch_delay", 0.150);
+ GLOBAL_DEF("input_devices/pointing/ios/touch_delay", 0.15);
+ ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pointing/ios/touch_delay",
+ PropertyInfo(Variant::FLOAT,
+ "input_devices/pointing/ios/touch_delay",
+ PROPERTY_HINT_RANGE, "0,1,0.001"));
// XR project settings.
GLOBAL_DEF_RST_BASIC("xr/openxr/enabled", false);
@@ -1551,6 +1587,7 @@ error:
display_driver = "";
audio_driver = "";
tablet_driver = "";
+ write_movie_path = "";
project_path = "";
args.clear();
@@ -1723,6 +1760,14 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
rendering_server->set_print_gpu_profile(true);
}
+ if (write_movie_path != String()) {
+ movie_writer = MovieWriter::find_writer_for_file(write_movie_path);
+ if (movie_writer == nullptr) {
+ ERR_PRINT("Can't find movie writer for file type, aborting: " + write_movie_path);
+ write_movie_path = String();
+ }
+ }
+
#ifdef UNIX_ENABLED
// Print warning after initializing the renderer but before initializing audio.
if (OS::get_singleton()->get_environment("USER") == "root" && !OS::get_singleton()->has_environment("GODOT_SILENCE_ROOT_WARNING")) {
@@ -2651,6 +2696,9 @@ bool Main::start() {
OS::get_singleton()->set_main_loop(main_loop);
+ if (movie_writer) {
+ movie_writer->begin(DisplayServer::get_singleton()->window_get_size(), fixed_fps, write_movie_path);
+ }
return true;
}
@@ -2837,6 +2885,13 @@ bool Main::iteration() {
Input::get_singleton()->flush_buffered_events();
}
+ if (movie_writer) {
+ RID main_vp_rid = RenderingServer::get_singleton()->viewport_find_from_screen_attachment(DisplayServer::MAIN_WINDOW_ID);
+ RID main_vp_texture = RenderingServer::get_singleton()->viewport_get_texture(main_vp_rid);
+ Ref<Image> vp_tex = RenderingServer::get_singleton()->texture_2d_get(main_vp_texture);
+ movie_writer->add_frame(vp_tex);
+ }
+
if (fixed_fps != -1) {
return exit;
}
@@ -2876,6 +2931,10 @@ void Main::cleanup(bool p_force) {
ERR_FAIL_COND(!_start_success);
}
+ if (movie_writer) {
+ movie_writer->end();
+ }
+
ResourceLoader::remove_custom_loaders();
ResourceSaver::remove_custom_savers();