We are proud to announce that Castle Game Engine supports now the Linux platform with the Delphi compiler! You can now deploy your Delphi games to Windows and Linux with the same code-base.
This blog post describes various details, but really the recap is short: it just works and we have extensive documentation about Delphi + Linux specific things. Go ahead, download the latest CGE and try it out ๐
Details about what happened:
- Well, 410 commits happened ๐ And I initially thought this (making CGE work with Delphi/Linux) will take me a few hours to do. Then I thought it will take me a few days. It ended up taking me almost 4 months (although I was doing many other CGE tasks in parallel to this). Let this be a lesson of humility for all devs who dare make optimistic estimates!
-
Both
TCastleWindow
andTCastleControl
applications work perfectly with Delphi for Linux. -
All
TCastleWindow
examples work on Delphi/Linux. Explore the examples in CGE examples/ subdirectory and build and run on Linux with Delphi.All
TCastleControl
examples using FMX (FireMonkey) work on Delphi/Linux. This includes examples/delphi/fmx/, examples/delphi/fmx_play_animation/.examples/delphi/fmx_play_animation/ is actually a new example. Cross-platform 3D model viewer and animation player using Castle Game Engine components (
TCastleControl
,TCastleScene
) and FireMonkey. -
The page about TCastleControl in FMX applications stays up-to-date and relevant for Delphi/Linux.
-
Downloads (web requests) using
TCastleDownload
work too on Delphi/Linux. You can test them by-
examples/network/asynchronous_download : does sample downloads asynchronously, so CGE events are processed, animations play, can be interrupted
-
examples/network/remote_logging : does sample POST requests.
-
examples/network/castle_download : command-line downloader, like a simple
wget
orcurl
.
Our code using
TNetHttpClient
on Delphi was much improved. It supports now various HTTP methods (including POST with POST form data). The code for aborting downloads in progress was also improved to behave cleanly and not cause crashes.It also got some Linux-specific fixes to work around Delphi issues. In particular, we handle redirects manually on that platform, as we cannot rely on
TNetHttpClient.HandleRedirects
on Linux.All in all, it was quite non-trivial to make it always work, but now it does ๐ It can be interrupted, it can send GET and POST and others, it can redirect, it can download files of unknown size, it can download URL like http://castle-engine.io/latest.zip.
-
-
Under the hood, the
TCastleWindow
andTCastleControl
for Delphi on non-Windows are actually shared more than in FPC: they both rely on a commonTFmxOpenGLUtility
class responsible for some platform-specific work, in particular to initialize OpenGL context inside an FMX window.Moreover, under the hood,
TCastleWindow
relies on CASTLE_WINDOW_FORM which is a new name for a generalized oldCASTLE_WINDOW_LCL
. It makesTCastleWindow
actually use FMX and the above-mentionedTFmxOpenGLUtility
. -
This makes our code much more cross-platform in case of Delphi. Doing Delphi/Android or Delphi/iOS after this should be a breeze. But Iโm not going to do any estimates, in light of the first point on this list ๐
-
All 407 automatic tests, exercising some edge-cases (also with window sizes and multiple contexts) pass on Delphi/Linux. You can run them yourself, just compile and run the project in tests/ just like any other CGE project.
-
Underneath, the code to initialize contexts got some upgrades. The glX and EGL context management has been refactored to separate units and extending them is easier.
EGL initialization has been separated from OpenGLES.
Finally, we can use EGL (on any platform) to initialize both OpenGL and OpenGLES. Our Delphi/Linux port relies on it: both
TCastleWindow
andTCastleControl
underneath use- a window created by FMXLinux,
- with a GTK3 widget,
- with OpenGL(ES) context initialized using EGL.
-
Our file filters are easier exposed for Delphi:
TFileFilterList
has now methodsTFileFilterList.LclFmxFilters
,TFileFilterList.LclFmxFiltersFromString
(suitable for both LCL and FMX) and we haveCastleFmxUtils
unit with utilities to place CGE filtes in FMX open/save dialogs. -
Our package checking application was much extended and it now checks also Delphi packages for correctness.
This makes it easier to design good packages for Delphi โ that include 100% of units, and that are disjoint where they should.
This also means we can change the files included in packages with confidence. Both DPK and DPROJ of packages are checked, and we make sure they include all files they should (scanning actual CGE files), with proper relative paths, and nothing more.
If youโre interested in code, see our check_packages utility code. While itโs an internal CGE tool, it is possible it could be useful for other projects as well. The tool can be compiled with both FPC and Delphi (and regardless of the compiler, it can check both Lazarus and Delphi packages). See the README for instructions how to adjust it for your own purposes.
-
Simple shell tests (mostly some
grep
calls) in cge_shell_tests also check now that Delphi packages are correct, in particular that VCL or FMX dependencies donโt happen in packages where they shouldnโt.
Note: Embarcadero had a server outage recently. Everything should be back online for users with Delphi 12 or Delphi 11.3. See Embarcadero blog, GetIt Update for Delphi 12, GetIt Update for Delphi 11.3. If you experience problems using GetIt to get FMXLinux, please consult the above articles.