This guide aids developers in understanding how the CRYENGINE C++ API works on its most fundamental levels, introducing users to game development using the engine.
The engine stores its public API inisde the Code/CryEngine/CryCommon folder, with the build system having been set up to automatically allow for includes with the CryCommon folder as root.
This means that we can include any file contained inside as follows:
#include <CrySystem/ICryPlugin.h>
Unlike the engine itself, plugins typically store their inside an Interface folder within their folder inside the Code/CryPlugins structure.
The engine exposes 'gEnv', a pointer referencing the global environment. (a structure containing a reference to all the systems) For example, we can use this to access the ISystem implementation:
ISystem* pSystem = gEnv->pSystem;
This is used all across the engine and plugins to continuously interact with the various engine modules. See the table below for information on the most common systems you can access:
Global environment member | System | Description |
---|---|---|
p3DEngine | I3DEngine | 3D engine implementation, allowing control of the 3D scene. |
pCryPak | ICryPak | File system implementation, wraps calls such as 'fopen' and 'fclose' for cross-platform and archive (.pak) support. |
pEntitySystem | IEntitySystem | Entity system implementation, allows for spawning and querying logical entities at run time. |
pConsole | IConsole | Console implementation, exposes console variable and command support. |
pAudioSystem | IAudioSystem | Audio system, exposing functionality for playing sounds on various audio middleware. |
pSystem | ISystem | The system is responsible for starting the engine and its sub-systems, and starting each frame. |
pRenderer | IRenderer | The renderer is a low-level wrapper of the graphics API level, exposing rendering to all engine users. |
The engine exposes the ILog interface to expose logging to both file and console (made visible by pressing ` / the tilde key). For more information, see Logging.
The engine’s source code file structure has remained largely unchanged over the years, remaining a simple setup where a Code directory is present in the root engine directory, containing the entire source code. See the table below for descriptions of the contents:
Directory Name | Description |
---|---|
CryEngine | Source code for the core engine modules such as CrySystem, Cry3DEngine and CryRenderer. |
CryManaged | Source code for the Mono (.NET/C#) integration. |
CryPlugins | Contains any of the default engine plugins, and plugin examples. |
GameSDK and GameZero | Legacy Game DLL samples – considered deprecated by game plugins and the game templates and will be removed in the future. |
GameTemplates | Source code for the example game and plugin templates. |
Launcher | Source code for executables that can run the engine on various platforms. |
Libs | Helpers and source for building certain SDKs. |
Sandbox | Source for the official engine editor. |
SDKs | Headers and source for third-party SDKs. |
Tools | Source code for engine tools and externals. |
As is common with most larger projects, CRYENGINE provides a few custom types that are very useful for development – making things easier and perhaps more performant. This chapter is dedicated to cover the most important of these types.
Keep in mind that a big focus of CRYENGINE V development has been to simplify source code, in some cases this has meant the removal of some custom types – often because C++/11 has made them obsolete.
Contained inside the Code/CryEngine/CryCommon directory are all the headers used for the engine modules and plugins. This directory is automatically included through the CMake build system and as an example we can include the Code/CryEngine/CryCommon/CryMath/Cry_Quat.h file as follows:
#include <CryMath/Cry_Quat.h>
This concludes the introduction to the Engine API, you may be interested in: