Skip to content
0.2.0-dev Download ZIP
80 lines ·3.2 KB Raw
1/**************************************************************************/
2/* main_ios.mm */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#import "os_ios.h"
32
33#include "core/profiling/profiling.h"
34#import "drivers/apple_embedded/godot_app_delegate_apple_embedded.h"
35#import "drivers/apple_embedded/main_utilities.h"
36#include "main/main.h"
37
38#import <UIKit/UIKit.h>
39
40#include <cstdio>
41
42static OS_IOS *os = nullptr;
43
44int apple_embedded_main(int argc, char **argv) {
45#if defined(VULKAN_ENABLED)
46 //MoltenVK - enable full component swizzling support
47 setenv("MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE", "1", 1);
48#endif
49
50 change_to_launch_dir(argv);
51
52 os = new OS_IOS();
53
54 // We must override main when testing is enabled
55 TEST_MAIN_OVERRIDE
56
57 char *fargv[64];
58 argc = process_args(argc, argv, fargv);
59
60 godot_init_profiler();
61
62 Error err = Main::setup(fargv[0], argc - 1, &fargv[1], false);
63
64 if (err != OK) {
65 if (err == ERR_HELP) { // Returned by --help and --version, so success.
66 return EXIT_SUCCESS;
67 }
68 return EXIT_FAILURE;
69 }
70
71 os->initialize_modules();
72
73 return os->get_exit_code();
74}
75
76void apple_embedded_finish() {
77 Main::cleanup();
78 godot_cleanup_profiler();
79 delete os;
80}