Castle Game Engine icon

Castle Game Engine 5.2.0

FPS game screen
Fountain water
multiple_viewports: interactive scene, with shadows and mirror
castle_siege model from DeleD sample models, with shadows
Precomputed Radiance Transfer
Demo of three ScreenEffects defined in VRML/X3D, see screen_effects.x3dv
Close up shadows on the tree. Notice that leaves (modeled by alpha-test texture) also cast correct shadows.
Terrain 1
Water reflections by optimized GeneratedCubeMapTexture
Fog from 3D noise
Integrations on Android available in Castle Game Engine - in-app purchases, ads, google games and more

A free open-source 3D/2D game engine for modern ObjectPascal.

  • We support of lot of 3D and 2D formats (VRML / X3D, Collada, Wavefront OBJ, MD3, Spine...),
  • we're portable to a lot of platforms (Linux, Windows, Mac OS X, mobile: Android, iOS, web browser plugin...),
  • we provide optimized rendering with a lot of graphic effects,
  • and we have a great API for managing your game world.

Contents of this page:

1. Download and usage

Download "Castle Game Engine":

As tar.gz archive

As zip archive
(easier to unpack
on Windows)

If you like this software, please consider donating.

This download contains all the engine sources, including the sources for many example programs and engine tools.

Shortest possible usage instructions:

  • For Lazarus:

    1. Open and compile the package castle_base.lpk You will find it in the castle_game_engine/packages/ subdirectory.
    2. Then open and compile the package castle_window.lpk.
    3. Finally, open and install the package castle_components.lpk.

    Then just compile and run from Lazarus any example you want (in examples subdirectory), just open the xxx.lpi project file and compile/run as any other program.

  • For command-line FPC: First, try compiling the examples by simple "make examples". Or execute scripts to compile particular examples.

    If you don't want to use Lazarus to compile your own programs, you have a couple of options.

    1. First of all, we advice using our build tool to compile and package your games.
    2. Other option is to compile the engine units by executing make inside the castle_game_engine/ directory (uses FpMake). Then add the path with compiled units to your fpc.cfg file by adding a line like -Fu.../castle_game_engine/units/x86_64-linux (see FPC documentation "Configuration file" to know where you can find your fpc.cfg file).
    3. Final option is to use the castle-fpc.cfg and create scripts (see examples) to compile your programs like that.

Now jump into our tutorial and you will have a working game in 5 minutes! :)

Remember to install required libraries: programs developed using our engine (engine examples and normal programs) may use a couple of libraries. In short, you will most likely want to have LibPng, ZLib, GtkGLExt, OpenAL, FreeType, and VorbisFile.

  • On Linux and FreeBSD you should install these libraries using your favorite package manager. Remember to install -dev versions of these libraries too (if you're under Debian or similar distribution) to be able to compile programs that link to these libraries.
  • On Windows download DLLs from here (32-bit libraries zipped) or here (directory with 32-bit libraries) or here (directory with 64-bit libraries). Place all DLLs in program's exe directory (or put them somewhere on $PATH).

    Be sure to use the ones corresponding to your compiler — if you use FPC/Lazarus for 32-bits, then you make executable for 32-bits, and you should use DLLs for 32-bits. Even if you work on 64-bit Windows. If in doubt, just try the other ones:)

  • On Mac OS X: Mac OS X requirements are listed here.

2. Documentation

The engine uses a cross-platform Object Pascal language and tools (FPC, Lazarus). If you'd like to learn about the Object Pascal:

3. Other useful downloads

Our model viewer view3dscene allows to test your models before loading them to your games.

An important strength of our engine is that you can express a lot of stuff inside your data, that is inside VRML/X3D models. So many features of our engine (shaders, screen effects, mirrors and many many more) don't have any special ObjectPascal examples, because they are simply not needed. For simple uses, you just define what you need inside VRML/X3D file (of course, for advanced usage you can do a lot more with ObjectPascal code, and you can always build/modify VRML/X3D graph by ObjectPascal code). So be sure to grab our demo VRML/X3D models and try opening them with any engine example program (like scene_manager_basic.lpr, or even our view3dscene) — you will find that everything just works, not requiring a single line of ObjectPascal code.

4. FPC (Free Pascal Compiler) version required

You need the Free Pascal Compiler (FPC) to use our engine. We always support and advice the latest stable (from release of FPC (currently 2.6.4). Usually, we also support a couple of older FPC releases. Currently (for engine 5.1.0) FPC versions >= 2.6.2 are supported.

You may also find it comfortable to use Lazarus, which is an IDE (editor, debugger etc.) built around FPC with a visual classes library (LCL). Our engine components can be used together with Lazarus forms (although we also have an alternative window classes, independent from Lazarus LCL). Any Lazarus version based on FPC >= 2.6.2 is supported now.

5. Get the latest sources from GIT or SVN

You can get the latest (bleeding edge, work in progress!) engine sources from our GitHub project. For example run this:

git clone

Or you can get them from our SourceForge project SVN (auto-synchronized with GitHub GIT), like this:

svn checkout

6. License

The whole engine and all related programs' sources are licensed on terms of GNU General Public License. See for more information about this license (including translations of it to various languages) and philosophy of free software.

Moreover, the core of the engine is also alternatively available under the more permissive GNU Lesser General Public License with the so-called "static linking exception". The idea of this exception is to allow statically linking with the engine on the same terms as dynamically linking. (Static linking is what normally happens when you compile a program using my units, without wrapping them in a DLL / Delphi runtime package.)

All this basically means that you have to share your modifications to the engine, and you can use the engine in closed-source programs.

The precise legal text of the "static linking exception" follows (it's the same as used by FreePascal Runtime Library and many other projects):

As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.

Important notes:

  • If you want to use the engine on LGPL terms (as opposed to more strict GPL) you must compile the engine with CASTLE_ENGINE_LGPL symbol defined in file castle_game_engine/base/ Just put there {$define CASTLE_ENGINE_LGPL} line (or simply remove the beginning space in already prepared comment { $define CASTLE_ENGINE_LGPL}).

    This is necessary to avoid pulling in GPL-only dependencies. For now, this is only the NURBS unit (uses GPL-only code from White_dune). This missing NURBS implementation is the only difference between LGPL and "strict GPL" engine version.

  • Note that LGPL stuff concerns only the engine, i.e. things inside castle_game_engine archive. The rest of the programs (view3dscene, castle etc.) are still strict GPL.