W4 Engine architecture

From Ciliz|W4

Scope

The W4 Engine is a library of C ++ modules with framework elements. The Engine allows you to create projects in C ++ that will work in any modern browser.

The ease of installation and templates for creating projects makes it look like a framework, but first of all it is a library of solutions that you can use as you like.

Note. Most templates use the IGame class (it is responsible for the Main Game Loop and implicitly contains the rest of the modules) - this is convenient, but most modules can be used independently.

This article provides a brief description of the engine modules and subsystems. Let's start with a general architectural scheme:

Scope 01.png

The following groups of modules are presented:

Note. Since the W4 Engine is a library of mostly independent modules, this separation serves to understand the modules' scope and does not indicate any relationship between them.

  • Core. Some modules are not related to the render and the game itself. Any of them can be used independently.
  • HAL. Interaction with the platform. In general, the platform is the browser, but there are features for different devices and OS.
  • Render. Modules that are responsible for rendering.
  • Game. An interface designed to make the main game loop easier to implement.
  • Resource. Resource management. In W4 Engine anything that can be loaded (i.e. data without logic) is a resource.

More details are described later in the article, and for complex modules, there are separate articles (pay attention to the hyperlinks in the text).

Core

The modules and subsystems of the Core group implement various common functionality of the W4 Engine. Next, let's consider each module separately.

Base

Implementation of basic solutions that are used inside the engine and are not very useful outside (although such use is possible). For example, the use of smart pointers (sPtr, ivPtr, cPtr) and the FATAL_ERROR module (emergency shutdown and reporting errors to the user.).

Logger

The W4 Logger module implements output (to the console, file, etc.) from within the engine. Various levels are implemented such as Debug, Info, Error and the like.

Note. Since browser performance is highly dependent on the amount of data transferred, it is best to use as few messages as possible. Therefore, when building the release version, only critical errors are displayed, the rest is turned off to improve performance.

Math

W4 Math is a set of standard solutions for various calculations (vector classes, rotator, color, etc.).

File system

The W4 Filesystem module is required because the standard C ++ file handling mechanisms cannot be used in a browser. The module implements a virtual file system that allows you to access files by path (URI). Both synchronous and asynchronous calls are used.

Note. Due to the specifics of web applications, the file system is read only.

FSM

This is a C ++ compile-time way of defining state machines. The FSM module is implemented as a separate interface that can be used from anywhere.

See also the W4 FSM How-To article.