# xorz57/learnopengl architecture

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

- Interactive diagram: https://gitdiagram.com/xorz57/learnopengl
- Repository: https://github.com/xorz57/learnopengl

## Overview

LearnOpenGL is a set of progressively richer SDL3/OpenGL example applications, rather than one shared runtime. The workflow is to initialize a window and graphics context, prepare shader programs and scene data, then render an interactive scene; later examples add meshes, lighting, materials, and instancing. The graph emphasizes the later rendering example and retains earlier stages. Source excerpts are partial, so some internal dependency links are marked unverified rather than presented as observed calls.

Main entry points: [`example_005b/main.cc`](https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc) (Lit scene), [`example_005b/mesh.cc`](https://github.com/xorz57/learnopengl/blob/master/example_005b/mesh.cc) (Mesh construction), [`example_003a/main.cc`](https://github.com/xorz57/learnopengl/blob/master/example_003a/main.cc) (Buffer rendering), [`example_002/main.cc`](https://github.com/xorz57/learnopengl/blob/master/example_002/main.cc) (Next example)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demos["Example progression"]
  node_demo001["Basic example<br/>[main.cc]"]
  node_demo002["Next example<br/>[main.cc]"]
  node_demo003["Buffer rendering<br/>[main.cc]"]
  node_demo004["Mesh rendering<br/>[main.cc]"]
  node_demo005["Lit scene<br/>[main.cc]"]
end

subgraph group_runtime["Application runtime"]
  node_sdl["SDL window runtime<br/>[main.cc]"]
  node_ui["ImGui interface<br/>[main.cc]"]
end

subgraph group_rendering["Rendering pipeline"]
  node_buffer["GPU buffers<br/>[buffer.cc]"]
  node_shader["Shader compilation<br/>[shader.h]"]
  node_program["Shader program<br/>[program.cc]"]
  node_gl["OpenGL renderer<br/>[main.cc]"]
end

subgraph group_scene["Scene and interaction"]
  node_camera["Camera controls<br/>[camera.cc]"]
  node_mesh["Mesh construction<br/>[mesh.cc]"]
  node_vertex["Vertex data<br/>[vertex.h]"]
  node_instance["Instance data<br/>[instance.h]"]
  node_lighting["Light and material<br/>[light.h]"]
end

node_user(("Operator"))

node_user -->|"runs"| node_demo005
node_demo001 -.->|"progresses to"| node_demo002
node_demo002 -.->|"progresses to"| node_demo003
node_demo003 -.->|"progresses to"| node_demo004
node_demo004 -.->|"progresses to"| node_demo005
node_demo005 -->|"initializes"| node_sdl
node_demo005 -->|"initializes"| node_ui
node_demo005 -->|"sets up"| node_gl
node_demo003 -->|"creates buffer"| node_buffer
node_program -->|"uses"| node_shader
node_mesh -->|"uses"| node_buffer
node_mesh -->|"uses"| node_vertex
node_mesh -->|"uses"| node_instance
node_demo005 -.->|"uses"| node_camera
node_demo005 -.->|"uses"| node_mesh
node_demo005 -.->|"uses"| node_program
node_demo005 -.->|"uses"| node_lighting

click node_demo001 "https://github.com/xorz57/learnopengl/blob/master/example_001/main.cc"
click node_demo002 "https://github.com/xorz57/learnopengl/blob/master/example_002/main.cc"
click node_demo003 "https://github.com/xorz57/learnopengl/blob/master/example_003a/main.cc"
click node_demo004 "https://github.com/xorz57/learnopengl/blob/master/example_004a/main.cc"
click node_demo005 "https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc"
click node_sdl "https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc"
click node_ui "https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc"
click node_camera "https://github.com/xorz57/learnopengl/blob/master/example_005b/camera.cc"
click node_mesh "https://github.com/xorz57/learnopengl/blob/master/example_005b/mesh.cc"
click node_vertex "https://github.com/xorz57/learnopengl/blob/master/example_005b/vertex.h"
click node_instance "https://github.com/xorz57/learnopengl/blob/master/example_005b/instance.h"
click node_lighting "https://github.com/xorz57/learnopengl/blob/master/example_005b/light.h"
click node_buffer "https://github.com/xorz57/learnopengl/blob/master/example_005b/buffer.cc"
click node_shader "https://github.com/xorz57/learnopengl/blob/master/example_005b/shader.h"
click node_program "https://github.com/xorz57/learnopengl/blob/master/example_005b/program.cc"
click node_gl "https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc"

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_demo001,node_demo002,node_demo003,node_demo004,node_demo005 toneBlue
class node_sdl,node_ui toneAmber
class node_buffer,node_shader,node_program,node_gl toneMint
class node_camera,node_mesh,node_vertex,node_instance,node_lighting toneRose
class node_user toneIndigo
```

## Components

### Example progression

- [Basic example](https://github.com/xorz57/learnopengl/blob/master/example_001/main.cc): `example_001/main.cc`
- [Next example](https://github.com/xorz57/learnopengl/blob/master/example_002/main.cc): `example_002/main.cc`
- [Buffer rendering](https://github.com/xorz57/learnopengl/blob/master/example_003a/main.cc): `example_003a/main.cc`
- [Mesh rendering](https://github.com/xorz57/learnopengl/blob/master/example_004a/main.cc): `example_004a/main.cc`
- [Lit scene](https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc): `example_005b/main.cc`

### Application runtime

- [SDL window runtime](https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc): `example_005b/main.cc`
- [ImGui interface](https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc): `example_005b/main.cc`

### Rendering pipeline

- [GPU buffers](https://github.com/xorz57/learnopengl/blob/master/example_005b/buffer.cc): `example_005b/buffer.cc`
- [Shader compilation](https://github.com/xorz57/learnopengl/blob/master/example_005b/shader.h): `example_005b/shader.h`
- [Shader program](https://github.com/xorz57/learnopengl/blob/master/example_005b/program.cc): `example_005b/program.cc`
- [OpenGL renderer](https://github.com/xorz57/learnopengl/blob/master/example_005b/main.cc): `example_005b/main.cc`

### Scene and interaction

- [Camera controls](https://github.com/xorz57/learnopengl/blob/master/example_005b/camera.cc): `example_005b/camera.cc`
- [Mesh construction](https://github.com/xorz57/learnopengl/blob/master/example_005b/mesh.cc): `example_005b/mesh.cc`
- [Vertex data](https://github.com/xorz57/learnopengl/blob/master/example_005b/vertex.h): `example_005b/vertex.h`
- [Instance data](https://github.com/xorz57/learnopengl/blob/master/example_005b/instance.h): `example_005b/instance.h`
- [Light and material](https://github.com/xorz57/learnopengl/blob/master/example_005b/light.h): `example_005b/light.h`

### Other components

- **Operator**

## Connections

- Operator → Lit scene: runs (evidence: `example_005b/main.cc`)
- Basic example → Next example: progresses to
- Next example → Buffer rendering: progresses to
- Buffer rendering → Mesh rendering: progresses to
- Mesh rendering → Lit scene: progresses to
- Lit scene → SDL window runtime: initializes (evidence: `example_005b/main.cc`)
- Lit scene → ImGui interface: initializes (evidence: `example_005b/main.cc`)
- Lit scene → OpenGL renderer: sets up (evidence: `example_005b/main.cc`)
- Buffer rendering → GPU buffers: creates buffer (evidence: `example_003a/main.cc`)
- Shader program → Shader compilation: uses (evidence: `example_005b/program.cc`)
- Mesh construction → GPU buffers: uses (evidence: `example_005b/mesh.cc`)
- Mesh construction → Vertex data: uses (evidence: `example_005b/mesh.cc`)
- Mesh construction → Instance data: uses (evidence: `example_005b/mesh.cc`)
- Lit scene → Camera controls: uses
- Lit scene → Mesh construction: uses
- Lit scene → Shader program: uses
- Lit scene → Light and material: uses (evidence: `example_005b/main.cc`)
