Installing Delphi Packages

1. Introduction

Installing Castle Game Engine packages in Delphi allows to:

  • Use TCastleControl component, that you can drop on a VCL or FMX form.

  • Have "Tools → Castle Game Engine" menu available, with useful commands like "Set Engine Path…​" and "Configure Delphi to Use Engine". These commands are used to set up the Delphi IDE to use CGE units and tools.

  • Necessary DLLs will be automatically deployed alongside your EXE file, if you build a project with CastleEngineManifest.xml from Delphi IDE. These DLLs follow the declared <dependencies> of your project along with some auto-detected dependencies (e.g. we automatically deploy OpenAL DLLs if your project includes sound files in data).

TCastleControl on Delphi FMX form Castle Game Engine menu in Delphi IDE

2. Installation in Delphi

  1. Open in Delphi packages/delphi/AllPackages.groupproj.

  2. Right-click on all packages (except castle_engine_window.bpl) in succession and click "Install".

    Note
    The platform of all our packages is set by default to "Windows 32-bit" and this is good, this is what you want to use for installation, since Delphi IDE is a Win32 application. The packages installed this way make CGE components available for all supported target platforms (including Win32, Win64, and Linux64).
  3. Use the new menu item "Tools → Castle Game Engine → Set Engine Path…​" to tell Delphi where is the CGE root directory. It should contain subdirectories like src, examples. Don’t worry, we validate what you select, we will not let you select an invalid directory.

  4. Use the menu item "Tools → Castle Game Engine → Configure Delphi to Use Engine".

    Restart Delphi IDE, as adviced by the message that will appear.

    Note
    Restart is really necessary, as changing "Library Path" in Delphi has to be done using the registry and Delphi will load new values only on restart.

    This simply modifies the global "Library Path" for all your Delphi platforms. You can visit "Tools → Options → Language → Delphi → Library → Library Path" (after restarting Delphi!) to see what it did. This way CGE source code is available to all your projects, and CGE units will be compiled and linked with your projects that use any CastleXxx units.

3. Alternative: Configure Only Current Project

If you want, instead of "Configure Delphi to Use Engine", you can also configure a particular project using menu item "Configure Only Current Project (for Current Platform and Debug/Release Config) to Use Engine".

The latter option, "Configure Only Current Project (for Current Platform and Debug/Release Config) to Use Engine", doesn’t touch the global Delphi settings, it only modifies the current project. It also doesn’t need Delphi restart. It is less recommended because:

  1. You will have to repeat this operation for every project, every platform, every config (debug/release).

  2. The resulting DPROJ will contain absolute paths to CGE sources, so it will not work for other developers if you share your project e.g. using a version control.

But the option remains. Good if you just want to try CGE locally.

Note
There’s no point activating both global ("Configure Delphi to Use Engine") and project ("Configure Only Current Project (for Current Platform and Debug/Release Config) to Use Engine") settings. Only one of them is necessary, and any one of them is enough.

4. More information (for CGE developers)

More information about how and why CGE packages for Delphi are designed is in the Delphi packages README file in sources.

If you are interested in developing Delphi IDE extensions, you may find it useful to take a look at our test project https://github.com/michaliskambi/delphi-test-package-design-features . This is small, independent of CGE, piece of Pascal code demonstrating how to extend Delphi IDE — adding new menu items, changing project and global options. We used it as a "test bed" to develop the CGE integration, and it may be useful for you too.


To improve this documentation just edit this page and create a pull request to cge-www repository.