Debian Codegraph @

examples/animations/expose_transformations_to_animate_children/code/gameinitialize.pas

raw
1 {
2 Copyright 2020-2023 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { Game initialization.
17 This unit is cross-platform.
18 It will be used by the platform-specific program or library file. }
19 unit GameInitialize;
20
21 interface
22
23 implementation
24
25 uses SysUtils,
26 CastleWindow, CastleScene, CastleControls, CastleLog,
27 CastleFilesUtils, CastleSceneCore, CastleKeysMouse, CastleColors,
28 CastleUIControls, CastleApplicationProperties
29 {$region 'Castle Initialization Uses'}
30 // The content here may be automatically updated by CGE editor.
31 , GameViewMain
32 {$endregion 'Castle Initialization Uses'};
33
34 var
35 Window: TCastleWindow;
36
37 { One-time initialization of resources. }
38 procedure ApplicationInitialize;
39 begin
40 { Adjust container settings for a scalable UI (adjusts to any window size in a smart way). }
41 Window.Container.LoadSettings('castle-data:/CastleSettings.xml');
42
43 { Create views (see https://castle-engine.io/views ). }
44 {$region 'Castle View Creation'}
45 // The content here may be automatically updated by CGE editor.
46 ViewMain := TViewMain.Create(Application);
47 {$endregion 'Castle View Creation'}
48
49 Window.Container.View := ViewMain;
50 end;
51
52 initialization
53 { This initialization section configures:
54 - Application.OnInitialize
55 - Application.MainWindow
56 - determines initial window size
57
58 You should not need to do anything more in this initialization section.
59 Most of your actual application initialization (in particular, any file reading)
60 should happen inside ApplicationInitialize. }
61
62 Application.OnInitialize := @ApplicationInitialize;
63
64 Window := TCastleWindow.Create(Application);
65 Application.MainWindow := Window;
66
67 { Optionally, adjust window fullscreen state and size at this point.
68 Examples:
69
70 Run fullscreen:
71
72 Window.FullScreen := true;
73
74 Run in a 600x400 window:
75
76 Window.FullScreen := false; // default
77 Window.Width := 600;
78 Window.Height := 400;
79
80 Run in a window taking 2/3 of screen (width and height):
81
82 Window.FullScreen := false; // default
83 Window.Width := Application.ScreenWidth * 2 div 3;
84 Window.Height := Application.ScreenHeight * 2 div 3;
85
86 Note that some platforms (like mobile) ignore these window sizes.
87 }
88
89 { Handle command-line parameters like --fullscreen and --window.
90 By doing this last, you let user to override your fullscreen / mode setup. }
91 Window.ParseParameters;
92 end.