| 1 |
{ |
| 2 |
Copyright 2022-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 |
{ Main LCL form. } |
| 17 |
unit FormMain; |
| 18 |
|
| 19 |
{$mode objfpc}{$H+} |
| 20 |
|
| 21 |
interface |
| 22 |
|
| 23 |
uses |
| 24 |
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, |
| 25 |
CastleControl; |
| 26 |
|
| 27 |
type |
| 28 |
|
| 29 |
{ TMainForm } |
| 30 |
|
| 31 |
TMainForm = class(TForm) |
| 32 |
ButtonTest2D: TButton; |
| 33 |
ButtonTest3D: TButton; |
| 34 |
CastleControl1: TCastleControl; |
| 35 |
Panel1: TPanel; |
| 36 |
procedure ButtonTest2DClick(Sender: TObject); |
| 37 |
procedure ButtonTest3DClick(Sender: TObject); |
| 38 |
procedure FormCreate(Sender: TObject); |
| 39 |
private |
| 40 |
|
| 41 |
public |
| 42 |
|
| 43 |
end; |
| 44 |
|
| 45 |
var |
| 46 |
MainForm: TMainForm; |
| 47 |
|
| 48 |
implementation |
| 49 |
|
| 50 |
uses CastleUtils |
| 51 |
{$region 'Castle Initialization Uses'} |
| 52 |
// The content here may be automatically updated by CGE editor. |
| 53 |
, GameViewTest2D |
| 54 |
, GameViewTest3D |
| 55 |
{$endregion 'Castle Initialization Uses'}; |
| 56 |
|
| 57 |
{$R *.lfm} |
| 58 |
|
| 59 |
{ TMainForm } |
| 60 |
|
| 61 |
procedure TMainForm.ButtonTest2DClick(Sender: TObject); |
| 62 |
begin |
| 63 |
CastleControl1.Container.View := ViewTest2D; |
| 64 |
end; |
| 65 |
|
| 66 |
procedure TMainForm.ButtonTest3DClick(Sender: TObject); |
| 67 |
begin |
| 68 |
CastleControl1.Container.View := ViewTest3D; |
| 69 |
end; |
| 70 |
|
| 71 |
procedure TMainForm.FormCreate(Sender: TObject); |
| 72 |
begin |
| 73 |
{ Create game views and set initial view. |
| 74 |
|
| 75 |
Note: We define special $region to allow CGE editor "New View" |
| 76 |
to be able to automatically add creation of new views here. |
| 77 |
It isn't necessary at all, you don't need this special $region |
| 78 |
and you can create ciews whenever you want. } |
| 79 |
{$region 'Castle View Creation'} |
| 80 |
// The content here may be automatically updated by CGE editor. |
| 81 |
ViewTest2D := TViewTest2D.Create(Application); |
| 82 |
ViewTest3D := TViewTest3D.Create(Application); |
| 83 |
{$endregion 'Castle View Creation'} |
| 84 |
|
| 85 |
CastleControl1.Container.View := ViewTest2D; |
| 86 |
end; |
| 87 |
|
| 88 |
end. |
| 89 |
|