# jeremyzetadev/c_sdl2_game architecture

> Architecture diagram of the GitHub repository jeremyzetadev/c_sdl2_game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeremyzetadev/c_sdl2_game
- Repository: https://github.com/jeremyzetadev/c_sdl2_game

## Overview

This repository is a small OpenGL starter project: two standalone examples demonstrate creating a window with GLFW or SDL2, initializing GLAD, and using an OpenGL context. The GLFW example additionally compiles shaders, configures triangle geometry, and renders until exit; the SDL2 example initializes the loader and polls for quit events. The generated GLAD loader and its API header provide the shared OpenGL entry points. README material also mentions shader/file-reading setup, but no corresponding implementation is visible in the provided tree or excerpts.

Main entry points: [`main.c`](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/main.c) (GLFW Triangle), [`main_sdl2.c`](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/main_sdl2.c) (SDL2 Starter), [`glad/include/glad/glad.h`](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/glad/include/glad/glad.h) (GLAD API), [`glad/src/glad.c`](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/glad/src/glad.c) (GLAD Loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_examples["Window Examples"]
  node_glfw_example["GLFW Triangle<br/>[main.c]"]
  node_sdl_example["SDL2 Starter<br/>[main_sdl2.c]"]
end

subgraph group_loader["OpenGL Loader"]
  node_glad_api["GLAD API<br/>[glad.h]"]
  node_glad_loader["GLAD Loader<br/>[glad.c]"]
end

node_developer(("Example User"))
node_glfw["GLFW"]
node_sdl["SDL2"]
node_opengl["OpenGL Context"]

node_developer -->|"runs"| node_glfw_example
node_developer -->|"runs"| node_sdl_example
node_glfw_example -->|"creates window"| node_glfw
node_sdl_example -->|"creates window"| node_sdl
node_glfw_example -->|"uses API"| node_glad_api
node_sdl_example -->|"uses API"| node_glad_api
node_glfw_example -->|"loads functions"| node_glad_loader
node_sdl_example -->|"initializes loader"| node_glad_loader
node_glfw_example -->|"renders triangle"| node_opengl
node_sdl_example -->|"queries vendor"| node_opengl

click node_glfw_example "https://github.com/jeremyzetadev/c_sdl2_game/blob/main/main.c"
click node_sdl_example "https://github.com/jeremyzetadev/c_sdl2_game/blob/main/main_sdl2.c"
click node_glad_api "https://github.com/jeremyzetadev/c_sdl2_game/blob/main/glad/include/glad/glad.h"
click node_glad_loader "https://github.com/jeremyzetadev/c_sdl2_game/blob/main/glad/src/glad.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_glfw_example,node_sdl_example,node_developer toneBlue
class node_glad_api,node_glad_loader toneAmber
class node_glfw,node_sdl,node_opengl toneIndigo
```

## Components

### Window Examples

- [GLFW Triangle](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/main.c): `main.c`
- [SDL2 Starter](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/main_sdl2.c): `main_sdl2.c`

### OpenGL Loader

- [GLAD API](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/glad/include/glad/glad.h): `glad/include/glad/glad.h`
- [GLAD Loader](https://github.com/jeremyzetadev/c_sdl2_game/blob/main/glad/src/glad.c): `glad/src/glad.c`

### Other components

- **Example User**
- **GLFW**
- **SDL2**
- **OpenGL Context**

## Connections

- Example User → GLFW Triangle: runs
- Example User → SDL2 Starter: runs
- GLFW Triangle → GLFW: creates window (evidence: `main.c`)
- SDL2 Starter → SDL2: creates window (evidence: `main_sdl2.c`)
- GLFW Triangle → GLAD API: uses API (evidence: `main.c`)
- SDL2 Starter → GLAD API: uses API (evidence: `main_sdl2.c`)
- GLFW Triangle → GLAD Loader: loads functions (evidence: `main.c`)
- SDL2 Starter → GLAD Loader: initializes loader (evidence: `main_sdl2.c`)
- GLFW Triangle → OpenGL Context: renders triangle (evidence: `main.c`)
- SDL2 Starter → OpenGL Context: queries vendor (evidence: `main_sdl2.c`)
