Skip to content

code structure

Tim Leonard edited this page Sep 15, 2023 · 1 revision

Code Structure

The source code is currently split into multiple projects, which are arranged into 4 puedo-tiers. The tiers are visible in the visual studio solution explorer or the cmake files.

The purpose of tiers is to provide clear seperation of the different "layers" of the engine, and to control dependencies.

Projects in a tier can depend on other projects in the same tier or in tiers lower than them, but they can never depend on projects above them.

  • tier 0 : Contains core / utility code. eg. Logging, IO, math, etc.
  • tier 1 : Contains hardware interface code. eg. Render interface, audio interface, asset management, etc.
  • tier 2 : Contains core engine code and gameplay frameworks. eg. The main engine class, the frame loop, scene management, etc.
  • tier 3 : Contains game-specific code goes. The code for all this is held in the games directory rather than the engine directory.

Third party libraries do not have any of this control and can be used by any tier.

Project Naming

All non-third-party projects are named using the same puedo-namespace format:

workshop.name

For projects that contain multiple implementations a third section is added:

workshop.name.implementation

Examples:

workshop.core
workshop.core.win32

workshop.renderer
workshop.renderer.dx12
workshop.renderer.vulkan

workshop.engine

workshop.windowing
workshop.windowing.sdl

Interface Projects

Several projects act as interface projects that only contain headers files. These are common where there are multiple possible implementations available. For example with platform specific code, different apis, etc.

The implementation projects are then compiled/linked as appropriate in cmake. This avoids a lot of messy preprocessor includes that usually happens when trying to make code implementation agnostic.

It also provides a hard seperation between the code consuming the API and the implementation. Any implementation projects should be considered private and other projects should not include any of their code directly.

Folder Layout

The folder layout is flat, there are no sub-directory nesting. The aim of which is to make it much easier to have a completion picture of the projects within the game within have to delve through many nested folders.

All engine projects are stored in sub-directories within engine\source\.

All third party projects are stored in sub-directories within engine\source\thirdparty\.

All game projects are stored in sub-directories within games\