# philosoph228/gdi-voxel-game architecture

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

- Interactive diagram: https://gitdiagram.com/philosoph228/gdi-voxel-game
- Repository: https://github.com/philosoph228/gdi-voxel-game

## Overview

WinCraft is an experimental WinAPI voxel game whose main workflow is Windows input and resize events entering GameState, updating the player and world, then drawing a CPU-rendered frame into a GDI backbuffer. The README also describes transforms, projection, clipping, triangle rasterization, voxel-world structure and experimental gameplay. Core engine behavior is concentrated in wincraft.c; its excerpts support the platform handoff and selected rendering and movement stages, but not every internal call. World-generation wiring is therefore shown conservatively.

Main entry points: [`launcher/main.c`](https://github.com/philosoph228/gdi-voxel-game/blob/main/launcher/main.c) (Window Launcher), [`wincraft.c`](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c) (Game State), [`perlin.c`](https://github.com/philosoph228/gdi-voxel-game/blob/main/perlin.c) (Terrain Noise), [`wincraft.h`](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.h) (World Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Windows Platform"]
  node_launcher["Window Launcher<br/>[main.c]"]
end

subgraph group_game["Game Runtime"]
  node_state["Game State<br/>[wincraft.c]"]
  node_input["Input Handling<br/>[wincraft.c]"]
  node_movement["Player Movement<br/>[wincraft.c]"]
  node_interaction["Block Interaction<br/>[wincraft.c]"]
end

subgraph group_world["Voxel World"]
  node_worlddata["World Data<br/>[wincraft.h]"]
  node_chunks["Chunk Management<br/>[wincraft.c]"]
  node_terrain["Terrain Noise<br/>[perlin.c]"]
  node_random["Random Generator<br/>[jrnd.h]"]
end

subgraph group_render["Software Rendering"]
  node_camera["Camera Transforms<br/>[wincraft.c]"]
  node_clip["Frustum Clipping<br/>[wincraft.c]"]
  node_raster["Triangle Rasterizer<br/>[wincraft.c]"]
  node_frame[("Frame Backbuffer<br/>[wincraft.c]")]
end

node_player(("Player"))
node_winapi(("WinAPI Events"))
node_gdi(("GDI Output"))

node_winapi -->|"dispatches"| node_launcher
node_launcher -->|"allocates"| node_state
node_launcher -->|"queues events"| node_input
node_launcher -->|"resizes"| node_state
node_player -->|"provides input"| node_launcher
node_launcher -->|"requests draw"| node_state
node_state -->|"processes events"| node_input
node_state -->|"updates"| node_movement
node_movement -->|"ensures nearby"| node_chunks
node_interaction -->|"reads and edits"| node_worlddata
node_state -->|"uses camera"| node_camera
node_camera -->|"transforms geometry"| node_clip
node_clip -->|"passes triangles"| node_raster
node_raster -->|"writes pixels"| node_frame
node_launcher -->|"reads backbuffer"| node_frame
node_frame -->|"blits frame"| node_gdi
node_terrain -->|"uses RNG"| node_random

click node_launcher "https://github.com/philosoph228/gdi-voxel-game/blob/main/launcher/main.c"
click node_state "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_input "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_movement "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_interaction "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_worlddata "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.h"
click node_chunks "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_terrain "https://github.com/philosoph228/gdi-voxel-game/blob/main/perlin.c"
click node_random "https://github.com/philosoph228/gdi-voxel-game/blob/main/jrnd.h"
click node_camera "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_clip "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_raster "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"
click node_frame "https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c"

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_launcher toneBlue
class node_state,node_input,node_movement,node_interaction toneAmber
class node_worlddata,node_chunks,node_terrain,node_random,node_winapi toneMint
class node_camera,node_clip,node_raster,node_frame toneRose
class node_player,node_gdi toneIndigo
```

## Components

### Windows Platform

- [Window Launcher](https://github.com/philosoph228/gdi-voxel-game/blob/main/launcher/main.c): `launcher/main.c`

### Game Runtime

- [Game State](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`
- [Input Handling](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`
- [Player Movement](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`
- [Block Interaction](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`

### Voxel World

- [World Data](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.h): `wincraft.h`
- [Chunk Management](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`
- [Terrain Noise](https://github.com/philosoph228/gdi-voxel-game/blob/main/perlin.c): `perlin.c`
- [Random Generator](https://github.com/philosoph228/gdi-voxel-game/blob/main/jrnd.h): `jrnd.h`

### Software Rendering

- [Camera Transforms](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`
- [Frustum Clipping](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`
- [Triangle Rasterizer](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`
- [Frame Backbuffer](https://github.com/philosoph228/gdi-voxel-game/blob/main/wincraft.c): `wincraft.c`

### Other components

- **Player**
- **WinAPI Events**
- **GDI Output**

## Connections

- WinAPI Events → Window Launcher: dispatches
- Window Launcher → Game State: allocates
- Window Launcher → Input Handling: queues events
- Window Launcher → Game State: resizes
- Player → Window Launcher: provides input
- Window Launcher → Game State: requests draw
- Game State → Input Handling: processes events
- Game State → Player Movement: updates
- Player Movement → Chunk Management: ensures nearby
- Block Interaction → World Data: reads and edits
- Game State → Camera Transforms: uses camera
- Camera Transforms → Frustum Clipping: transforms geometry
- Frustum Clipping → Triangle Rasterizer: passes triangles
- Triangle Rasterizer → Frame Backbuffer: writes pixels
- Window Launcher → Frame Backbuffer: reads backbuffer
- Frame Backbuffer → GDI Output: blits frame
- Terrain Noise → Random Generator: uses RNG
