# ptitseb/gl4es architecture

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

- Interactive diagram: https://gitdiagram.com/ptitseb/gl4es
- Repository: https://github.com/ptitseb/gl4es

## Overview

GL4ES is a compatibility library that presents legacy OpenGL 1.5 and selected OpenGL 2.x functionality on GLES hardware. An application’s GL calls enter the compatibility wrappers, are handled by stateful emulation and shader conversion, then reach the GLES implementation; GLX/EGL setup supplies contexts and hardware capability information. The README documents the main emulation and backend capabilities. Some implementation files are unsampled, so links beyond the indexed imports and documented behavior are omitted.

Main entry points: [`src/gl/gles.h`](https://github.com/ptitseb/gl4es/blob/master/src/gl/gles.h) (GLES calls), [`src/gl/wrap/gles.c`](https://github.com/ptitseb/gl4es/blob/master/src/gl/wrap/gles.c) (GL call wrappers), [`src/gl/program.c`](https://github.com/ptitseb/gl4es/blob/master/src/gl/program.c) (Shader and program API), [`src/glx/glx.c`](https://github.com/ptitseb/gl4es/blob/master/src/glx/glx.c) (GLX interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Compatibility API"]
  node_gl_headers["GL declarations<br/>[gl.h]"]
  node_api_wrappers["GL call wrappers<br/>[gles.c]"]
end

subgraph group_emulation["OpenGL Emulation"]
  node_state["GL state<br/>[glstate.c]"]
  node_fixed_pipeline["Fixed pipeline emulation<br/>[fpe.c]"]
  node_drawing["Drawing and raster<br/>[drawing.c]"]
  node_textures["Texture operations<br/>[texture.c]"]
  node_framebuffers["Framebuffer operations<br/>[framebuffers.c]"]
  node_hash_helper["Hash tables<br/>[khash.h]"]
end

subgraph group_shader["Shader Support"]
  node_shader_api["Shader and program API<br/>[program.c]"]
  node_shader_conversion["Shader conversion<br/>[shaderconv.c]"]
  node_arb_programs["ARB program conversion<br/>[arbparser.c]"]
end

subgraph group_platform["Context and Platform"]
  node_glx_entry["GLX interface<br/>[glx.c]"]
  node_egl_entry["EGL interface<br/>[egl.c]"]
  node_amiga["Amiga interface<br/>[amigaos.c]"]
  node_loader["API loader<br/>[loader.h]"]
  node_capabilities["Hardware capabilities<br/>[hardext.c]"]
  node_gles_backend["GLES calls<br/>[gles.h]"]
end

node_application(("GL application"))
node_gles_driver["GLES driver"]
node_egl_service["EGL implementation"]

node_application -->|"uses API"| node_gl_headers
node_application -->|"calls"| node_api_wrappers
node_api_wrappers -.->|"updates state"| node_state
node_api_wrappers -->|"emulates calls"| node_fixed_pipeline
node_api_wrappers -.->|"dispatches draws"| node_drawing
node_api_wrappers -.->|"handles textures"| node_textures
node_api_wrappers -.->|"handles buffers"| node_framebuffers
node_fixed_pipeline -->|"generates shaders"| node_shader_conversion
node_shader_api -.->|"converts shaders"| node_shader_conversion
node_shader_api -->|"accepts ARB programs"| node_arb_programs
node_shader_api -->|"uses GLES programs"| node_gles_backend
node_arb_programs -->|"produces GLSL"| node_shader_conversion
node_fixed_pipeline -->|"emits GLES calls"| node_gles_backend
node_drawing -.->|"renders through"| node_gles_backend
node_textures -.->|"uses GLES calls"| node_gles_backend
node_framebuffers -.->|"uses GLES calls"| node_gles_backend
node_gles_backend -.->|"dispatches calls"| node_gles_driver
node_glx_entry -->|"uses EGL"| node_egl_entry
node_glx_entry -->|"loads APIs"| node_loader
node_egl_entry -->|"loads APIs"| node_loader
node_loader -.->|"loads symbols"| node_gles_driver
node_egl_entry -.->|"calls EGL"| node_egl_service
node_glx_entry -->|"checks extensions"| node_capabilities
node_capabilities -->|"informs backend"| node_gles_backend
node_amiga -->|"uses capabilities"| node_capabilities
node_shader_api -->|"indexes objects"| node_hash_helper

click node_gl_headers "https://github.com/ptitseb/gl4es/blob/master/include/GL/gl.h"
click node_api_wrappers "https://github.com/ptitseb/gl4es/blob/master/src/gl/wrap/gles.c"
click node_glx_entry "https://github.com/ptitseb/gl4es/blob/master/src/glx/glx.c"
click node_egl_entry "https://github.com/ptitseb/gl4es/blob/master/src/egl/egl.c"
click node_amiga "https://github.com/ptitseb/gl4es/blob/master/src/agl/amigaos.c"
click node_loader "https://github.com/ptitseb/gl4es/blob/master/src/gl/loader.h"
click node_capabilities "https://github.com/ptitseb/gl4es/blob/master/src/glx/hardext.c"
click node_state "https://github.com/ptitseb/gl4es/blob/master/src/gl/glstate.c"
click node_fixed_pipeline "https://github.com/ptitseb/gl4es/blob/master/src/gl/fpe.c"
click node_drawing "https://github.com/ptitseb/gl4es/blob/master/src/gl/drawing.c"
click node_textures "https://github.com/ptitseb/gl4es/blob/master/src/gl/texture.c"
click node_framebuffers "https://github.com/ptitseb/gl4es/blob/master/src/gl/framebuffers.c"
click node_shader_api "https://github.com/ptitseb/gl4es/blob/master/src/gl/program.c"
click node_shader_conversion "https://github.com/ptitseb/gl4es/blob/master/src/gl/shaderconv.c"
click node_arb_programs "https://github.com/ptitseb/gl4es/blob/master/src/gl/arbparser.c"
click node_gles_backend "https://github.com/ptitseb/gl4es/blob/master/src/gl/gles.h"
click node_hash_helper "https://github.com/ptitseb/gl4es/blob/master/include/khash.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_gl_headers,node_api_wrappers toneBlue
class node_state,node_fixed_pipeline,node_drawing,node_textures,node_framebuffers,node_hash_helper toneAmber
class node_shader_api,node_shader_conversion,node_arb_programs toneMint
class node_glx_entry,node_egl_entry,node_amiga,node_loader,node_capabilities,node_gles_backend toneRose
class node_application,node_gles_driver,node_egl_service toneIndigo
```

## Components

### Compatibility API

- [GL declarations](https://github.com/ptitseb/gl4es/blob/master/include/GL/gl.h): `include/GL/gl.h`
- [GL call wrappers](https://github.com/ptitseb/gl4es/blob/master/src/gl/wrap/gles.c): `src/gl/wrap/gles.c`

### OpenGL Emulation

- [GL state](https://github.com/ptitseb/gl4es/blob/master/src/gl/glstate.c): `src/gl/glstate.c`
- [Fixed pipeline emulation](https://github.com/ptitseb/gl4es/blob/master/src/gl/fpe.c): `src/gl/fpe.c`
- [Drawing and raster](https://github.com/ptitseb/gl4es/blob/master/src/gl/drawing.c): `src/gl/drawing.c`
- [Texture operations](https://github.com/ptitseb/gl4es/blob/master/src/gl/texture.c): `src/gl/texture.c`
- [Framebuffer operations](https://github.com/ptitseb/gl4es/blob/master/src/gl/framebuffers.c): `src/gl/framebuffers.c`
- [Hash tables](https://github.com/ptitseb/gl4es/blob/master/include/khash.h): `include/khash.h`

### Shader Support

- [Shader and program API](https://github.com/ptitseb/gl4es/blob/master/src/gl/program.c): `src/gl/program.c`
- [Shader conversion](https://github.com/ptitseb/gl4es/blob/master/src/gl/shaderconv.c): `src/gl/shaderconv.c`
- [ARB program conversion](https://github.com/ptitseb/gl4es/blob/master/src/gl/arbparser.c): `src/gl/arbparser.c`

### Context and Platform

- [GLX interface](https://github.com/ptitseb/gl4es/blob/master/src/glx/glx.c): `src/glx/glx.c`
- [EGL interface](https://github.com/ptitseb/gl4es/blob/master/src/egl/egl.c): `src/egl/egl.c`
- [Amiga interface](https://github.com/ptitseb/gl4es/blob/master/src/agl/amigaos.c): `src/agl/amigaos.c`
- [API loader](https://github.com/ptitseb/gl4es/blob/master/src/gl/loader.h): `src/gl/loader.h`
- [Hardware capabilities](https://github.com/ptitseb/gl4es/blob/master/src/glx/hardext.c): `src/glx/hardext.c`
- [GLES calls](https://github.com/ptitseb/gl4es/blob/master/src/gl/gles.h): `src/gl/gles.h`

### Other components

- **GL application**
- **GLES driver**
- **EGL implementation**

## Connections

- GL application → GL declarations: uses API
- GL application → GL call wrappers: calls
- GL call wrappers → GL state: updates state
- GL call wrappers → Fixed pipeline emulation: emulates calls
- GL call wrappers → Drawing and raster: dispatches draws
- GL call wrappers → Texture operations: handles textures
- GL call wrappers → Framebuffer operations: handles buffers
- Fixed pipeline emulation → Shader conversion: generates shaders
- Shader and program API → Shader conversion: converts shaders
- Shader and program API → ARB program conversion: accepts ARB programs
- Shader and program API → GLES calls: uses GLES programs (evidence: `src/gl/program.c`)
- ARB program conversion → Shader conversion: produces GLSL
- Fixed pipeline emulation → GLES calls: emits GLES calls
- Drawing and raster → GLES calls: renders through
- Texture operations → GLES calls: uses GLES calls
- Framebuffer operations → GLES calls: uses GLES calls
- GLES calls → GLES driver: dispatches calls
- GLX interface → EGL interface: uses EGL (evidence: `src/glx/glx.c`)
- GLX interface → API loader: loads APIs (evidence: `src/glx/glx.c`)
- EGL interface → API loader: loads APIs (evidence: `src/egl/egl.c`)
- API loader → GLES driver: loads symbols
- EGL interface → EGL implementation: calls EGL
- GLX interface → Hardware capabilities: checks extensions (evidence: `src/glx/glx.c`)
- Hardware capabilities → GLES calls: informs backend (evidence: `src/glx/hardext.c`)
- Amiga interface → Hardware capabilities: uses capabilities (evidence: `src/agl/amigaos.c`)
- Shader and program API → Hash tables: indexes objects (evidence: `src/gl/program.c`)
