| 1 | # Lazarus packages to use Castle Game Engine in Lazarus |
| 2 | |
| 3 | ## Instructions |
| 4 | |
| 5 | Register in Lazarus all packages using the button _"Register Lazarus Packages"_ in CGE editor _"Preferences -> FPC and Lazarus"_ (see https://castle-engine.io/install ). |
| 6 | |
| 7 | Then, optionally, you can install the `castle_components.lpk` package in Lazarus, to have LCL component `TCastleControl` (see https://castle-engine.io/control_on_form ). |
| 8 | |
| 9 | Please use this approach instead of manually compiling/installing .lpk files, and hunting for their dependencies :) |
| 10 | |
| 11 | ## Packages desciption |
| 12 | |
| 13 | ### castle_base.lpk |
| 14 | |
| 15 | Base engine code and components. |
| 16 | |
| 17 | This also includes [Vampyre Imaging Library](https://imaginglib.sourceforge.io/) (you do not have to install it by a separate package). |
| 18 | |
| 19 | ### castle_window.lpk |
| 20 | |
| 21 | `TCastleWindow` class and associated unit. |
| 22 | |
| 23 | Should never be installed in Lazarus, as the `CastleWindow` is talking directly to the window system, and would conflict with LCL trying to do the same. |
| 24 | |
| 25 | Depends on `castle_base.lpk`. |
| 26 | |
| 27 | Add this package as a _requirement_ to Lazarus applications that use `TCastleWindow`. |
| 28 | |
| 29 | ### castle_components.lpk |
| 30 | |
| 31 | Engine code and components using LCL. TODO: a better name of this package would be `castle_lcl.lpk`. |
| 32 | |
| 33 | Depends on |
| 34 | |
| 35 | - `castle_base.lpk`. |
| 36 | |
| 37 | - LCL. |
| 38 | |
| 39 | - standard Lazarus package `LazOpenGLContext`. |
| 40 | |
| 41 | Lazarus should automatically know its location, but if necessary you can find it and manually compile in `<lazarus>/components/opengl/lazopenglcontext.lpk`. |
| 42 | |
| 43 | Add this package as a _requirement_ to Lazarus applications that use `TCastleControl` (our LCL component). |
| 44 | |
| 45 | ### castle_editor_components.lpk |
| 46 | |
| 47 | Components used by CGE editor. Engine developers (who wish to modify CGE editor forms) should install this in Lazarus IDE. |
| 48 | |
| 49 | These components are also used by custom CGE editor builds (with project-specific components, if you use https://castle-engine.io/custom_components ). So "normal" engine users don't need to install this, but they should "register" it with Lazarus, so that you can rebuild Lazarus with custom components. |
| 50 | |
| 51 | All the units inside this package are internal for CGE -- normal engine users should not rely on this code at all, it is only internally used by CGE editor. |
| 52 | |
| 53 | Note: We avoid adding dependencies on packages elsewhere in CGE directories, like `tools/castle-editor/contrib/mbColorLib/mbcolorliblaz.lpk`. Because this would confuse some people, because seasoned Lazarus users routinely install lpk directly, scanning our "packages/" subdirectory, and not knowing about CGE button "Register Lazarus Packages" (even though it's documented early in manual). So let's keep it simple and store all .lpk here. |
| 54 | |
| 55 | Depends on `castle_components.lpk`. |
| 56 | |
| 57 | ### alternative_castle_window_based_on_lcl.lpk |
| 58 | |
| 59 | Alternative version of `castle_window.lpk` package that provides `CastleWindow` unit using Lazarus LCL as a backend. It's useful for platforms where we don't have a better CastleWindow backend. |
| 60 | |
| 61 | In practice, it has no use now. (In the past, it was useful for macOS.) |
| 62 | |
| 63 | ### castle_indy.lpk |
| 64 | |
| 65 | There is one, completely optional unit in CGE using Indy: `CastleClientServer`. This package allows to compile applications within it. |
| 66 | |
| 67 | Example usage of it is in `examples/network/tcp_connection/`. |
| 68 | |
| 69 | Depends on: |
| 70 | - castle_base |
| 71 | - indylaz |
| 72 | |
| 73 | TODO: To avoid confusion (as CGE in general doesn't depend on Indy) we should probably move it to separate repo. |
| 74 | |
| 75 | ## Do I need Lazarus to use Castle Game Engine? |
| 76 | |
| 77 | No. Packages here are provided to easily compile and use the engine with Lazarus. But CGE doesn't require LCL, you can develop CGE applications using `TCastleWindow` that doesn't depend on LCL. |
| 78 | |
| 79 | So all you actually need is bare FPC installation. Use our editor (https://castle-engine.io/manual_editor.php) or build tool (https://castle-engine.io/build_tool) to compile all examples and tools. |
| 80 | |
| 81 | ## Development notes: Conventions about these packages |
| 82 | |
| 83 | How to cope with system-specific units and include files inside |
| 84 | a single Lazarus package file? |
| 85 | |
| 86 | (This concerns stuff inside */unix/, */windows/ subdirectories, |
| 87 | like base/unix|windows, opengl/unix|windows). |
| 88 | |
| 89 | - Add all files, .inc and .pas, even the system-specific, to the package |
| 90 | (this way e.g. dependency checking for .compiled files will be Ok). |
| 91 | This also means that we have to add all paths, |
| 92 | both for unix/ and windows/, to the package. |
| 93 | |
| 94 | - All include/units files must have unique names. |
| 95 | |
| 96 | I used to have a hack like this: place file unix/xxx.inc |
| 97 | and windows/xxx.inc, and then using {$I xxx.inc} |
| 98 | I knew that the correct (for current platform) xxx.inc would be included. |
| 99 | This is not possible anymore --- both unix/ and windows/ will be |
| 100 | on the include path for all of the platforms, |
| 101 | so you cannot depend on include path to select the proper file. |
| 102 | |
| 103 | Not a real problem, I used this hack only in one place actually... |
| 104 | |
| 105 | - For units in platform-specific dirs, set "Add to Uses Clause" to false |
| 106 | checkbox (at the unit configuration inside the package window). |
| 107 | Otherwise compiling package on other platforms would fail. |