# thecherno/opengl architecture

> Architecture diagram of the GitHub repository thecherno/opengl, 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/thecherno/opengl
- Repository: https://github.com/thecherno/opengl

## Overview

##### Main Components
- OpenGL-Core Library: This is the heart of the project. It contains several submodules:
- Core Functionality (application management, layer system, logging, input management, event system, and window handling)
- Utility Components (shader management, camera, orthographic controllers, and debugging utilities)
- ImGui Integration (for GUI layer functionalities)
- Platform Specific Implementations (Windows-specific implementations for input and window operations)
- OpenGL-Examples: Contains sample applications which demonstrate how to use the core OpenGL functionality.
- OpenGL-Sandbox: Provides a playground or experimental area (SandboxApp and SandboxLayer) where users can write and test custom OpenGL code.
- Build/Configuration Tools: The premake5 scripts and the batch script (scripts/Win-Premake.bat) to generate Visual Studio solutions/projects.
- Vendor: Third-party libraries used by the project (could include dependencies for OpenGL or ImGui).

##### Relationships and Interactions
- The example and sandbox applications act as consumers or clients of the OpenGL-Core library.
- The core library is built in a modular fashion. For instance, the “Core” folder contains application initialization, event handling, and logging, while the “Platform” folder abstracts platform-specific operations (currently only Windows is “officially” supported).
- Components inside OpenGL-Core interact internally: the Application class drives the main loop, LayerStack manages different layers (including ImGui integration), and the Utility modules support common features like shader compilation or camera management.
- The platform-specific modules (under “Platform/Windows”) are accessed from the Core modules to provide correct input and window management on Windows.
- Build scripts (premake5.lua at various levels) coordinate building all these modules and their interdependencies.

##### Architectural Patterns and Design Principles
- Modular design: Components (Core, Events, Util, ImGui, Platform) are clearly separated for ease of maintenance and clarity.
- Abstraction layers: Abstractions for platform details (Windows-specific implementations) hide hardware-specific details from the main application logic.
- Layered architecture: Incorporates a layer system (Layer and LayerStack) that can easily add or remove functionality in the rendering and event pipeline.
- Extensibility: The inclusion of example and sandbox projects shows that the core library is designed for experimentation and can be extended by client code.

- Core (Application, Logging, Layer/LayerStack)
- Events (various event types)
- ImGui (ImGuiLayer and supporting code)
- Utilities (Shader management, Camera and Orthographic camera utilities, Debug tools)
- Platform (Windows implementation for input and window management)

##### Final Advice
- Don’t hesitate to create as many detailed components as possible. Even if some are smaller (like individual header sets or the platform abstractions), break them out if it clarifies the overall design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "OpenGL Project"
    
        subgraph "OpenGL-Core"
            CCore["Core (Application, Logging, Layers)"]:::core
            CEvents["Events (AppEvent, KeyEvent, MouseEvent)"]:::events
            CUtil["Utilities (Shader, Camera, Debug)"]:::util
            CImGui["ImGui (ImGuiLayer, ImGuiBuild)"]:::imgui
            CPlatform["Platform (Windows Input & Window)"]:::platform
        end
        
        Examples["OpenGL-Examples"]:::client
        Sandbox["OpenGL-Sandbox"]:::client
        BuildTools["Build Tools (premake5, Win-Premake.bat)"]:::build
        Vendor["Vendor/Third-Party Libraries"]:::vendor
        
    end

    %% Internal interactions within OpenGL-Core
    CCore -->|"uses"| CEvents
    CCore -->|"uses"| CUtil
    CCore -->|"integrates"| CImGui
    CCore -->|"calls"| CPlatform

    %% External dependencies on OpenGL-Core
    Examples -->|"depends"| CCore
    Sandbox -->|"depends"| CCore

    %% Build tools orchestrate all
    BuildTools -->|"builds"| CCore
    BuildTools -->|"builds"| CEvents
    BuildTools -->|"builds"| CUtil
    BuildTools -->|"builds"| CImGui
    BuildTools -->|"builds"| CPlatform
    BuildTools -->|"builds"| Examples
    BuildTools -->|"builds"| Sandbox

    %% Vendor supports the core library
    Vendor -->|"provides libs to"| CCore

    %% Click Events
    click CCore "https://github.com/thecherno/opengl/tree/master/OpenGL-Core/src/GLCore/Core"
    click CEvents "https://github.com/thecherno/opengl/tree/master/OpenGL-Core/src/GLCore/Events"
    click CUtil "https://github.com/thecherno/opengl/tree/master/OpenGL-Core/src/GLCore/Util"
    click CImGui "https://github.com/thecherno/opengl/tree/master/OpenGL-Core/src/GLCore/ImGui"
    click CPlatform "https://github.com/thecherno/opengl/tree/master/OpenGL-Core/src/Platform/Windows"
    click Examples "https://github.com/thecherno/opengl/tree/master/OpenGL-Examples"
    click Sandbox "https://github.com/thecherno/opengl/tree/master/OpenGL-Sandbox"
    click BuildTools "https://github.com/thecherno/opengl/blob/master/scripts/Win-Premake.bat"
    click Vendor "https://github.com/thecherno/opengl/tree/master/OpenGL-Core/vendor"

    %% Style Definitions
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef events fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef util fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef imgui fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef platform fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef client fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef build fill:#FDEBD0,stroke:#BA4A00,stroke-width:2px;
    classDef vendor fill:#D6EAF8,stroke:#2471A3,stroke-width:2px;
```
