| 1 |
{ |
| 2 |
Copyright 2018-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 |
{ Castle Game Engine editor. |
| 17 |
|
| 18 |
See https://castle-engine.io/manual_editor.php about editor usage. |
| 19 |
See README.md about editor development. |
| 20 |
|
| 21 |
When this LPR code changes (e.g. new auto-created form is added), |
| 22 |
remember to rerun ../build-tool/data/custom_editor_template_rebuild.sh . } |
| 23 |
program castle_editor; |
| 24 |
|
| 25 |
{$mode objfpc}{$H+} |
| 26 |
|
| 27 |
{ CGE applications use threads for |
| 28 |
- music streaming (when TCastleSound.Stream = @true) |
| 29 |
- asynchronous downloading (TCastleDownload with protocols like http/https) |
| 30 |
- and maybe more in the future. } |
| 31 |
{$define UseCThreads} |
| 32 |
|
| 33 |
uses |
| 34 |
{$IFDEF UNIX}{$IFDEF UseCThreads} |
| 35 |
cthreads, |
| 36 |
{$ENDIF}{$ENDIF} |
| 37 |
Interfaces, // this includes the LCL widgetset |
| 38 |
// packages: |
| 39 |
castle_components, |
| 40 |
// This line was uncommented by tools/build-tool/data/custom_editor_template_rebuild.sh |
| 41 |
castle_editor_automatic_package, |
| 42 |
Forms, anchordockpkg, FormChooseProject, ProjectUtils, FormNewProject, |
| 43 |
EditorUtils, FormProject, FrameDesign, FormAbout, FrameViewFile, |
| 44 |
FormPreferences, DesignVisualizeTransform, FormSpriteSheetEditor, |
| 45 |
DataModuleIcons, FormImportAtlas, FormImportStarling, FormNewUnit, |
| 46 |
EditorCodeTools, CastleShellCtrls, FormSystemInformation, |
| 47 |
CastleComponentEditorDesigner, DesignCameraPreview, DesignObjectInspector, |
| 48 |
DesignUndoSystem, FormRestartCustomEditor, FormImportSketchfab, FormProgress; |
| 49 |
|
| 50 |
{ Forces using a dedicated (faster) GPU on laptops with multiple GPUs. |
| 51 |
See https://castle-engine.io/dedicated_gpu } |
| 52 |
{$if (not defined(CASTLE_NO_FORCE_DEDICATED_GPU)) and (defined(cpu386) or defined(cpux64) or defined(cpuamd64)) and (defined(MSWINDOWS) or defined(Linux))} |
| 53 |
{$ifdef fpc} |
| 54 |
{$asmmode intel} |
| 55 |
{$endif} |
| 56 |
|
| 57 |
procedure NvOptimusEnablement; {$ifdef fpc}assembler; nostackframe;{$endif} |
| 58 |
asm |
| 59 |
{$ifdef cpu64} |
| 60 |
{$ifndef fpc} |
| 61 |
.NOFRAME |
| 62 |
{$endif} |
| 63 |
{$endif} |
| 64 |
dd 1 |
| 65 |
end; |
| 66 |
|
| 67 |
procedure AmdPowerXpressRequestHighPerformance; {$ifdef fpc}assembler; nostackframe;{$endif} |
| 68 |
asm |
| 69 |
{$ifdef cpu64} |
| 70 |
{$ifndef fpc} |
| 71 |
.NOFRAME |
| 72 |
{$endif} |
| 73 |
{$endif} |
| 74 |
dd 1 |
| 75 |
end; |
| 76 |
|
| 77 |
exports |
| 78 |
NvOptimusEnablement, |
| 79 |
AmdPowerXpressRequestHighPerformance; |
| 80 |
{$ifend} |
| 81 |
|
| 82 |
{$R *.res} |
| 83 |
|
| 84 |
{ Do not auto-create below forms that use TCastleControl, and would initialize OpenGL |
| 85 |
right when the CGE editor opens. |
| 86 |
|
| 87 |
Reason: In case someone has broken OpenGL library installation |
| 88 |
we don't want to have CGE editor just crash at start, it's better if it will crash |
| 89 |
later -- allowing us to recognize this case (e.g. because it crashes when you open any |
| 90 |
design or "System Information"). |
| 91 |
|
| 92 |
If there's a single variable to hold single form instance, you can initialize it on-demand, like |
| 93 |
|
| 94 |
if SystemInformationForm = nil then |
| 95 |
SystemInformationForm := TSystemInformationForm.Create(Application); |
| 96 |
SystemInformationForm.Show; |
| 97 |
} |
| 98 |
|
| 99 |
begin |
| 100 |
RequireDerivedFormResource := True; |
| 101 |
Application.Scaled := True; |
| 102 |
Application.Initialize; |
| 103 |
Application.CreateForm(TIcons, Icons); |
| 104 |
Application.CreateForm(TChooseProjectForm, ChooseProjectForm); |
| 105 |
Application.CreateForm(TNewProjectForm, NewProjectForm); |
| 106 |
Application.CreateForm(TAboutForm, AboutForm); |
| 107 |
Application.CreateForm(TPreferencesForm, PreferencesForm); |
| 108 |
Application.CreateForm(TImportAtlasForm, ImportAtlasForm); |
| 109 |
Application.CreateForm(TImportStarlingForm, ImportStarlingForm); |
| 110 |
Application.CreateForm(TNewUnitForm, NewUnitForm); |
| 111 |
Application.CreateForm(TRestartCustomEditorForm, RestartCustomEditorForm); |
| 112 |
Application.Run; |
| 113 |
end. |