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

An open-source 3D/2D game engine for 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, Android, iOS...),
  • 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: install the package castle_game_engine/packages/castle_components.lpk. It will also automatically install the package castle_base, as a dependency. Then, open and compile (but do not install) the package castle_game_engine/packages/castle_window.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: Compile the engine with simple "make" inside the castle_game_engine/ directory (uses FpMake). Compile examples by simple "make examples". Or execute xxx_compile.sh scripts to compile particular examples.

    To develop your own programs, you can either add the engine unit output path to your fpc.cfg file, or you can compile your own projects using our build tool.

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, and vorbisfile.

2. Documentation

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 freepascal.org) 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. Bleeding edge (SVN) sources

Instead of downloading the archive, you can also get the latest (bleeding-edge) engine sources from Subversion by:

svn checkout http://svn.code.sf.net/p/castle-engine/code/trunk/castle_game_engine

6. License

The whole engine and all related programs' sources are licensed on terms of GNU General Public License. See www.gnu.org 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/castleconf.inc. 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.