Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
This document covers basic information on using and compiling Game Source Code, software needed and so on

.

English
Excerpt
hiddentrue

This document covers basic information on using and compiling game source code and software needed.


Overview

The Game Code package supply the GameDLL C++ source code along with the required header files to access most of the CRYENGINE systems. It is stripped down for users who don't have access to the full Engine Code.

Starting with 3.6.3, users of the Game Code package now also get additional access to the CryAction and CryInput projects, including all the source files required to build CryAction.dll and CryInput.dll for Windows platforms. 

CRYENGINE licensees who obtained a full Engine Code License should only use the Engine Code package which already includes all the files supplied in the Game Code package.

The GameDLL provides developers a project where they can implement a game class based on the IGame interface. It's also possible to implement new Entity class and extensions to game systems (i.e. vehicle movements, firemode or AI characters).

Info

For the Steam release, the code will be provided inside a .zip file, placed in the root folder of your installation. The reason the files are placed in a .zip is so that any changes you make are not overwritten when steam updates your installation.
After an update, you can either merge the contents of the new .zip file into your existing code (using source control or other tools of your preference), or just replace your code with the new code if you have not made any changes.

Prerequisites

Required Software

Please refer to Visual Studio supported versionsSupported Versions_dup for information on which version of Visual Studio and Windows SDK are supported.

Pre-CRYENGINE 3.6.3

Expand
Info

Before 3.6.3: When using the Game Code package, you don't need to install any additional 3rd party SDKs, all the required SDKs for building the GameDLL are included in the source code package.

CRYENGINE 3.6.3 -> 3.6.15

Expand
Note

Starting with 3.6.3: In order to build the CryInput.dll, you need to obtain the DirectX SDK from Microsoft here (it's free). After installation, you must copy the contents of the installed SDK (the Include and Lib folders) into <CRYENGINE root>\Code\SDKs\DXSDK

Alternatively, before building the Game code solution, disable the CryInput project from building by unchecking the check-box in the solution Configuration Manager for all combinations of Configuration and Platform.

CRYENGINE 3.6.9 -> Current

Expand
Note

Starting with 3.6.9: In order to build the CryAudioImplWwise.dll, you need to obtain the Wwise SDK from Audiokinetic here. After installation, you must copy the folder <Wwise Installation root>\SDK\include\AK to <CRYENGINE root>\Code\SDKs\Audio\AK. Then create the <CRYENGINE root>\Code\SDKs\Audio\AK\lib folder and copy the contents of the following folders:

FromTo
<Wwise Installation root>\SDK\x64_vc110\Debug\lib  <CRYENGINE root>\Code\SDKs\Audio\AK\lib\x64\debug\vc110
<Wwise Installation root>\SDK\x64_vc110\Profile\lib<CRYENGINE root>\Code\SDKs\Audio\AK\lib\x64\profile\vc110
<Wwise Installation root>\SDK\x64_vc110\Release\lib<CRYENGINE root>\Code\SDKs\Audio\AK\lib\x64\release\vc110
<Wwise Installation root>\SDK\Win32_vc110\Debug\lib  <CRYENGINE root>\Code\SDKs\Audio\AK\lib\win32\debug\vc110
<Wwise Installation root>\SDK\Win32_vc110\Profile\lib<CRYENGINE root>\Code\SDKs\Audio\AK\lib\win32\profile\vc110
<Wwise Installation root>\SDK\Win32_vc110\Release\lib<CRYENGINE root>\Code\SDKs\Audio\AK\lib\win32\release\vc110

The final folder structure in <CRYENGINE root>\Code\SDKs\Audio\ should look like this:

Using STLport

STLport is an open source implementation of the Standard Template Library (STL) different from the default implementation shipping with Visual Studio.

Note

Usage of STLport is no longer recommended since the improvements in the Visual Studio shipped STLs.

The STLport source code is included in the CRYENGINE SDK. However, Visual Studio needs to be set up to make use of STLport instead of the default STL implementation using the following steps:

  • Go to Tools/Options in the main menu and select VC++ Directories under Projects and Solutions.
  • Select Platform Win32 and add the path <CRY_SDK_ROOT>\Code\SDKs\STLPORT\stlport at the top of the Include files and Library files list. It is essential that the STLport path is above the default Visual Studio include and lib paths in the list.
  • Repeat the previous step for the x64 and other platforms, as required.

Solution Files

Note

This information applies to CRYENGINE before 3.7.0
In CRYENGINE versions since 3.7.0, WAF is used as the build system.
Please read WAF Build System on information how to generate Visual Studio solution files. 

The following table describes the solution file supplied with the CryENGINE SDK.

Solution file

Description

Code\Solutions\CryEngine.sln

Solution delivered to full Engine Code licensees.

Code\Solutions\CryEngine_GameCodeOnly.sln

Solution delivered to other users.
Starting with 3.6.3: This solution also includes code for CryAction and CryInput 

The CryEngine.sln solution is only supplied with the full engine source code. The content of the CryEngine_GameCodeOnly.sln solution is included in CryEngine.sln.

The Game Code solution can always be compiled in either Debug or Profile configuration. Compiling the Release configuration requires the access to full engine source code.

Source files

Directory

Description

Code\CryEngine\CryCommon

Headers for all the interfaces of CRYENGINE.

Code\CryEngine\CryAction

Include headers for the Game Framework which include the implementation of Flowgraph, Vehicle, etc.
Starting with 3.6.3: Includes all source code for CryAction.dll, so users can build it from scratch.

Code\CryEngine\CryInput

Starting with 3.6.3: Includes all header and source files for CryInput on Windows.

Code\CryEngine\CrySoundSystem

Starting with 3.6.9: Includes all header and source files for building the CryAudioImplWwise module.

Code\GameSDK\GameDll

Source files for the reference game shipped with the SDK.

The header files from CryCommon and CryAction are required to recompile the GameDLL. More information on CryAudioImplWwise and writing your own Audio Implementations can be found here.

Where to start

Initialization

The code handling the initialization of a CRYENGINE game is contained inside Code\GameSDK\GameDll\GameStartup.cpp. The function CGameStartup::Reset() is handling the allocation and initialization of the IGame interface.

For adding any game specific initialization, it is recommended to look into CGame::Init(). This function is called once when the game is loaded. The function CGame::Shutdown() will be called when the game is being shutdown.

Frame Update

Any function that needs to be updated for every frame should be added to one of the two update functions.

Code Block
int CGame::Update(bool haveFocus, unsigned int updateFlags)
Code Block
void CGame::OnPostUpdate(float fDeltaTime)

Debugging

After making and building code changes in the GameDLL or in another project, you will probably want to be able to debug the new code (or any other code).
There are two ways to debug from a game code project

  • Edit the debugging settings of the CryGameSDK project.
    • Right-click the project in the solution explorer, and select properties
    • Under configuration properties category, go to Debugging
    • Update "Command" to point to GameSDK.exe (for launcher) or Editor.exe (for Sandbox) on your local computer. Pick the .exe from Bin64 if Platform is set to x64, or from Bin32 if Platform is set to Win32 (top right drop-down)
    • Update "Working Directory" to point to the root folder of your CRYENGINE installation. (This is the the folder containing the Bin32 and Bin64 folders)
    • Set the CryGameSDK project as start-up project. Right click the project in the solution explorer, and pick "Set as StartUp Project"
    • You can now debug the game code in either Sandbox or the launcher (depending on which you picked two steps up) by using Debug -> Start debugging (or press the default shortcut, F5)
  • Attach the debugger to an existing process.
    • Start either the launcher or the sandbox after building your code
    • In visual studio, go to Debug -> Attach to Process
    • Find either GameSDK.exe (for launcher) or Editor.exe (for Sandbox) in the list of processes. Then attach to it.
    • You can now debug the game code in the running process
Note

If you have obtained your installation of CRYENGINE using Steam, you can only use the second method for debugging game code in the Editor. You can still use the first method to debug code in the Launcher. 

Common Questions For Beginners

Q: I'm getting an error about "Unable to start program... /CryCommon" when building the GameCode solution, why?

A: Users without full Engine Code will only be able to build "CryGame", so make sure that's what you're building.

Q: I finished building CryGame but at the end it gave me an error about "Unable to start program... /CryGame.dll", why?

A: If you have set CryGame as your "Startup Project" then upon completion of the build, it will attempt to 'run' it, which can't happen.

 

Excerpt
hiddentrue
Chinese

游戏代码入门指南

游戏代码包提供 GameDLL C++ 源代码和所需的头文件以访问多数 CryENGINE 系统。为那些没有权限获得完整引擎源代码的用户去除了底层代码。获得完整引擎代码许可的 CryENGINE 授权用户应仅使用引擎代码包,该代码包已包括游戏代码包所提供的所有文件。

GameDLL 为开发者提供一个基于 IGame 界面可以实现游戏类的项目。也能够实现新实体类以及游戏系统的扩展。(例如载具移动、开火模式或 AI 角色)。

必备项

所需软件

使用不同版本的 Microsoft Visual C++ 可能会产生与 CryENGINE 不相兼容的 GameDLL。今年将引进能够给予 Visual C++ 2010 全方位支持的版本。

使用 STLport

STLport 是标准模板库 (STL) 的开放源码的实现。STL 更优于同 Visual Studio一起发布的默认STL库的实现。我们强烈推荐您在建立 CryENGINE 时使用 STLport。

CryENGINE SDK 包括 STLport 源代码。但是,需按照以下步骤对 Visual Studio 进行设置以利用 STLport 而不是利用默认的 STL 实现:

进入主菜单中的*工具/选项*并选中*项目和解决方案*之下的 *VC++ 目录
*选中 Win32 平台并添加 <CRY_SDK_ROOT>\Code\SDKs\STLPORT\stlport 路径,该路径在*包含文件*和*库文件*列表的顶部位置。在列表中的默认 Visual Studio 和 lib 路径之上的 STLport 路径很重要。
*重复先前的 x64 步骤和可选的(在有主机平台的情况下)Xbox 360 平台。

解决方案文件

以下表格描述与 CryENGINE SDK 一同提供的解决方案文件。

解决方案文件描述
Code\Solutions\CryEngine.sln提供解决方案给完整引擎代码的许可用户。
Code\Solutions\CryEngine_GameCodeOnly.sln提供解决方案给其他用户。

CryEngine.sln 解决方案仅与完整引擎源代码一同提供。CryEngine.sln 中包含 CryEngine_GameCodeOnly.sln 解决方案的内容。

可以在 Debug、配置文件和发布配置中编译 GameDLL 项目。

头文件

目录描述
Code\CryCommon所有 CryENGINE 界面的头文件
Code\CryAction包括游戏框架的头文件,其中也包括 Flowgraph 和载具的实现等等。

CryCommon 和 CryAction 的头文件需重新编译 GameDLL。

从何处开始

初始化

Code\Game\GameDll\GameStartup.cpp 中包括代码处理 CryENGINE 游戏的初始化。CGameStartup::Reset() 函数处理 IGame 界面的分配和初始化。

若要添加任意游戏的特定初始化。推荐您查阅 CGame::Init()。加载游戏时请调用该函数一次。关闭游戏时将调用 CGame::Shutdown() 函数。

帧更新

应添加每个帧所需要更新的任意函数至两个更新函数的其中一个。

Code Block
int CGame::Update(bool haveFocus, unsigned int updateFlags)
Code Block
void CGame::OnPostUpdate(float fDeltaTime)

初学者的常见问题

Q: 为什么我在编译GameCode解决方案的时候会出现一个报错 "Unable to start program... /CryCommon"?

A: 没有全部源代码的用户只能编译 "CryGame", 请确认你只编译了这个工程.

Q: 我完成了 CryGame 的编译, 但是在启动时又出现了另一个报错 "Unable to start program... /CryGame.dll", 这是为什么?

A: 如果你把 CryGame 设置成为了"启动项", 那么在编译结束后就会自动这个工程, 这显然是错误的.