# murray2k6/gldirect architecture

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

- Interactive diagram: https://gitdiagram.com/murray2k6/gldirect
- Repository: https://github.com/murray2k6/gldirect

## Overview

GLDirect is a Windows OpenGL DLL wrapper whose normal workflow accepts an application's WGL context and OpenGL calls, translates supported work into a D3D9 command stream, and submits it to the active D3D9 implementation. OpenGL stages D3D9 cannot represent run in a private Mesa worker; their results are synchronized into the D3D9 stream. The graph preserves the documented fixed-function, shader, resource, advanced-stage, and Remix paths. Most links rely on README statements; sampled source excerpts establish context management and Mesa pipeline behavior, but do not expose the complete runtime call graph.

Main entry points: [`src/dx9/gld5_driver.c`](https://github.com/murray2k6/gldirect/blob/master/src/dx9/gld5_driver.c) (D3D9 Driver), [`src/gl46/gl_impl.c`](https://github.com/murray2k6/gldirect/blob/master/src/gl46/gl_impl.c) (GL API Dispatch), [`src/mesa_proxy.c`](https://github.com/murray2k6/gldirect/blob/master/src/mesa_proxy.c) (Mesa Worker), [`src/gld_wgl.c`](https://github.com/murray2k6/gldirect/blob/master/src/gld_wgl.c) (WGL Context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Windows Entry"]
  node_dll["OpenGL DLL<br/>[dll_main.c]"]
  node_wgl["WGL Context<br/>[gld_wgl.c]"]
  node_context["Context State<br/>[gld_context.c]"]
  node_glapi["GL API Dispatch<br/>[gl_impl.c]"]
end

subgraph group_translation["GL Translation"]
  node_fixed["Fixed Function"]
  node_shader["Shader Translation<br/>[glsl_to_hlsl.c]"]
  node_state["State Translation<br/>[state_translator.c]"]
  node_buffers["Buffer Manager<br/>[buffer_manager.c]"]
  node_textures["Texture Manager<br/>[texture_manager.c]"]
  node_targets["Render Targets"]
end

subgraph group_execution["Execution Paths"]
  node_advanced["Advanced Emulation"]
  node_compute["Compute Emulation<br/>[compute_emulator.c]"]
  node_mesa["Mesa Worker<br/>[mesa_proxy.c]"]
  node_mesa_tnl["Mesa TNL Pipeline<br/>[t_pipeline.c]"]
end

subgraph group_integration["D3D9 Integration"]
  node_dx9["D3D9 Driver<br/>[gld5_driver.c]"]
  node_swap["Swap Chain<br/>[swap_chain.c]"]
end

subgraph group_operations["Diagnostics"]
  node_profiler["Tracy Client<br/>[tracy_client.cpp]"]
end

node_app(("GL Application"))
node_remix["D3D9 Runtime"]

node_app -->|"calls OpenGL"| node_dll
node_dll -->|"exports WGL"| node_wgl
node_wgl -->|"creates and binds"| node_context
node_app -->|"issues GL calls"| node_glapi
node_glapi -->|"translates fixed state"| node_fixed
node_glapi -->|"translates GLSL"| node_shader
node_glapi -.->|"translates state"| node_state
node_glapi -.->|"manages buffers"| node_buffers
node_glapi -.->|"manages textures"| node_textures
node_glapi -.->|"manages targets"| node_targets
node_fixed -->|"emits D3D9 draws"| node_dx9
node_shader -->|"emits shaders"| node_dx9
node_state -->|"sets D3D9 state"| node_dx9
node_buffers -->|"submits geometry"| node_dx9
node_textures -.->|"submits resources"| node_dx9
node_targets -.->|"binds render targets"| node_dx9
node_glapi -->|"dispatches unsupported stages"| node_advanced
node_advanced -->|"executes post-vertex work"| node_mesa
node_compute -->|"executes compute"| node_mesa
node_mesa -.->|"runs Mesa pipeline"| node_mesa_tnl
node_mesa -->|"submits results"| node_dx9
node_compute -->|"syncs writable resources"| node_dx9
node_dx9 -->|"sends D3D9 stream"| node_remix
node_dx9 -.->|"presents frames"| node_swap
node_wgl -->|"starts profiling"| node_profiler

click node_dll "https://github.com/murray2k6/gldirect/blob/master/src/dll_main.c"
click node_wgl "https://github.com/murray2k6/gldirect/blob/master/src/gld_wgl.c"
click node_context "https://github.com/murray2k6/gldirect/blob/master/src/gld_context.c"
click node_glapi "https://github.com/murray2k6/gldirect/blob/master/src/gl46/gl_impl.c"
click node_fixed "https://github.com/murray2k6/gldirect/blob/master/src/gl46/fixed_function_emulator.c"
click node_shader "https://github.com/murray2k6/gldirect/blob/master/src/gl46/glsl_to_hlsl.c"
click node_state "https://github.com/murray2k6/gldirect/blob/master/src/gl46/state_translator.c"
click node_buffers "https://github.com/murray2k6/gldirect/blob/master/src/gl46/buffer_manager.c"
click node_textures "https://github.com/murray2k6/gldirect/blob/master/src/gl46/texture_manager.c"
click node_targets "https://github.com/murray2k6/gldirect/blob/master/src/gl46/render_target_manager.c"
click node_advanced "https://github.com/murray2k6/gldirect/blob/master/src/gl46/advanced_emulation.c"
click node_compute "https://github.com/murray2k6/gldirect/blob/master/src/gl46/compute_emulator.c"
click node_mesa "https://github.com/murray2k6/gldirect/blob/master/src/mesa_proxy.c"
click node_mesa_tnl "https://github.com/murray2k6/gldirect/blob/master/mesa/src/mesa/tnl/t_pipeline.c"
click node_dx9 "https://github.com/murray2k6/gldirect/blob/master/src/dx9/gld5_driver.c"
click node_swap "https://github.com/murray2k6/gldirect/blob/master/src/gl46/swap_chain.c"
click node_profiler "https://github.com/murray2k6/gldirect/blob/master/src/tracy_client.cpp"

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_dll,node_wgl,node_context,node_glapi toneBlue
class node_fixed,node_shader,node_state,node_buffers,node_textures,node_targets toneAmber
class node_advanced,node_compute,node_mesa,node_mesa_tnl toneMint
class node_dx9,node_swap toneRose
class node_profiler,node_app,node_remix toneIndigo
```

## Components

### Windows Entry

- [OpenGL DLL](https://github.com/murray2k6/gldirect/blob/master/src/dll_main.c): `src/dll_main.c`
- [WGL Context](https://github.com/murray2k6/gldirect/blob/master/src/gld_wgl.c): `src/gld_wgl.c`
- [Context State](https://github.com/murray2k6/gldirect/blob/master/src/gld_context.c): `src/gld_context.c`
- [GL API Dispatch](https://github.com/murray2k6/gldirect/blob/master/src/gl46/gl_impl.c): `src/gl46/gl_impl.c`

### GL Translation

- [Fixed Function](https://github.com/murray2k6/gldirect/blob/master/src/gl46/fixed_function_emulator.c): `src/gl46/fixed_function_emulator.c`
- [Shader Translation](https://github.com/murray2k6/gldirect/blob/master/src/gl46/glsl_to_hlsl.c): `src/gl46/glsl_to_hlsl.c`
- [State Translation](https://github.com/murray2k6/gldirect/blob/master/src/gl46/state_translator.c): `src/gl46/state_translator.c`
- [Buffer Manager](https://github.com/murray2k6/gldirect/blob/master/src/gl46/buffer_manager.c): `src/gl46/buffer_manager.c`
- [Texture Manager](https://github.com/murray2k6/gldirect/blob/master/src/gl46/texture_manager.c): `src/gl46/texture_manager.c`
- [Render Targets](https://github.com/murray2k6/gldirect/blob/master/src/gl46/render_target_manager.c): `src/gl46/render_target_manager.c`

### Execution Paths

- [Advanced Emulation](https://github.com/murray2k6/gldirect/blob/master/src/gl46/advanced_emulation.c): `src/gl46/advanced_emulation.c`
- [Compute Emulation](https://github.com/murray2k6/gldirect/blob/master/src/gl46/compute_emulator.c): `src/gl46/compute_emulator.c`
- [Mesa Worker](https://github.com/murray2k6/gldirect/blob/master/src/mesa_proxy.c): `src/mesa_proxy.c`
- [Mesa TNL Pipeline](https://github.com/murray2k6/gldirect/blob/master/mesa/src/mesa/tnl/t_pipeline.c): `mesa/src/mesa/tnl/t_pipeline.c`

### D3D9 Integration

- [D3D9 Driver](https://github.com/murray2k6/gldirect/blob/master/src/dx9/gld5_driver.c): `src/dx9/gld5_driver.c`
- [Swap Chain](https://github.com/murray2k6/gldirect/blob/master/src/gl46/swap_chain.c): `src/gl46/swap_chain.c`

### Diagnostics

- [Tracy Client](https://github.com/murray2k6/gldirect/blob/master/src/tracy_client.cpp): `src/tracy_client.cpp`

### Other components

- **GL Application**
- **D3D9 Runtime**

## Connections

- GL Application → OpenGL DLL: calls OpenGL
- OpenGL DLL → WGL Context: exports WGL
- WGL Context → Context State: creates and binds
- GL Application → GL API Dispatch: issues GL calls
- GL API Dispatch → Fixed Function: translates fixed state
- GL API Dispatch → Shader Translation: translates GLSL
- GL API Dispatch → State Translation: translates state
- GL API Dispatch → Buffer Manager: manages buffers
- GL API Dispatch → Texture Manager: manages textures
- GL API Dispatch → Render Targets: manages targets
- Fixed Function → D3D9 Driver: emits D3D9 draws
- Shader Translation → D3D9 Driver: emits shaders
- State Translation → D3D9 Driver: sets D3D9 state
- Buffer Manager → D3D9 Driver: submits geometry
- Texture Manager → D3D9 Driver: submits resources
- Render Targets → D3D9 Driver: binds render targets
- GL API Dispatch → Advanced Emulation: dispatches unsupported stages
- Advanced Emulation → Mesa Worker: executes post-vertex work
- Compute Emulation → Mesa Worker: executes compute
- Mesa Worker → Mesa TNL Pipeline: runs Mesa pipeline
- Mesa Worker → D3D9 Driver: submits results
- Compute Emulation → D3D9 Driver: syncs writable resources
- D3D9 Driver → D3D9 Runtime: sends D3D9 stream
- D3D9 Driver → Swap Chain: presents frames
- WGL Context → Tracy Client: starts profiling
