# adskeptik/kgui architecture

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

- Interactive diagram: https://gitdiagram.com/adskeptik/kgui
- Repository: https://github.com/adskeptik/kgui

## Overview

This is a Windows C++ GUI and graphics-context library. Its intended user workflow is to create a window, run its message loop, and use a renderer window’s OpenGL context; the renderer abstraction also leaves room for other graphics APIs, but DirectX is only a stub in the sampled files. The graph includes the shader abstraction and OpenGL shader specialization as a separate capability. Source excerpts establish the window and OpenGL foundations, but do not show the renderer-window implementation or a complete shader workflow.

Main entry points: [`K_Window.cpp`](https://github.com/adskeptik/kgui/blob/main/K_Window.cpp) (Window base), [`OpenGL/K_OpenGL_Context.cpp`](https://github.com/adskeptik/kgui/blob/main/OpenGL/K_OpenGL_Context.cpp) (OpenGL context), [`K_Renderer_Context.cpp`](https://github.com/adskeptik/kgui/blob/main/K_Renderer_Context.cpp) (Renderer abstraction), [`K_RendererWindow.cpp`](https://github.com/adskeptik/kgui/blob/main/K_RendererWindow.cpp) (Renderer window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_windows["Windowing"]
  node_window["Window base<br/>[K_Window.cpp]"]
  node_custom_window["Custom window loop<br/>[CustomWindow.cpp]"]
end

subgraph group_rendering["Rendering"]
  node_renderer_window["Renderer window"]
  node_renderer_context["Renderer abstraction"]
  node_opengl_context["OpenGL context"]
  node_custom_gl["Custom GL context"]
  node_directx_context["DirectX context stub<br/>[K_DXContext.cpp]"]
end

subgraph group_shaders["Shaders"]
  node_shader_base["Shader abstraction<br/>[K_Shader.cpp]"]
  node_opengl_shader["OpenGL shader"]
end

node_developer(("Library user"))
node_win32["Windows API"]
node_opengl["OpenGL / WGL"]

node_developer -.->|"creates"| node_window
node_window -->|"creates windows"| node_win32
node_custom_window -->|"extends"| node_window
node_renderer_window -->|"extends"| node_custom_window
node_renderer_window -->|"owns context"| node_custom_gl
node_custom_gl -->|"extends"| node_opengl_context
node_opengl_context -->|"extends"| node_renderer_context
node_renderer_context -->|"gets window handle"| node_window
node_opengl_context -->|"loads functions"| node_opengl
node_directx_context -.->|"implements API"| node_renderer_context
node_opengl_shader -->|"extends"| node_shader_base

click node_window "https://github.com/adskeptik/kgui/blob/main/K_Window.cpp"
click node_custom_window "https://github.com/adskeptik/kgui/blob/main/CustomWindow.cpp"
click node_renderer_window "https://github.com/adskeptik/kgui/blob/main/K_RendererWindow.cpp"
click node_renderer_context "https://github.com/adskeptik/kgui/blob/main/K_Renderer_Context.cpp"
click node_opengl_context "https://github.com/adskeptik/kgui/blob/main/OpenGL/K_OpenGL_Context.cpp"
click node_custom_gl "https://github.com/adskeptik/kgui/blob/main/OpenGL/CustomOpenGLContext.cpp"
click node_directx_context "https://github.com/adskeptik/kgui/blob/main/DX/K_DXContext.cpp"
click node_shader_base "https://github.com/adskeptik/kgui/blob/main/K_Shader.cpp"
click node_opengl_shader "https://github.com/adskeptik/kgui/blob/main/K_Shader_OpenGL.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_window,node_custom_window,node_developer toneBlue
class node_renderer_window,node_renderer_context,node_opengl_context,node_custom_gl,node_directx_context toneAmber
class node_shader_base,node_opengl_shader,node_win32 toneMint
class node_opengl toneIndigo
```

## Components

### Windowing

- [Window base](https://github.com/adskeptik/kgui/blob/main/K_Window.cpp): `K_Window.cpp`
- [Custom window loop](https://github.com/adskeptik/kgui/blob/main/CustomWindow.cpp): `CustomWindow.cpp`

### Rendering

- [Renderer window](https://github.com/adskeptik/kgui/blob/main/K_RendererWindow.cpp): `K_RendererWindow.cpp`
- [Renderer abstraction](https://github.com/adskeptik/kgui/blob/main/K_Renderer_Context.cpp): `K_Renderer_Context.cpp`
- [OpenGL context](https://github.com/adskeptik/kgui/blob/main/OpenGL/K_OpenGL_Context.cpp): `OpenGL/K_OpenGL_Context.cpp`
- [Custom GL context](https://github.com/adskeptik/kgui/blob/main/OpenGL/CustomOpenGLContext.cpp): `OpenGL/CustomOpenGLContext.cpp`
- [DirectX context stub](https://github.com/adskeptik/kgui/blob/main/DX/K_DXContext.cpp): `DX/K_DXContext.cpp`

### Shaders

- [Shader abstraction](https://github.com/adskeptik/kgui/blob/main/K_Shader.cpp): `K_Shader.cpp`
- [OpenGL shader](https://github.com/adskeptik/kgui/blob/main/K_Shader_OpenGL.cpp): `K_Shader_OpenGL.cpp`

### Other components

- **Library user**
- **Windows API**
- **OpenGL / WGL**

## Connections

- Library user → Window base: creates
- Window base → Windows API: creates windows (evidence: `K_Window.cpp`)
- Custom window loop → Window base: extends
- Renderer window → Custom window loop: extends
- Renderer window → Custom GL context: owns context
- Custom GL context → OpenGL context: extends
- OpenGL context → Renderer abstraction: extends
- Renderer abstraction → Window base: gets window handle (evidence: `K_Renderer_Context.cpp`)
- OpenGL context → OpenGL / WGL: loads functions (evidence: `OpenGL/K_OpenGL_Context.cpp`)
- DirectX context stub → Renderer abstraction: implements API
- OpenGL shader → Shader abstraction: extends
