# mhammerc/engine2 architecture

> Architecture diagram of the GitHub repository mhammerc/engine2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mhammerc/engine2
- Repository: https://github.com/mhammerc/engine2

## Overview

##### Core Systems Breakdown

- GBuffer Pass → Lighting Pass → Post-Processing
- ↓             ↓               ↓
- [Geometry]    [Lighting Data]  [Bloom, ACES Tone Mapping]

##### Component Relationships

Key relationships:
- Entity Component System (ECS)
- Entity → Components (Camera, Light, Material, Outline, Skybox)
- Resource Management System
- Cache Systems → [Mesh Cache, Texture Cache, Shader Cache]

##### Specific subsystems

a) Graphics Pipeline:
- Mesh Loading → Material System → Deferred Renderer
- ↓              ↓               ↓
- [Mesh Cache]   [Shader Cache]   [Framebuffers]

b) Editor Tools:
- Entity Editor → Scene Hierarchy → Property Inspector
- ↓              ↓               ↓
- [Transform]    [Component List]  [Material Editor]

##### Resource Flow

How assets are processed:
- Assets → Loading System → Cache Manager → Runtime Usage

- The deferred rendering pipeline as the core feature
- Component-based architecture using EnTT
- Clear separation between engine systems and editor tools
- Resource management and caching systems
- Debug/development tools integration

Keep the abstraction level high enough to show the overall architecture while including critical subsystems that make this engine unique, such as the deferred renderer, material system, and debug tools.

This structure reflects both the engine's technical capabilities (deferred rendering, shadows, bloom) and its development features (profiler, texture viewer, gizmos), making it valuable for both runtime and development understanding.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        UI["UI System"]
        SceneManagement["Scene Management"]
        InputHandling["Input Handling"]
        
        subgraph "Editor Tools"
            EntityEditor["Entity Editor"]
            SceneHierarchy["Scene Hierarchy"]
            PropertyInspector["Property Inspector"]
            Gizmos["Gizmo System"]
        end
        
        subgraph "Debug Tools"
            Profiler["Profiler"]
            ShaderViewer["Shader Viewer"]
            TextureViewer["Texture Viewer"]
        end
    end
    
    subgraph "Rendering Layer"
        DeferredRenderer["Deferred Renderer"]
        
        subgraph "Graphics Pipeline"
            GBufferPass["GBuffer Pass"]
            LightingPass["Lighting Pass"]
            PostProcessing["Post-Processing"]
        end
        
        subgraph "Resource Management"
            MeshCache[("Mesh Cache")]
            TextureCache[("Texture Cache")]
            ShaderCache[("Shader Cache")]
            FramebufferCache[("Framebuffer Cache")]
        end
        
        MaterialSystem["Material System"]
        ShaderPipeline["Shader Pipeline"]
    end
    
    subgraph "Platform Layer"
        GLFW["GLFW Window"]
        OpenGL["OpenGL Context"]
    end
    
    subgraph "Entity Component System"
        ECS["EnTT ECS"]
        Components["Components"]
    end
    
    %% Relationships
    UI --> EntityEditor
    UI --> SceneHierarchy
    UI --> PropertyInspector
    UI --> Gizmos
    UI --> Profiler
    UI --> ShaderViewer
    UI --> TextureViewer
    
    SceneManagement --> ECS
    InputHandling --> GLFW
    
    DeferredRenderer --> GBufferPass
    GBufferPass --> LightingPass
    LightingPass --> PostProcessing
    
    MaterialSystem --> ShaderCache
    MaterialSystem --> TextureCache
    
    DeferredRenderer --> MaterialSystem
    DeferredRenderer --> ShaderPipeline
    DeferredRenderer --> FramebufferCache
    
    ECS --> Components
    Components --> MaterialSystem
    
    OpenGL --> GLFW
    
    %% Styling
    classDef platform fill:#e6e6e6
    classDef rendering fill:#a8d5ba
    classDef resource fill:#ffb366
    classDef ui fill:#b3b3cc
    classDef ecs fill:#ff9999
    classDef debug fill:#cc99ff
    
    class GLFW,OpenGL platform
    class DeferredRenderer,GBufferPass,LightingPass,PostProcessing,MaterialSystem,ShaderPipeline rendering
    class MeshCache,TextureCache,ShaderCache,FramebufferCache resource
    class UI,EntityEditor,SceneHierarchy,PropertyInspector,Gizmos ui
    class ECS,Components ecs
    class Profiler,ShaderViewer,TextureViewer debug
    
    %% Click events
    click UI "https://github.com/mhammerc/engine2/tree/main/src/ui/"
    click InputHandling "https://github.com/mhammerc/engine2/blob/main/src/core/input.hpp"
    click DeferredRenderer "https://github.com/mhammerc/engine2/tree/main/src/graphics/deferred_renderer/"
    click MeshCache "https://github.com/mhammerc/engine2/blob/main/src/graphics/mesh_cache.h"
    click TextureCache "https://github.com/mhammerc/engine2/blob/main/src/graphics/texture/texture_cache.h"
    click ShaderCache "https://github.com/mhammerc/engine2/blob/main/src/graphics/shader_cache.h"
    click FramebufferCache "https://github.com/mhammerc/engine2/blob/main/src/graphics/framebuffer_cache.h"
    click GLFW "https://github.com/mhammerc/engine2/blob/main/src/platform/glfw.h"
    click OpenGL "https://github.com/mhammerc/engine2/blob/main/src/platform/opengl.h"
    click Profiler "https://github.com/mhammerc/engine2/tree/main/src/ui/ui_window_profiler/"
    click ShaderViewer "https://github.com/mhammerc/engine2/tree/main/src/ui/ui_window_shader_viewer/"
    click TextureViewer "https://github.com/mhammerc/engine2/tree/main/src/ui/ui_window_texture_viewer/"
    click SceneManagement "https://github.com/mhammerc/engine2/blob/main/src/create_scene.h"
    click MaterialSystem "https://github.com/mhammerc/engine2/blob/main/src/components/material_component.h"
    click ShaderPipeline "https://github.com/mhammerc/engine2/blob/main/src/graphics/shader_program.h"
    click EntityEditor "https://github.com/mhammerc/engine2/tree/main/src/ui/entity_editor/"
    click SceneHierarchy "https://github.com/mhammerc/engine2/blob/main/src/ui/ui_window_hierarchy.cpp"
    click Gizmos "https://github.com/mhammerc/engine2/blob/main/src/ui/ui_gizmo_manipulate_3d_object.cpp"
    click Components "https://github.com/mhammerc/engine2/tree/main/src/components/"
    click ECS "https://github.com/mhammerc/engine2/blob/main/src/core/entity.h"
```
