MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnInit

Method OnInit

Source/Engine/Engine/Engine.cpp:77–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75double EngineIdleTime = 0;
76
77int32 Engine::OnInit(const Char* cmdLine)
78{
79#if COMPILE_WITH_PROFILER
80 extern void InitProfilerMemory(const Char* cmdLine, int32 stage);
81 InitProfilerMemory(cmdLine, 0);
82#endif
83 PROFILE_MEM_BEGIN(Engine);
84 EngineImpl::CommandLine = cmdLine;
85 Globals::MainThreadID = Platform::GetCurrentThreadID();
86 StartupTime = DateTime::Now();
87
88 EngineService::Sort();
89
90 if (CommandLine::Parse(cmdLine))
91 {
92 Platform::Fatal(TEXT("Invalid command line."));
93 return -1;
94 }
95
96 // Init platform
97 Platform::SetHighDpiAwarenessEnabled(!CommandLine::Options.LowDPI.IsTrue());
98 if (Platform::Init())
99 {
100 Platform::Fatal(TEXT("Cannot init platform."));
101 return -1;
102 }
103#if COMPILE_WITH_PROFILER
104 InitProfilerMemory(cmdLine, 1);
105#endif
106 Time::StartupTime = DateTime::Now();
107
108 // Setup paths and folders
109 Globals::StartupFolder = Globals::BinariesFolder = Platform::GetMainDirectory();
110#if USE_EDITOR
111 Globals::StartupFolder /= TEXT("../../../..");
112#if PLATFORM_MAC
113 if (Globals::BinariesFolder.EndsWith(TEXT(".app/Contents")))
114 {
115 // If running editor from application package on macOS
116 Globals::StartupFolder = Globals::BinariesFolder;
117 Globals::BinariesFolder /= TEXT("MacOS");
118 }
119#endif
120#endif
121 StringUtils::PathRemoveRelativeParts(Globals::StartupFolder);
122 FileSystem::NormalizePath(Globals::BinariesFolder);
123 FileSystem::GetSpecialFolderPath(SpecialFolder::Temporary, Globals::TemporaryFolder);
124 if (Globals::TemporaryFolder.IsEmpty())
125 Platform::Fatal(TEXT("Failed to gather temporary folder directory."));
126 Globals::TemporaryFolder /= Guid::New().ToString(Guid::FormatType::D);
127
128 // Load game info or project info
129 const int32 result = Application::LoadProduct();
130 if (result != 0)
131 return result;
132
133 // Init logging
134 EngineImpl::InitPaths();

Callers

nothing calls this directly

Calls 12

InitProfilerMemoryFunction · 0.85
NormalizePathFunction · 0.85
DisposeFunction · 0.85
OnInitFunction · 0.85
GetCurrentThreadIDFunction · 0.50
ParseFunction · 0.50
InitFunction · 0.50
NewFunction · 0.50
IsTrueMethod · 0.45
EndsWithMethod · 0.45
IsEmptyMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected