//Window App
- Appdevelopment for Windows (C++)
- Game Engine Architecture, Strings, Memory Allocator, Logging, Unit Tests
- 1 Teammember
- Timespan: 01/2023 - today
Summary
Inspired by Jason Gregory's Game Engine Architecture, I have been working for some
time on an application in which I can test my theoretical knowledge and try out my new ideas.
In this sandbox I'm developing an application that will contain many components of a game engine.
This way I want to gradually learn more and more about game development and acquire new skills.
I became familiar with the Windows API through this application and learned quite a bit about the
architecture of Windows applications as well as game engines. I would like to discuss some of the
components here.
Basic architecture
My goal is to have the application open a window that can display text as well as 2D/3D graphics and UI.
In such a case, the WinMain entry point is a good choice. However, since I don't want
to output debug information only to the Visual Studio console, I decided to use a console application.
This then opens a window in a controlled manner and initializes the Message Pump.
Debugging && Logging
To develop my application correctly I need a good logging system. For this I implemented a structure that can
output strings to the console. The debugging system is based on this logging system, which outputs the time
and an optional topic tag in addition to the log message by default.
For errors and assertions there is also a separate system. With it error messages and warnings can be issued,
which output additionally also the file location as well as the line of the error. Assertions also classically
terminate the program here, with the console conveniently remaining open so that valuable information about
the assertion remains visible.
Strings
Since strings are known to be performance-critical, I wrote my own string class to make strings more efficient.
Following Jason Gregory's suggestion from Game Engine Architecture, the class contains a
global string table. Within the table, strings are mapped as hash and as char*. This makes
string assignments, comparisons, and the creation of new strings with text already stored much more performant.
For hashing a 64bit fast CRC hash algorithm is used.
Later the string class could for example serialize the used strings at compiletime and could then in the best
case be operated exclusively by means of the hash values.
The string classes source code is available here.
Unit tests
Already at the beginning of the development I put great emphasis on unit tests. That unit tests are a valuable habit
I learned in my studies (Game Engine Programming, Systems Engineering and Management, ...) as well as in this project.
Similar to how assertions consistently uncover false assumptions or erroneous data, unit tests effectively showed me
where errors crept in. Implementing tests, while time consuming, has (almost) always paid off. The tests are activated
and executed using the -test command line argument. Future customizations of my tests should extend
the routine to include function tests and randomized tests.
Memory allocation
For the application I implemented two custom memory allocators. A stack allocator and a pool allocator.
The stack allocator is implemented with a simple pointer to the top memory address of the stack.
Markers can also be set arbitrarily to free the memory. The pool allocator creates a number of memory blocks
whose size and number are specified when the allocator is initialized. In the future, both allocators will still
be equipped with an automatic alignment function so that reading and writing is as efficient as possible.
Both allocators are integrated into the unit tests in order to detect misbehavior at an early stage.
The stack allocator's source code is available here.
The pool allocator's source code is available here.
...
For the future many more structures, classes and subsystems are planned, which are to be included in the application.
I will add these here when the occasion arises. Topics that I am interested in and that will be published on this
page are multithreading (especially a job system),
D3D11/12 and or Vulkan rendering, an entity component system and many more.