MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / godot_web_main

Function godot_web_main

platform/web/web_main.cpp:129–175  ·  view source on GitHub ↗

When calling main, it is assumed FS is setup and synced.

Source from the content-addressed store, hash-verified

127
128/// When calling main, it is assumed FS is setup and synced.
129extern EMSCRIPTEN_KEEPALIVE int godot_web_main(int argc, char *argv[]) {
130 os = new OS_Web();
131
132#ifdef TOOLS_ENABLED
133 WebToolsEditorPlugin::initialize();
134#endif
135
136 // We must override main when testing is enabled
137 TEST_MAIN_OVERRIDE
138
139 Error err = Main::setup(argv[0], argc - 1, &argv[1]);
140
141 // Proper shutdown in case of setup failure.
142 if (err != OK) {
143 // Will only exit after sync.
144 emscripten_set_main_loop(exit_callback, -1, false);
145 godot_js_os_finish_async(cleanup_after_sync);
146 if (err == ERR_HELP) { // Returned by --help and --version, so success.
147 return EXIT_SUCCESS;
148 }
149 return EXIT_FAILURE;
150 }
151
152 print_web_header();
153
154 main_started = true;
155
156 // Ease up compatibility.
157 ResourceLoader::set_abort_on_missing_resources(false);
158
159 int ret = Main::start();
160 os->set_exit_code(ret);
161 os->get_main_loop()->initialize();
162#ifdef TOOLS_ENABLED
163 if (Engine::get_singleton()->is_project_manager_hint() && FileAccess::exists("/tmp/preload.zip")) {
164 PackedStringArray ps;
165 ps.push_back("/tmp/preload.zip");
166 SceneTree::get_singleton()->get_root()->emit_signal(SNAME("files_dropped"), ps);
167 }
168#endif
169 emscripten_set_main_loop(main_loop_callback, -1, false);
170 // Immediately run the first iteration.
171 // We are inside an animation frame, we want to immediately draw on the newly setup canvas.
172 main_loop_callback();
173
174 return os->get_exit_code();
175}

Callers 1

mainFunction · 0.85

Calls 11

initializeFunction · 0.85
print_web_headerFunction · 0.85
main_loop_callbackFunction · 0.85
set_exit_codeMethod · 0.80
emit_signalMethod · 0.80
get_exit_codeMethod · 0.80
initializeMethod · 0.45
get_main_loopMethod · 0.45
push_backMethod · 0.45
get_rootMethod · 0.45

Tested by

no test coverage detected