Personal Game Engine

Sven van Huessen | Nov 1, 2024

⏳ Duration: 8 weeks

🛠️ Engine/Tools: Custom Engine - C++

🖥 Platform: PC & PlayStation 5


Personal Game Engine

Overview

During block A of Year 2 I developed a custom game engine in C++ featuring a modern ECS architecture, cross-platform support, and cool editor tools. This project shows game engine concepts including resource management, serialization systems, and performance optimization techniques.

Core Technologies: C++17, EnTT, ECS, ImGui, Cereal Serialization

Note* as a starting point, I used a basic renderer provided by the teachers, which I heavily modified and expanded upon.


Technical Architecture

Entity Component System (ECS)

  • Implemented data-oriented design using EnTT library
  • Runtime reflection system for component registration from game projects
  • Component serialization supporting save/load functionality for scenes and prefabs
// Dynamic component registration with reflection
template <typename ComponentType, auto DrawFunction>
static void RegisterComponent(std::string name, bool removable, bool serializable) {
    entt::meta<ComponentType>()
        .type(entt::type_hash<ComponentType>::value())
        .prop("removable"_hs, removable)
        .prop("name"_hs, name)
        .func<DrawFunction>("draw"_hs);
}

Cross-Platform Abstraction

  • Polymorphic abstraction layer for platform-specific systems
  • Unified interface for Input, FileIO, Audio, and Device management
  • Implemented for both Windows and PlayStation 5
class Device {
public:
    virtual bool ShouldClose() = 0;
    virtual void BeginFrame() = 0;
    virtual void EndFrame() = 0;
    static Device* Create(); // Platform-specific factory
};

Resource Management System

  • Reference-counted resource loading with automatic cleanup
  • Support for multiple resource types (Meshes, Textures, GLTF models)

Every asset is being tracked and has a reference count, if unused it can be unloaded

Resource Manager Interface


Editor Tools

Visual Editor Interface

  • Full-featured scene editor built with ImGui
  • Real-time scene hierarchy with drag-and-drop functionality
  • Multi-viewport support with different camera perspectives
  • Property inspector with runtime component editing

Multiviewports for different render perspectives, UVs, wireframes, normals

Camera perspectives

Advanced Editing Features

Undo/Redo System

  • Command pattern implementation supporting complex operations
  • Handles entity creation, deletion, transformation, and property changes
  • Command combination system for multi-entity operations
class Command {
public:
    virtual void Execute() = 0;
    virtual void Undo() = 0;
};

// Template command for any data type
template <typename T>
class TypeCommand : public Command {
    T& m_target;
    T m_previousValue, m_newValue;
public:
    void Execute() override { m_target = m_newValue; }
    void Undo() override { m_target = m_previousValue; }
};

Note*

I wrote a better Undo/Redo system in the Kudzu Engine. Read more about it here.

Level Editor

  • Grid-based tile placement system
  • Asset browser with thumbnail generation
  • Save/load functionality for complete levels

Grid-based tile system showcase


Performance Optimization

Rendering Optimizations

  • Model Matrix Caching: Reduced complexity from O(N*C) to O(N) for hierarchical transforms
  • Instanced Rendering: Achieved 400-600 FPS in particle-heavy scenarios (up from 30 FPS)

Memory Management

  • RAII principles with smart pointer usage throughout
  • Memory alignment optimization for component structures
  • Resource pooling and automatic cleanup systems

Before and after memory alignment optimization


Core Engine Features

Particle System

  • GPU-accelerated particle rendering with instancing
  • Configurable emitters with cone-based velocity generation
  • Real-time parameter adjustment through editor interface
  • Billboard rendering and gradient color support
Particle Move Rotate
Confetti Particle
Spark Particle
Smoke Particle

Asset Pipeline

  • GLTF model loading with complete scene hierarchy support
  • Automatic texture and mesh extraction

Simple GLTF Scene Hierarchy

GLTF Scene Hierarchy

Serialization Framework

  • JSON-based scene serialization using Cereal library
  • User defined serialization for custom components
  • Prefab system for reusable entity templates

Creating, saving, and loading a prefab

Prefab System

Note*

When I wrote this blog post, I called this prefabs, in reality these are not actual prefabs, more blueprints/templates. In the Kudzu Engine I implemented an actual prefab system. Read more about it here.


Demonstrated Projects

Multi-Game Support

Created three distinct game demos demonstrating engine flexibility:

  1. Tile-based Puzzle Game - Simple grid-based puzzle
  2. Driving Simulator - Simple car controller with a small city
  3. Paint Ball Shooter - Real-time particle effects with collision detection

Paint Game, lots of entities and particles

Driving Game, simple car controller

PlayStation 5 Deployment

Both games shown above run on PlayStation 5 hardware. The engine was built with cross-platform support in mind, allowing easy deployment to console platforms.

Because of NDA restrictions, I cannot show any footage of the PS5 version.


Code Quality & Best Practices

C++

  • Warning-free compilation at maximum warning levels with warnings-as-errors
  • Static analysis compliance using Clang-Tidy with C++ Core Guidelines
  • Modern C++ patterns including RAII, smart pointers, and template metaprogramming

Architecture Patterns

  • Command Pattern for undo/redo functionality
  • Observer Pattern for event system
  • Factory Pattern for cross-platform abstractions
  • Component Pattern for modular entity design

Technologies Used

Core: C++17, EnTT ECS
Tools: ImGui, ImGuizmo, Cereal, TinyGLTF, GLM
Platforms: PC & PlayStation 5
Build System: Visual Studio 2022
Version Control: GitHub


All in all, this project has been a fantastic learning experience and sparked my passion for engine & tools development. Making generic and reusable systems is incredibly fun and rewarding.