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

Method InitMainWindow

Source/Engine/Engine/Engine.cpp:698–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

696}
697
698void EngineImpl::InitMainWindow()
699{
700#if PLATFORM_HAS_HEADLESS_MODE
701 // Try to use headless mode
702 if (CommandLine::Options.Headless.IsTrue())
703 {
704 LOG(Info, "Running in headless mode.");
705 return;
706 }
707#endif
708 PROFILE_CPU_NAMED("Engine::InitMainWindow");
709
710 // Create window
711 Engine::MainWindow = Application::CreateMainWindow();
712 if (!Engine::MainWindow)
713 {
714 LOG(Warning, "No main window created.");
715 return;
716 }
717
718 // Init window rendering output resources
719 if (Engine::MainWindow->InitSwapChain())
720 {
721 Platform::Fatal(TEXT("Cannot init rendering output for a window."));
722 return;
723 }
724
725#if !USE_EDITOR && !COMPILE_WITHOUT_CSHARP
726 // Inform the managed runtime about the window (game can link GUI to it)
727 auto scriptingClass = Scripting::GetStaticClass();
728 ASSERT(scriptingClass);
729 auto setWindowMethod = scriptingClass->GetMethod("SetWindow", 1);
730 ASSERT(setWindowMethod);
731 void* params[1];
732 params[0] = Engine::MainWindow->GetOrCreateManagedInstance();
733 MObject* exception = nullptr;
734 setWindowMethod->Invoke(nullptr, params, &exception);
735 if (exception)
736 {
737 MException ex(exception);
738 ex.Log(LogType::Fatal, TEXT("FlaxEngine.Scripting.SetWindow"));
739 }
740#endif
741}

Callers

nothing calls this directly

Calls 6

InitSwapChainMethod · 0.80
IsTrueMethod · 0.45
GetMethodMethod · 0.45
InvokeMethod · 0.45
LogMethod · 0.45

Tested by

no test coverage detected