{ Copyright 2018-2024 Benedikt Magnus, Michalis Kamburelis. This file is part of "Castle Game Engine". "Castle Game Engine" is free software; see the file COPYING.txt, included in this distribution, for details about the copyright. "Castle Game Engine" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ---------------------------------------------------------------------------- } { Game initialization. This unit is cross-platform. It will be used by the platform-specific program or library file. } unit GameInitialize; interface implementation uses SysUtils, CastleWindow, CastleLog, CastleUIControls {$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. } { Special code in client / server examples: Portrait-like aspect ratio, similar to mobile portrait mode. } Window.Width := Application.ScreenWidth div 3; Window.Height := Application.ScreenHeight * 3 div 4; { Handle command-line parameters like --fullscreen and --window. By doing this last, you let user to override your fullscreen / mode setup. } Window.ParseParameters; end.