{ Game initialization. This unit is cross-platform. It will be used by the platform-specific program or library file. } unit GameInitialize; interface implementation uses CastleWindow, CastleLog, CastleApplicationProperties {$region 'Castle Initialization Uses'} // The content here may be automatically updated by CGE editor. , GameViewMain {$endregion 'Castle Initialization Uses'}; var Window: TCastleWindow; { One-time initialization of resources. } procedure ApplicationInitialize; begin { Adjust container settings for a scalable UI (adjusts to any window size in a smart way). } Window.Container.LoadSettings('castle-data:/CastleSettings.xml'); { Create views (see https://castle-engine.io/views ). } {$region 'Castle View Creation'} // The content here may be automatically updated by CGE editor. ViewMain := TViewMain.Create(Application); {$endregion 'Castle View Creation'} Window.Container.View := ViewMain; end; initialization { This initialization section configures: - Application.OnInitialize - Application.MainWindow - determines initial window size You should not need to do anything more in this initialization section. Most of your actual application initialization (in particular, any file reading) should happen inside ApplicationInitialize. } Application.OnInitialize := @ApplicationInitialize; Window := TCastleWindow.Create(Application); Application.MainWindow := Window; { Optionally, adjust window fullscreen state and size at this point. Examples: Run fullscreen: Window.FullScreen := true; Run in a 600x400 window: Window.FullScreen := false; // default Window.Width := 600; Window.Height := 400; Run in a window taking 2/3 of screen (width and height): Window.FullScreen := false; // default Window.Width := Application.ScreenWidth * 2 div 3; Window.Height := Application.ScreenHeight * 2 div 3; Note that some platforms (like mobile) ignore these window sizes. } { On desktops, change the initial window size to simulate a tall screen, like mobile in a "portrait" orientation. } Window.Height := Application.ScreenHeight * 5 div 6; Window.Width := Window.Height * 900 div 1600; { Handle command-line parameters like --fullscreen and --window. By doing this last, you let user to override your fullscreen / mode setup. } Window.ParseParameters; end.