-
Notifications
You must be signed in to change notification settings - Fork 1
/
gameinitialize.pas
executable file
·63 lines (48 loc) · 1.92 KB
/
gameinitialize.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
unit GameInitialize;
{$mode objfpc}{$H+}
interface
uses
CastleWindow, CastleScene, CastleControls, CastleLog,
CastleTimeUtils, CastleApplicationProperties, MainGameUnit;
var
Window: TCastleWindowBase;
CastleApp: TCastleApp;
implementation
{ One-time initialization of resources. }
procedure ApplicationInitialize;
begin
CastleApp := TCastleApp.Create(Window);
CastleApp.RunCGEApplication(Window);
Window.onBeforeRender := @WindowBeforeRender;
Window.onClose := @WindowClose;
Window.onMotion := @WindowMotion;
Window.onOpen := @WindowOpen;
Window.onPress := @WindowPress;
Window.onRelease := @WindowRelease;
Window.onRender := @WindowRender;
Window.onResize := @WindowResize;
Window.onUpdate := @WindowUpdate;
Window.Caption := 'Hover CGE Standalone Application';
end;
initialization
{ Set ApplicationName early, as our log uses it.
Optionally you could also set ApplicationProperties.Version here. }
ApplicationProperties.ApplicationName := 'Hover';
{ Start logging. Do this as early as possible,
to log information and eventual warnings during initialization.
For programs, InitializeLog is not called here.
Instead InitializeLog is done by the program main file,
after command-line parameters are parsed. }
if IsLibrary then
InitializeLog;
{ Create and assign Application.MainWindow. }
Window := TCastleWindowBase.Create(Application);
{ Initialize Application.OnInitialize. }
Application.OnInitialize := @ApplicationInitialize;
Application.MainWindow := Window;
{ You should not need to do *anything* more in the unit "initialization" section.
Most of your game initialization should happen inside ApplicationInitialize.
In particular, it is not allowed to read files before ApplicationInitialize
(because in case of non-desktop platforms,
some necessary resources may not be prepared yet). }
end.