# fazlibeqir/kompjuterska-grafika-projekt architecture

> Architecture diagram of the GitHub repository fazlibeqir/kompjuterska-grafika-projekt, 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/fazlibeqir/kompjuterska-grafika-projekt
- Repository: https://github.com/fazlibeqir/kompjuterska-grafika-projekt

## Overview

##### Main Components
- Game Application Core: At the heart lies the game loop, managed in main.cpp and game-related files (Game.cpp/h, GlobalVariables, MainMenu, etc.) which coordinate navigation between game states.
- Rendering Engine: This handles graphics (using OpenGL via the Glitter boilerplate), shader management (see the Shaders directory with car.frag, skybox.vert, etc.), camera handling (camera.hpp), and mesh/model management (mesh.hpp, Model.hpp).
- Physics Engine: Integration with the Bullet physics library is evident from the Physics files (Physics.cpp/h). This component simulates collisions, car dynamics, and environmental physics.
- Audio System: Managed via Audio.cpp/h files along with irrKlang library integration—this handles music and sound effects.
- Input Handling: The project uses GLFW (as configured via CMake and GLFW dependencies) to capture keyboard inputs for controlling the car, camera, and menu options.
- Asset Management: With well-organized asset folders for models, textures, shaders, and audio files, this component handles resource loading (models from .obj, textures from .bmp, etc.), often facilitated by libraries like assimp and stb.
- Utility Modules: These include ancillary modules like GlobalVariables for configuration, scoring/logging (Score.hpp), and initialization (init.h/cpp) routines.

##### Relationships and Interactions
- The Game Application Core coordinates the game loop and interacts with the Rendering Engine (for display), the Physics Engine (to update physics), and the Audio System (to play sounds).
- The Rendering Engine uses shaders and handles the drawing of the Scene, meshes, skybox, and terrain.
- Physics updates from Bullet are applied to the state of the game objects which then affects rendering outputs.
- Input events captured via GLFW are passed to the Game Core for processing (e.g., car movement, camera control).
- The Asset Management module supplies models, textures, and audio resources to the graphics and audio subsystems.

##### Important Architectural Patterns
- Separation of Concerns: The project divides responsibilities among distinct modules (graphics, physics, audio, input, assets), promoting modularity.
- Hierarchical Layering: Lower-level systems (asset loading, shader management) support higher-level game logic.
- Integration of External Libraries: Notice how external libraries are incorporated as specialized modules within the system, reflecting a plug-in-like design where each library manages its dedicated functionality.

##### Relevant Technologies and Frameworks
- C++ for core application logic.
- OpenGL for rendering, with the Glitter boilerplate facilitating setup.
- Bullet for the physics engine.
- GLFW for window management and input handling.
- irrKlang for audio.
- Additional libraries assimp, glm, and stb for model, math, and texture support.

##### Specific Elements
- Clear Labels: Name each block (Game Core, Rendering Engine, Physics Engine, Audio System, Input Handler, Asset Manager).
- External Libraries: Represent these as annotated external modules (e.g., “Bullet Physics”, “irrKlang Audio”) connected with integration lines to their respective subsystems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Game Application Core Subgraph
    subgraph "Game Application Core"
        G1["Game Loop (main.cpp & main.hpp)"]:::gameCore
        G2["Game Management (Game.cpp & Game.h)"]:::gameCore
        G3["Main Menu & State (MainMenu.cpp & MainMenu.h)"]:::gameCore
    end

    %% Rendering Engine Subgraph
    subgraph "Rendering Engine"
        R1["Shader & Graphics Resources"]:::rendering
        R2["Camera & Mesh (camera.hpp, mesh.hpp, shader.hpp)"]:::rendering
        R3["Model Loading (Model.hpp)"]:::rendering
    end

    %% Physics Engine Subgraph
    subgraph "Physics Engine"
        P1["Physics Simulation (Physics.cpp & Physics.h)"]:::physics
    end

    %% Audio System Subgraph
    subgraph "Audio System"
        A1["Audio Management (Audio.cpp & Audio.hpp)"]:::audio
    end

    %% Input Handling Subgraph
    subgraph "Input Handler"
        I1["GLFW Input"]:::input
    end

    %% Asset Management Subgraph
    subgraph "Asset Management"
        AS1["Assets (Glitter/Sources/assets)"]:::assets
    end

    %% Utility Modules Subgraph
    subgraph "Utility Modules"
        U1["Global Variables (GlobalVariables.cpp & GlobalVariables.h)"]:::utility
        U2["Score Management (Score.hpp)"]:::utility
        U3["Initialization Routines (init.cpp & init.h)"]:::utility
    end

    %% External Libraries Subgraph
    subgraph "External Libraries"
        E1["assimp"]:::external
        E2["Bullet Physics"]:::external
        E3["GLFW"]:::external
        E4["glm"]:::external
        E5["stb"]:::external
        E6["irrKlang"]:::external
        E7["OpenGL & Glitter Boilerplate"]:::external
    end

    %% Connections between Core and Subsystems
    G1 -->|"renders"| R1
    G1 -->|"updatesPhysics"| P1
    G1 -->|"playsAudio"| A1
    I1 -->|"triggers"| G1
    U1 -->|"configures"| G2
    U2 -->|"updatesScore"| G2
    U3 -->|"initializes"| G2
    AS1 -->|"suppliesAssets"| R1
    AS1 -->|"suppliesAssets"| A1

    %% Connections with External Libraries
    R1 -->|"uses"| E7
    R2 -->|"uses"| E4
    R2 -->|"uses"| E5
    R3 -->|"uses"| E1
    P1 -->|"uses"| E2
    I1 -->|"uses"| E3
    A1 -->|"uses"| E6

    %% Click Events for Game Application Core
    click G1 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Sources/main.cpp"
    click G2 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Sources/Game.cpp"
    click G3 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Sources/MainMenu.cpp"

    %% Click Events for Rendering Engine
    click R1 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/tree/main/Glitter/Shaders"
    click R2 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Headers/camera.hpp"
    click R3 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Headers/Model.hpp"

    %% Click Event for Physics Engine
    click P1 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Sources/Physics.cpp"

    %% Click Event for Audio System
    click A1 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Sources/Audio.cpp"

    %% Click Event for Asset Management
    click AS1 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/tree/main/Glitter/Sources/assets"

    %% Click Events for Utility Modules
    click U1 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Sources/GlobalVariables.cpp"
    click U2 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Headers/Score.hpp"
    click U3 "https://github.com/fazlibeqir/kompjuterska-grafika-projekt/blob/main/Glitter/Sources/init.cpp"

    %% Style Classes
    classDef gameCore fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef rendering fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef physics fill:#ffa500,stroke:#333,stroke-width:2px;
    classDef audio fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef input fill:#ff6961,stroke:#333,stroke-width:2px;
    classDef assets fill:#fdfd96,stroke:#333,stroke-width:2px;
    classDef utility fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef external fill:#ffb6c1,stroke:#333,stroke-width:2px;
```
