Introduction to the Engine API

Overview

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.

Common Headers

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>

Plugin Interfaces

Unlike the engine itself, plugins typically store their inside an Interface folder within their folder inside the Code/CryPlugins structure.

Accessing Engine System Interfaces

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 memberSystemDescription
p3DEngineI3DEngine3D engine implementation, allowing control of the 3D scene.
pCryPakICryPakFile system implementation, wraps calls such as 'fopen' and 'fclose' for cross-platform and archive (.pak) support.
pEntitySystemIEntitySystemEntity system implementation, allows for spawning and querying logical entities at run time.
pConsoleIConsoleConsole implementation, exposes console variable and command support.
pAudioSystemIAudioSystemAudio system, exposing functionality for playing sounds on various audio middleware.
pSystemISystemThe system is responsible for starting the engine and its sub-systems, and starting each frame.
pRendererIRendererThe renderer is a low-level wrapper of the graphics API level, exposing rendering to all engine users.

Logging

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.

Source Code Folder Structure

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 NameDescription
CryEngineSource code for the core engine modules such as CrySystem, Cry3DEngine and CryRenderer.
CryManagedSource code for the Mono (.NET/C#) integration.
CryPluginsContains any of the default engine plugins, and plugin examples.
GameSDK and GameZeroLegacy Game DLL samples – considered deprecated by game plugins and the game templates and will be removed in the future.
GameTemplatesSource code for the example game and plugin templates.
LauncherSource code for executables that can run the engine on various platforms.
LibsHelpers and source for building certain SDKs.
SandboxSource for the official engine editor.
SDKsHeaders and source for third-party SDKs.
ToolsSource code for engine tools and externals.

Common Types, Helpers, and the Math Library

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>

Conclusion

This concludes the introduction to the Engine API, you may be interested in: