Spike Engine is a custom C++ based game engine created to deepen my understanding of game engine architecture and other modern C++ techniques. In the engines current state as of (30/10/2026), the engine contains the following features:
Custom maths library
Memory management using stack, linear, pool and dynamic pool allocators
Custom debugging methods to a log file and console
Custom asset importer for textures, meshes and shaders
Asset file parser, providing helper functions for file access and validation
External header only custom libs, providing various smaller utilities such as:
uuid generation for assets (using stduuid)
custom error types with context
a timer function with optional precision
custom vector whereby resize does not default initialise memory (niche use-case)
flagset type
An Asset Manager, importing assets and generating corresponding "sasset" files holding any relevant data
An ECS system, whereby objects and components may be retrieved by ID and are mapped onto one another using their IDs
Basic Engine loop using sub systems with pre/post, fixed and standard update methods
Basic rendering loop making use of renderer components and their relevant assets
Basic Editor UI using ImGui
In the engines current state, the engine contains the following features:
Custom maths library (developed to improve my understanding of a wider range of game maths aside from the basic vector maths)
Memory management using stack, linear, pool and dynamic pool allocators
Custom debugging methods, allowing debug logs to be sent to file and/or logged to a console queue while logging the source file and line
Custom asset importer, allowing most image files, obj, gltf, glb and fbx meshes and glsl shaders (specific formatting required) to be imported from file using a single import method
Asset file parser, providing helper functions for file access and validation
External header only custom libs, providing various smaller utilities such as:
uuid generation for assets (using stduuid)
custom error types with context
a timer function with optional precision
custom vector whereby resize does not default initialise memory (niche use-case)
flagset type, acting as a wrapper against a user specified integer type for setting / getting specific bits / chunks, allowing multiple flags that fit within 4 bits to share a single uint8_t without needing to modify the value sizes of the second flag (e.g. Get(0) or Get(1) to retrieve either the first 4 or second 4 bits of a <uint8_t, 2> flagset)
An Asset Manager, allowing for the use of the importer to import assets and generate a corresponding "sasset" file holding any relevant data, allowing assets to be requested and loaded/unloaded at runtime via an asset catalogue and a handle system. The Asset Manager handles the creation and deletion of all assets within the engine
An ECS system, whereby objects and components may be retrieved by ID and are mapped onto one another using their IDs. Equally, the ECS manager handles the creation and deletion of all objects within the engine
Basic Engine loop using sub systems with pre/post, fixed and standard update methods
Basic rendering loop making use of renderer components, whereby renderers are parsed for mesh asset handles and material assets handles, which are then parsed for required textures from held handles. Defaults exist for all stage
Basic Editor UI using ImGui, providing viewing access for the game scene, scene hierarchy, object inspector and debug console, alongside a console input window and statistics display, showing frame-rate, memory usage and engine object count
The engine is currently in the process of architectural changes, with the ECS system also being swapped for a handle based system over IDs, reducing the memory footprint and optimising object access times through using vectors with direct access from handle index values instead of the current 128 bit ID keyed hash map.
Equally, I am currently in the process of reducing the amount of inheritance and polymorphism within the engine which is currently causing wasted memory. This should reduce the sizes of the components classes, providing greater cache line efficiency during iteration.
On-top of this, the pool system may be modified to enable chunk shifting, whereby on object deletion, proceeding objects will be shifted back to fill the empty space, reducing cache misses / redundant space. This will pair nicely with the shift to the handle system within the ECS as the only pointer to the asset will be within the ObjectSlot pointed to by the handle, meaning only the slot must be updated.
Spike Engine is a custom C++ based game engine created to deepen my understanding of game engine architecture and other modern C++ techniques. This project is my second exploration into game engine architecture and will be my first experience working on some of the more specialised disciplines in this manner including Audio, generic Animation support, Asset management & File systems, Vulkan and advanced OpenGL rendering.
Compared to the methodology on LBX, Spike will not make use of many architectural and management techniques used within LBX. Namely, all aspects of the engine, including the more generic custom libraries, core engine modules, runtime project and editor project, will be contained within a single solution, separated by project and filters.
Equally, Spike will make use of a C# programming front-end backed by optional C++ dlls for performance critical systems, providing rapid iteration and easy tooling for designers/scripters, and raw performance for heavy maths/update loops.
As a preface to this section I must note, all custom libraries are developed within separate C++ projects, meaning they can be used within unrelated C++ projects too. Equally, most includes are contained within the using cpp files, with split implementation to ensure both clean headers with appropriate type / method summaries, alongside reduced build times on implementation changes.
This focus on reducing includes was used throughout the engine too, as this would equally reduce the maintenance on projects, whereby external includes only used within cpp files do not need to be included within the project settings of other projects, enabling easier integration with other libraries / systems.
See THIRD PARTY NOTICES for all required licenses and attributions to all third party libraries used within the Spike Engine. Notices for Spike Libraries external dependencies can be found on its GitHub page, however, as these are transitively included, their notices are also included within the notices for the engine.
Upon the start of engine development, I knew I would need a maths library as the back bone of the engine. There are many options out there with the obvious solution being glm as the first rendering API Spike will use is OpenGL. However, the glm syntax did not appeal to me with the amount of free functions compared to member function, those feeling more natural to me having used other game engines such as Unity. Equally, Spike is primarily being developed as a learning experience, thus I deemed it a good idea to develop my own to get hands on experience with the inner workings of some common methods and data-types such as quaternions and matrices.
Following this, I understood I would need some form of custom memory management, primarily for entities and components but also applicable to assets. As a result, I implemented the three primary allocator types, including a linear, stack and pool allocators. Equally, to allow for dynamic memory growth, I implemented a dynamic memory pool system, whereby the dynamic pool class holds a list of pools that are instantiated as all available pools are filled.
During regular versions of memory management systems, each allocator allocates and manages its own memory chunk that has been malloced for linear and stack allocators or simple arrays for pools. I wished to avoid this memory overhead so a memory manager was implemented. The memory manager mallocs a large portion of memory on engine initialisation which memory users can request chunks from. The manager uses a stack allocator to dish out memory and the requested memory chunk can be used by the memory user however they need.
Within the memory pool class, a union has been used to optimise for space. During early versions of the pool, I had a separate free list to store free chunks which was then modified so each chunk had a header pointing to the next free chunk, allowing me to request _free instead of the back of the free list. However, both of these have an impact on memory usage. Using the memory meant for objects to store this pointer while the chunk is free via a union solves this issue.
Within the dynamic memory pool class, it inherits from the memory user. Upon filling all available pools, it requests a new memory chunk of the appropriate size to house another pool. This method reduces the memory management overhead on requesting a large memory chunk, placing the impact at the start of the program when the primary memory chunk is requested.
Many engines contain some form of debug logger system, allowing users to write logs within their code to allow information to be output to the console or a log file during a play-test. This console / log is equally used to report errors or potential hazards to the user, whether that be from within user generated code for a game, editor plugins or engine code itself.
To implement this, I created a debugger class that made use of variadic templates, string views and source location to provide similar syntax to Unity's debug system, requiring for the user to use the "::" syntax instead of "." syntax (e.g. Debug::Log("text {}", parameter); )
In order to ensure the source location for a log call was automatically captured instead of explicitly stated by the user, I used structs within the debug class using variadic templated arguments alongside a default value source location parameter. This in theory would work, however, because parameters cannot easily follow an unexpanded parameter pack unless they have default values, this would not work.
Instead, I could take advantage of User-Defined Deduction Guides, whereby the constructor takes a string view and variadic arguments, which then uses the trailing arrow syntax to point to the standard constructor, which does have a trailing default source location argument. This results in the file name, line number and function being captured at all log calls in code, where the log object is instantiated, without any explicit passing of source location or macro wrappers.
However, as each log call is an object instantiation and (once out of scope) deletion, the log storage is static to ensure the running log is not wiped.
By now, I had some solid foundational libraries in that would help engine development quite significantly. So then I began thinking of the asset pipeline for game engines. The asset pipeline is one of the most significant parts of an engine as that is how artists and designers access and import content into the engine to then subsequently modify or use within a project.
In keeping with my aim to split all focused functionality without engine requirements into separated libraries, I began working on a basic file parser for generic use. This parser provided methods to generate metadata for files, writing and reading this in, alongside methods for writing a catalogue file for book-keeping and fast lookup of assets within a project (and some read/write wrappers for data alignment and string parsing).
On-top of this compression and decompression methods were implemented, whereby users could use zstd or zlib compression to compress and decompress data to buffers, which is used extensively within the asset manager.
Finally, a YAML parser / node type were implemented, allowing for reading/writing YAML to file, which will subsequently be used for level and prefab representations. This system uses YamlCpp internally to safely parse and write to file.
Following on from this, I now had the capability to read / write metadata to files, but now I needed the assets to write to file.
I based my asset importer on assimp in terms of its public API and file handling, allowing assets of all types to be imported using one method and returned in one container capable of handling all types.
The first asset type tackled was textures, with these initially being loaded via stbimage. The asset files generated alongside the texture merely contained the class instances data and a string path to the source file. This method worked but required the presence of the source image and would require mipmap generation on loading in the image every time the asset is requested if it is not loaded already.
Equally, many game engines offer compression settings for textures based on use-case. This is critical when handling high quality textures or large amounts of textures at once. As a result, basis universal was used on-top of stbimage within the engine, however the asset importer still solely makes use of stbimage as I wanted all engine/editor specific stuff to be confined to the engine code with all external libraries remaining as generic as possible without resulting in unnecessary complexity.
Secondly, shader importing was introduced. This by far being the easiest due to the nature of shaders. Being text files, shader import merely requires the file to have a shader file extension, which if so, file data is read into a string buffer, with additional parsing to identify the stages within the shader.
As of (30/10/2026), only Mesh assets may be imported from obj, gltf/glb and fbx files, with gltf importing using JsonCpp and fbx importing using the fbx sdks. Meshes are split on import based on material index, whereby a primary vertex and index buffer are generated per mesh, with a submesh list holding, for each submesh, its index offset into the buffer, its index count and its material index. Using this data the mesh is updated with its material count.
The mesh importer also has optional flags to import tangents from meshes as-well, with missing tangents being generated on import. Bi-tangents are not imported, they will be generated on the shader instead using the w value from the tangent (handedness).
The engine core contains the primary systems within the engine that allow all subsystems to function, including base classes, the asset and ECS managers, and other engine specific shared functionality.
Firstly, the ECS system is contained within the Core. The ECS makes use of dynamic memory pools per entity and component type to provide better creation time and cache locality on iteration. All entities present within the engine can be accessed via their ID from a hash map, with ownership between objects being denoted by a hash map also indexed by IDs holding vectors of child IDs, with two separate maps for level hierarchy and component ownership.
As of (30/10/2026), the ECS system is actively being converted into a handle-slot based system in the same manner as the Asset manager, doing so will allow me to modify the memory pools to actively condense themselves on object deletion, removing wasted space between used chunks, reducing cache misses.
On-top of this, the primary architecture is being shifted to a data-oriented design with less polymorphism, further reducing wasted space within pools as a result of padding bytes present within the current implementations.
Secondly, the Asset manager is implemented within the Core. The Asset manager provides methods to request an asset by name or ID, alongside importing new assets or unloading assets via their handle. As stated, the Asset manager uses handles for asset access, with methods available to get the underlying asset itself from the handle. This was done to provide safety on hot reloading and asset unloading, preventing invalid pointer issues.
Within the importing method, the Asset manager makes use of the asset importer library above, which then parses the returned data into engine specific types, generating an associated asset file for them.
For meshes, this is simple, where the buffers and sub-mesh list are all compressed and written to file. Upon reading from file, the compressed data is read and then decompressed directly into GPU memory / buffers for OpenGL.
In the case of shaders, the present shader stages are looped over, using includes based on the shader stage to generate each stage correctly. Once this is done, the program is then generated. I may modify this in future so the shader is physically split into stages via different strings (e.g. a vector of stage type, string pairs) but for now this method works.
For textures, the loaded image data is then checked for its type (SDR or HDR) and is then checked for original channel count to select the appropriate GPU format.
When saving to file, basis universal was used, generating the basis file data (including image mipmaps) on texture import. It is worth noting, imported textures are forced to four channels to allow transcoding to any format without issue. As textures are saved in the basis format, they can be transcoded to any format at runtime.
It may be more memory efficient to save the textures within their asset files within the desired compression format, but upon changing this within the editor, the original texture would need to be re-imported and the asset file rewritten entirely, whereas runtime transcoding removes the need for the source file post import while retaining the option for compression to disk on build/export of the project.
As of (30/10/2026), the final asset type supported is materials. With material files merely holding the IDs of a parent material, shader and a list of its shader inputs, with these holding either the data itself if the input is a value or colour, or a texture assets ID of the input is a texture input.
The current rendering pipeline as of (30/10/2026) is rather simple, merely providing basic functionality to allow for testing other aspects of the engine.
Ideally, once the main engine architecture is modified, advanced rendering techniques will be implemented including batched rendering, frustum culling, lighting and post-processing effects.
During development of LBX, the editor and engine were separated by solutions with an intermediate sdk folder used to hold includes and lib files. This resulted in a tedious testing process when editing the core engine where the build process had to be automated and took a considerable amount of time. Equally, as these project were separated, debugging or stepping through code became an issue that required extensive logging to solve issues.
Using a single solution with multiple build configurations, a debug and release for both a runtime and editor exe, has improved the workflow significantly, allowing for easy code debugging even when running the editor and equally providing a far faster build time.