# raysan5/raylib architecture

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

- Interactive diagram: https://gitdiagram.com/raysan5/raylib
- Repository: https://github.com/raysan5/raylib

## Overview

raylib is a C game-programming library. The principal workflow is: an application uses the public API to initialize a platform window, process input and timing, update camera or game state, issue 2D/3D drawing and audio calls, and present results through a graphics backend. Core modules cover rendering, assets, text, models, audio, mathematics, and input helpers. The graph preserves documented platform, OpenGL, software-rendering, VR, shader, and media-format capabilities; some links are inferred from module organization because only sampled excerpts were available.

Main entry points: [`src/rlgl.h`](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) (OpenGL Abstraction), [`src/platforms`](https://github.com/raysan5/raylib/tree/master/src/platforms) (Platform Backends), [`src/rcore.c`](https://github.com/raysan5/raylib/blob/master/src/rcore.c) (Core Loop), [`src/rtextures.c`](https://github.com/raysan5/raylib/blob/master/src/rtextures.c) (Textures Images)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_api["Public API"]
  node_raylib_api["Raylib API<br/>[raylib.h]"]
end

subgraph group_g_runtime["Runtime Modules"]
  node_core_loop["Core Loop<br/>[rcore.c]"]
  node_shapes["2D Shapes<br/>[rshapes.c]"]
  node_textures["Textures Images<br/>[rtextures.c]"]
  node_text_fonts["Text Fonts<br/>[rtext.c]"]
  node_models3d["3D Models<br/>[rmodels.c]"]
  node_audio["Audio Playback<br/>[raudio.c]"]
  node_math["Math Types<br/>[raymath.h]"]
  node_camera["Camera Control<br/>[rcamera.h]"]
  node_gestures["Gesture Input<br/>[rgestures.h]"]
end

subgraph group_g_backend["Platform Backends"]
  node_rlgl["OpenGL Abstraction<br/>[rlgl.h]"]
  node_platforms["Platform Backends"]
  node_glfw["GLFW Windowing<br/>[glfw3.h]"]
  node_software_renderer["Software Renderer<br/>[rlsw.h]"]
  node_shader_sources["Shader Support<br/>[rlgl.h]"]
end

subgraph group_g_media["Bundled Media"]
  node_media_codecs["Media Codecs"]
  node_model_loaders["Model Loaders<br/>[cgltf.h]"]
end

node_application(("Game Application"))
node_display_gpu{{"Display GPU"}}
node_audio_device{{"Audio Device"}}

node_application -->|"uses API"| node_raylib_api
node_application -->|"initializes loop"| node_core_loop
node_application -->|"updates camera"| node_camera
node_application -->|"draws shapes"| node_shapes
node_application -->|"loads textures"| node_textures
node_application -->|"draws text"| node_text_fonts
node_application -->|"draws models"| node_models3d
node_application -->|"plays audio"| node_audio
node_application -->|"reads gestures"| node_gestures
node_camera -->|"uses math"| node_math
node_core_loop -->|"manages platform"| node_platforms
node_core_loop -->|"controls rendering"| node_rlgl
node_platforms -.->|"opens desktop window"| node_glfw
node_platforms -->|"presents frames"| node_display_gpu
node_platforms -.->|"selects renderer"| node_software_renderer
node_shapes -->|"submits geometry"| node_rlgl
node_textures -->|"uploads textures"| node_rlgl
node_text_fonts -->|"renders glyphs"| node_rlgl
node_models3d -->|"submits models"| node_rlgl
node_models3d -.->|"loads model data"| node_model_loaders
node_textures -.->|"decodes images"| node_media_codecs
node_audio -->|"decodes audio"| node_media_codecs
node_audio -->|"outputs samples"| node_audio_device
node_rlgl -->|"executes commands"| node_display_gpu
node_rlgl -->|"uses shaders"| node_shader_sources

click node_raylib_api "https://github.com/raysan5/raylib/blob/master/src/raylib.h"
click node_core_loop "https://github.com/raysan5/raylib/blob/master/src/rcore.c"
click node_shapes "https://github.com/raysan5/raylib/blob/master/src/rshapes.c"
click node_textures "https://github.com/raysan5/raylib/blob/master/src/rtextures.c"
click node_text_fonts "https://github.com/raysan5/raylib/blob/master/src/rtext.c"
click node_models3d "https://github.com/raysan5/raylib/blob/master/src/rmodels.c"
click node_audio "https://github.com/raysan5/raylib/blob/master/src/raudio.c"
click node_math "https://github.com/raysan5/raylib/blob/master/src/raymath.h"
click node_camera "https://github.com/raysan5/raylib/blob/master/src/rcamera.h"
click node_gestures "https://github.com/raysan5/raylib/blob/master/src/rgestures.h"
click node_rlgl "https://github.com/raysan5/raylib/blob/master/src/rlgl.h"
click node_platforms "https://github.com/raysan5/raylib/tree/master/src/platforms"
click node_glfw "https://github.com/raysan5/raylib/blob/master/src/external/glfw/include/GLFW/glfw3.h"
click node_software_renderer "https://github.com/raysan5/raylib/blob/master/src/external/rlsw.h"
click node_media_codecs "https://github.com/raysan5/raylib/tree/master/src/external"
click node_model_loaders "https://github.com/raysan5/raylib/blob/master/src/external/cgltf.h"
click node_shader_sources "https://github.com/raysan5/raylib/blob/master/src/rlgl.h"

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_raylib_api toneBlue
class node_core_loop,node_shapes,node_textures,node_text_fonts,node_models3d,node_audio,node_math,node_camera,node_gestures toneAmber
class node_rlgl,node_platforms,node_glfw,node_software_renderer,node_shader_sources toneMint
class node_media_codecs,node_model_loaders toneRose
class node_application,node_display_gpu,node_audio_device toneIndigo
```

## Components

### Public API

- [Raylib API](https://github.com/raysan5/raylib/blob/master/src/raylib.h): `src/raylib.h`

### Runtime Modules

- [Core Loop](https://github.com/raysan5/raylib/blob/master/src/rcore.c): `src/rcore.c`
- [2D Shapes](https://github.com/raysan5/raylib/blob/master/src/rshapes.c): `src/rshapes.c`
- [Textures Images](https://github.com/raysan5/raylib/blob/master/src/rtextures.c): `src/rtextures.c`
- [Text Fonts](https://github.com/raysan5/raylib/blob/master/src/rtext.c): `src/rtext.c`
- [3D Models](https://github.com/raysan5/raylib/blob/master/src/rmodels.c): `src/rmodels.c`
- [Audio Playback](https://github.com/raysan5/raylib/blob/master/src/raudio.c): `src/raudio.c`
- [Math Types](https://github.com/raysan5/raylib/blob/master/src/raymath.h): `src/raymath.h`
- [Camera Control](https://github.com/raysan5/raylib/blob/master/src/rcamera.h): `src/rcamera.h`
- [Gesture Input](https://github.com/raysan5/raylib/blob/master/src/rgestures.h): `src/rgestures.h`

### Platform Backends

- [OpenGL Abstraction](https://github.com/raysan5/raylib/blob/master/src/rlgl.h): `src/rlgl.h`
- [Platform Backends](https://github.com/raysan5/raylib/tree/master/src/platforms): `src/platforms`
- [GLFW Windowing](https://github.com/raysan5/raylib/blob/master/src/external/glfw/include/GLFW/glfw3.h): `src/external/glfw/include/GLFW/glfw3.h`
- [Software Renderer](https://github.com/raysan5/raylib/blob/master/src/external/rlsw.h): `src/external/rlsw.h`
- [Shader Support](https://github.com/raysan5/raylib/blob/master/src/rlgl.h): `src/rlgl.h`

### Bundled Media

- [Media Codecs](https://github.com/raysan5/raylib/tree/master/src/external): `src/external`
- [Model Loaders](https://github.com/raysan5/raylib/blob/master/src/external/cgltf.h): `src/external/cgltf.h`

### Other components

- **Game Application**
- **Display GPU**
- **Audio Device**

## Connections

- Game Application → Raylib API: uses API
- Game Application → Core Loop: initializes loop
- Game Application → Camera Control: updates camera
- Game Application → 2D Shapes: draws shapes
- Game Application → Textures Images: loads textures
- Game Application → Text Fonts: draws text
- Game Application → 3D Models: draws models
- Game Application → Audio Playback: plays audio
- Game Application → Gesture Input: reads gestures
- Camera Control → Math Types: uses math
- Core Loop → Platform Backends: manages platform
- Core Loop → OpenGL Abstraction: controls rendering
- Platform Backends → GLFW Windowing: opens desktop window
- Platform Backends → Display GPU: presents frames
- Platform Backends → Software Renderer: selects renderer
- 2D Shapes → OpenGL Abstraction: submits geometry
- Textures Images → OpenGL Abstraction: uploads textures
- Text Fonts → OpenGL Abstraction: renders glyphs
- 3D Models → OpenGL Abstraction: submits models
- 3D Models → Model Loaders: loads model data
- Textures Images → Media Codecs: decodes images
- Audio Playback → Media Codecs: decodes audio
- Audio Playback → Audio Device: outputs samples
- OpenGL Abstraction → Display GPU: executes commands
- OpenGL Abstraction → Shader Support: uses shaders
