3D Game Engine

C++ 11 OpenGL 3.3 Windows CMake

A custom-built component-based 3D game engine featuring real-time physics simulation, forward rendering pipeline, and flexible entity architecture.

📖 Overview

This project is a from-scratch 3D game engine developed in C++11 with OpenGL 3.3, demonstrating proficiency in real-time graphics programming, physics simulation, and game engine architecture. The engine implements industry-standard patterns including an Entity-Component System (ECS), a finite state machine for game states, and a multi-phase physics solver with impulse-based collision resolution.

✨ Key Highlights

🛠️ Tech Stack

Category Technology
Language C++11
Graphics API OpenGL 3.3 Core Profile
Windowing GLFW 3.x
OpenGL Loading GLEW 2.x
Mathematics GLM (OpenGL Mathematics)
Model Loading Assimp (Open Asset Import Library)
Texture Loading SOIL (Simple OpenGL Image Library)
Build System CMake 3.15+
Compiler MSVC (Visual Studio Build Tools)

🏗️ Architecture

┌──────────────────────────────────────────────────────────────────┐
│                         GameEngine                               │
│  ┌─────────────────────────────────────────────────────────────┐ │
│  │                    GameStateManager                         │ │
│  │  ┌────────────────────────────────────────────────────────┐ │ │
│  │  │                      Level                             │ │ │
│  │  │  ┌──────────────────┐  ┌─────────────────────────────┐ │ │ │
│  │  │  │  PhysicsSystem   │  │      ObjectManager          │ │ │ │
│  │  │  │  ┌────────────┐  │  │  ┌───────────────────────┐  │ │ │ │
│  │  │  │  │ Collision  │  │  │  │     GameObject[]      │  │ │ │ │
│  │  │  │  │ Detection  │  │  │  │  ┌─────────────────┐  │  │ │ │ │
│  │  │  │  ├────────────┤  │  │  │  │   Component[]   │  │  │ │ │ │
│  │  │  │  │  Impulse   │  │  │  │  │ • Transform     │  │  │ │ │ │
│  │  │  │  │  Solver    │  │  │  │  │ • RigidBody     │  │  │ │ │ │
│  │  │  │  ├────────────┤  │  │  │  │ • Collider      │  │  │ │ │ │
│  │  │  │  │ Integration│  │  │  │  │ • Behaviors     │  │  │ │ │ │
│  │  │  │  └────────────┘  │  │  │  └─────────────────┘  │  │ │ │ │
│  │  │  └──────────────────┘  │  └───────────────────────┘  │ │ │ │
│  │  └────────────────────────────────────────────────────────┘ │ │
│  └─────────────────────────────────────────────────────────────┘ │
│  ┌─────────────────────────────────────────────────────────────┐ │
│  │                    Rendering System                         │ │
│  │  Forward Renderer • Shader Management • Model/Mesh Pipeline │ │
│  └─────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘

🧩 Entity-Component System (ECS)

The engine employs a component-based architecture where game entities (GameObject) are containers for modular components that define behavior and properties:

// Component system uses CRTP pattern for type-safe component identification
class Transform : public Component<TRANSFORM> { ... };
class RigidBody : public Component<RIGIDBODY> { ... };
class Collider  : public Component<COLLIDER>  { ... };

Supported Components

⚙️ Physics System

A custom rigid body physics engine implementing a 6-phase simulation pipeline:

Phase Description
1. Gather Collect active bodies with physics components from ObjectManager
2. Integrate Forces Apply gravity and external forces to update velocities
3. Detect Collisions OBB vs OBB intersection testing using Separating Axis Theorem
4. Solve Contacts Sequential impulse solver with friction and restitution
5. Integrate Velocities Semi-implicit Euler integration for positions and orientations
6. Sync Transforms Write physics state back to Transform components

Physics Features

// Physics update pipeline (called each frame)
void PhysicsSystem::Update(float dt) {
    GatherBodies();          // Phase 1
    IntegrateForces(dt);     // Phase 2
    DetectCollisions();      // Phase 3
    SolveContacts(dt);       // Phase 4
    IntegrateVelocities(dt); // Phase 5
    SyncTransforms();        // Phase 6
}

🎨 Rendering System

A forward rendering pipeline with shader-based lighting using the Blinn-Phong model:

Lighting Types

Shader System

Shader Purpose
MultiLight Primary PBR-style lighting with multi-source support
DebugLine Wireframe rendering for collision visualization
HUDText Bitmap font rendering for UI overlays
DeferredGeometry (Experimental) G-buffer generation for deferred path

Rendering Features

📊 Technical Specifications

Metric Value
OpenGL Version 3.3 Core
GLSL Version 130
Max Point Lights 4 (configurable)
Physics Solver Iterations 8 (configurable)
Default Object Pool 256 per model type
Collision Layers 32 (bitmask)
Supported Model Formats OBJ, FBX (via Assimp)

✅ Implemented Features

✓ Component-Based Entity System
✓ Rigid Body Physics
✓ OBB Collision Detection (SAT)
✓ Impulse-Based Resolution
✓ Multi-Light Forward Rendering
✓ Model Loading (OBJ/FBX)
✓ Diffuse/Specular Texturing
✓ Game State Machine
✓ Object Pooling
✓ Collision Events
✓ Layer-Based Filtering
✓ Debug Visualization
✓ HUD System
✓ First-Person Camera
✓ Runtime Object Spawning

🎮 Controls

Key Action
W A S D Move camera
Mouse Look around
C Spawn dynamic box
V Spawn static platform
M Delete object in crosshair
P Toggle collision debug view
ESC Quit

🚀 Future Enhancements

▶ Try the Playable Engine