| 696 | } |
| 697 | |
| 698 | void 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 | } |
nothing calls this directly
no test coverage detected