# jlisowskyy/opengl-rendering-engine architecture

> Architecture diagram of the GitHub repository jlisowskyy/opengl-rendering-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jlisowskyy/opengl-rendering-engine
- Repository: https://github.com/jlisowskyy/opengl-rendering-engine

## Overview

##### Project Type & Purpose
- This is a C++ OpenGL rendering engine featuring deferred shading, model loading, real-time lighting (with Blinn-Phong), an IMGUI-based UI, and scene management. Key functionalities include rendering (shaders, lighting, overlays), scene handling (saving/loading configurations), and engine management.

##### Key Components
a. Core Engine Layer:
- Engine Core: Located in src/libcgp/engine. Contains components such as process_loop, view management, light manager, global lighting, and g_buffer management.
- Window & Input Handling: Under src/libcgp/window, including mouse operations and window management (as well as overlays for debugging).

b. Resource & Scene Management:
- Managers: The object_mgr, resource_mgr, and settings_mgr found in src/libcgp/mgr.
- Scene Serialization: The scene_serializer under src/libcgp/serialization manages saving and loading scene configurations.
- Predefined test scenes and model definitions: Represented in the scenes and models directories.

c. Rendering Pipeline:
- Deferred Shading Pipeline: Implemented via the shaders in src/shaders (e.g., deferred_shading, g_buffer shaders) and integrated in the engine.
- Shader & Mesh Handling: Located in src/libcgp/primitives (shader, mesh, model, texture).

d. UI Layer:
- IMGUI Integration: The engine includes an IMGUI-based editor interface, possibly interacting with both the window components and engine overlays (src/libcgp/window/overlay).

e. External Dependencies & Libraries:

f. Asset Compiler & Resources:
- The asset_compiler directory suggests a pre-build step for processing assets.
- Resources and models directories provide assets for rendered scenes.

##### Relationships & Data Flow
- The Flow starts from the entry points (main_debug.cpp, main_editor.cpp, main_game.cpp in src/) which initialize the engine.
- The Engine Core interacts with the window management, the resource and object managers, and the deferred shading pipeline.
- The UI components (IMGUI overlays) interact directly with engine settings and runtime modifications (e.g., lighting, world time).
- External dependencies provide foundational capabilities (e.g., GLFW for windowing, GLM for mathematics) and are integrated into the engine’s core via CMake configuration.
- Scene management components (scene_serializer, resource_mgr) facilitate loading/saving and handling of views, which are then rendered via the deferred shading pipeline.

##### Architectural Patterns & Design Principles
- Modular Structure: The project is separated into distinct modules (engine, managers, primitives, window, serialization) which eases maintenance and upgrades.
- Separation of Concerns: There is a clear distinction between the core engine logic, rendering pipeline, resource management, and the UI.
- Reusability & Extensibility: Having well-defined managers for resources and objects, as well as externalized dependencies, encourages reusability and clean integration of additional features (e.g., new rendering techniques or input methods).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Entry Point Layer
    EP("Entry Points (main_debug,main_editor,main_game)"):::entry

    %% Engine Core Layer
    subgraph "Engine Core Layer"
        EC("Engine Core"):::engine
        WI("Window & Input Handling"):::window
        EN("External Dependencies"):::external
    end

    %% Management Layer
    subgraph "Management Layer"
        RM("Resource & Scene Managers"):::resource
        SS_CPP("Scene Serializer (C++)"):::resource
        SS_HPP("Scene Serializer (Header)"):::resource
        TS("Predefined Test Scenes"):::resource
        MD("Model Definitions"):::resource
    end

    %% Rendering Pipeline Layer
    subgraph "Rendering Pipeline"
        DS("Deferred Shading Pipeline"):::rendering
        SM("Shader & Mesh Handling"):::rendering
    end

    %% UI Layer
    subgraph "UI Layer"
        UI("IMGUI UI & Overlays"):::ui
    end

    %% Asset & Resources Layer
    subgraph "Asset & Resources"
        AC("Asset Compiler"):::asset
        RES("Resources"):::asset
    end

    %% Connections
    EP --> EC
    EC --> WI
    EC --> RM
    EC --> DS
    EC --> SM
    EC --> UI
    EC --> EN
    RM --> SS_CPP
    RM --> SS_HPP
    RM --> TS
    RM --> MD
    DS --> SM
    WI --> UI
    EC --> AC
    AC --> RES

    %% Click Events
    click EC "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/src/libcgp/engine"
    click WI "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/src/libcgp/window"
    click RM "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/src/libcgp/mgr"
    click SS_CPP "https://github.com/jlisowskyy/opengl-rendering-engine/blob/main/src/libcgp/serialization/scene_serializer.cpp"
    click SS_HPP "https://github.com/jlisowskyy/opengl-rendering-engine/blob/main/src/libcgp/serialization/scene_serializer.hpp"
    click TS "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/scenes"
    click MD "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/models"
    click DS "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/src/shaders"
    click SM "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/src/libcgp/primitives"
    click UI "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/src/libcgp/window/overlay"
    click EN "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/deps"
    click AC "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/asset_compiler"
    click RES "https://github.com/jlisowskyy/opengl-rendering-engine/tree/main/resources"

    %% Styles
    classDef engine fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef window fill:#b3e5fc,stroke:#333,stroke-width:2px;
    classDef resource fill:#c8e6c9,stroke:#333,stroke-width:2px;
    classDef rendering fill:#ffe082,stroke:#333,stroke-width:2px;
    classDef ui fill:#d1c4e9,stroke:#333,stroke-width:2px;
    classDef external fill:#d7ccc8,stroke:#333,stroke-width:2px;
    classDef asset fill:#f0f4c3,stroke:#333,stroke-width:2px;
    classDef entry fill:#e0e0e0,stroke:#333,stroke-width:2px;
```
