# krishna2803/snake-gl architecture

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

## Overview

##### Project Components
- Main Game Application: Represented by src/main.c, it contains the game’s core logic including initialization, the game loop, input processing, game state updates, and rendering commands.
- OpenGL Loader: The file src/glad.c in combination with the headers in inc/glad (and related inc/KHR) are responsible for loading modern OpenGL functions.
- Graphics & Windowing: The use of OpenGL (with Direct State Access) and GLFW (noted by the presence of headers in inc/glfw) implies a clear separation for managing window creation, input events, and context setup.
- Math & Utility Libraries: The inclusion of directories like inc/cglm suggests that vector/matrix operations (likely used in rendering calculations) are managed by an external math library.
- Debug & Helper Modules: The header inc/gl_debug.h hints at built-in debugging or logging support to track OpenGL state or errors.
- Build & Configuration: The Makefile at the project root indicates a build system that compiles the code and likely manages linking the external libraries together (even if some of them are included as submodules or directly in the inc directory).

##### Relationships & Interactions
- The Main Application is at the core and interacts directly with the OpenGL Loader to set up the graphics environment.
- The math library (cglm) supports rendering and possibly physics calculations by providing operations on vectors and matrices.
- The debugging facilities (like gl_debug.h) would receive log outputs or error messages from both the main loop and OpenGL operations, primarily on rendering issues.

## Diagram (Mermaid)

```mermaid
flowchart TD
    MF["Build & Configuration<br/>(Makefile)"]:::build

    subgraph "Game Engine Core"
        MAIN["Main Game Application<br/>(Core Logic)"]:::game
    end

    subgraph "Rendering System"
        GLLoader["OpenGL Loader<br/>(Implementation)"]:::render
        GLHeaders["GLAD Headers"]:::render
        KHRHeaders["KHR Headers"]:::render
    end

    subgraph "Supporting Libraries"
        GLFW["Input & Window Management<br/>(GLFW)"]:::support
        CGLM["Math & Utility Library<br/>(cglm)"]:::support
        DEBUG["Debug & Logging Module<br/>(gl_debug.h)"]:::support
    end

    MF -->|"builds"| MAIN
    MF -->|"builds"| GLLoader
    MF -->|"builds"| GLFW
    MF -->|"builds"| CGLM
    MF -->|"builds"| DEBUG

    MAIN -->|"initOpenGL"| GLLoader
    GLLoader -->|"loadsHeaders"| GLHeaders
    GLLoader -->|"loadsHeaders"| KHRHeaders

    MAIN <-->|"handlesInput"| GLFW
    MAIN -->|"mathOps"| CGLM
    MAIN -->|"logErrors"| DEBUG
    GLLoader -->|"logErrors"| DEBUG

    click MF "https://github.com/krishna2803/snake-gl/tree/main/Makefile"
    click MAIN "https://github.com/krishna2803/snake-gl/blob/main/src/main.c"
    click GLLoader "https://github.com/krishna2803/snake-gl/blob/main/src/glad.c"
    click GLHeaders "https://github.com/krishna2803/snake-gl/tree/main/inc/glad"
    click KHRHeaders "https://github.com/krishna2803/snake-gl/tree/main/inc/KHR"
    click GLFW "https://github.com/krishna2803/snake-gl/tree/main/inc/glfw"
    click CGLM "https://github.com/krishna2803/snake-gl/tree/main/inc/cglm"
    click DEBUG "https://github.com/krishna2803/snake-gl/blob/main/inc/gl_debug.h"

    classDef game fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef render fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef support fill:#ffebcd,stroke:#333,stroke-width:2px;
    classDef build fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
