# phoboslab/wipeout-rewrite architecture

> Architecture diagram of the GitHub repository phoboslab/wipeout-rewrite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phoboslab/wipeout-rewrite
- Repository: https://github.com/phoboslab/wipeout-rewrite

## Overview

##### Main System Components

a) Platform Layer
- Create two parallel tracks showing the dual platform backends (SDL2 and Sokol)
- Platform-specific components (input, audio, window management)
- OpenGL rendering capabilities (GL 2.x for SDL2, GL 3.3 for Sokol)

b) Core Engine Layer
- Rendering System (render_gl.c, render_software.c)
- Memory Management (mem.c)
- Input System (input.c)
- System Management (system.c)
- Utility Functions (utils.c)

c) Game Logic Layer
- Game State Management (game.c)
- Scene Management (scene.c)
- Physics and Collision
- AI Systems (ship_ai.c)
- Particle Systems (particle.c)

d) Asset Management
- Image Loading
- Sound Management (sfx.c)
- Track Loading (track.c)
- Model Management (object.c)

##### Specific Implementation Details

**[Platform Layer]**
- SDL2 Backend
- OpenGL 2.x
- Sokol Backend
- OpenGL 3.3

**[Core Systems]**
- Memory Manager
- Renderer
- Input Handler

**[Game Systems]**
- Ship Management
- Player Ships
- AI Ships
- Race Management
- Weapons
- Camera

**[UI Systems]**
- HUD
- Menus
- User Interface

##### Technical Details to Highlight

- Rendering pipeline options (GL vs Software)
- Audio system (QOA format support)
- Platform-specific features (e.g., controller support in SDL2)
- Build configuration options

##### Notes for Implementation Details

Callouts for:
- Memory management strategy
- Asset loading paths
- Save data handling
- Platform-specific optimizations
- WASM/Emscripten considerations

- Nested components
- Proper layering
- Export to high-resolution formats

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style definitions
    classDef platform fill:#lightblue
    classDef core fill:#90EE90
    classDef game fill:#FFFF99
    classDef ui fill:#FFA07A
    classDef asset fill:#DDA0DD
    classDef external fill:#D3D3D3

    %% Platform Layer
    subgraph PlatformLayer["Platform Layer"]
        SDL["SDL2 Backend\nOpenGL 2.x"]
        Sokol["Sokol Backend\nOpenGL 3.3"]
    end

    %% Core Engine Layer
    subgraph CoreLayer["Core Engine Layer"]
        RenderSystem["Rendering System"]
        MemSystem["Memory Management"]
        InputSystem["Input System"]
        SysManagement["System Management"]
        Utils["Utility Functions"]
    end

    %% Game Logic Layer
    subgraph GameLayer["Game Logic Layer"]
        GameState["Game State"]
        SceneMan["Scene Management"]
        Physics["Physics & Collision"]
        ShipAI["Ship AI"]
        ParticleSystem["Particle System"]
        Camera["Camera System"]
        Race["Race Management"]
        Weapons["Weapon System"]
    end

    %% Asset Management
    subgraph AssetLayer["Asset Management"]
        ImageLoader["Image Loading"]
        SoundMan["Sound Management"]
        TrackLoader["Track Loading"]
        ModelMan["Model Management"]
    end

    %% UI Systems
    subgraph UILayer["UI Layer"]
        MainUI["Main UI"]
        HUD["HUD"]
        MenuSystem["Menu System"]
        MainMenu["Main Menu"]
        InGameMenus["In-game Menus"]
        TitleScreen["Title Screen"]
        Intro["Intro Sequence"]
    end

    %% External Libraries
    subgraph ExternalLibs["External Libraries"]
        MediaPlayback["Media Playback"]
        QOA["QOA Audio"]
        SokolLibs["Sokol Libraries"]
    end

    %% Relationships
    SDL & Sokol --> RenderSystem
    RenderSystem --> MemSystem
    InputSystem --> GameState
    SysManagement --> GameState
    GameState --> SceneMan
    SceneMan --> Physics
    Physics --> ShipAI
    Physics --> ParticleSystem
    GameState --> Camera
    GameState --> Race
    Race --> Weapons
    AssetLayer --> GameLayer
    GameLayer --> UILayer
    ExternalLibs --> CoreLayer

    %% Click events for component mapping
    click SDL "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/platform_sdl.c"
    click Sokol "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/platform_sokol.c"
    click RenderSystem "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/render_gl.c"
    click MemSystem "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/mem.c"
    click InputSystem "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/input.c"
    click SysManagement "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/system.c"
    click Utils "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/utils.c"
    click GameState "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/game.c"
    click SceneMan "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/scene.c"
    click ShipAI "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/ship_ai.c"
    click ParticleSystem "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/particle.c"
    click Camera "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/camera.c"
    click Race "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/race.c"
    click Weapons "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/weapon.c"
    click ImageLoader "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/image.c"
    click SoundMan "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/sfx.c"
    click TrackLoader "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/track.c"
    click ModelMan "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/object.c"
    click MainUI "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/ui.c"
    click HUD "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/hud.c"
    click MenuSystem "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/menu.c"
    click MainMenu "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/main_menu.c"
    click InGameMenus "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/ingame_menus.c"
    click TitleScreen "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/title.c"
    click Intro "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/wipeout/intro.c"
    click MediaPlayback "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/libs/pl_mpeg.h"
    click QOA "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/libs/qoa.h"
    click SokolLibs "https://github.com/phoboslab/wipeout-rewrite/blob/master/src/libs/sokol_app.h"

    %% Style applications
    class SDL,Sokol platform
    class RenderSystem,MemSystem,InputSystem,SysManagement,Utils core
    class GameState,SceneMan,Physics,ShipAI,ParticleSystem,Camera,Race,Weapons game
    class MainUI,HUD,MenuSystem,MainMenu,InGameMenus,TitleScreen,Intro ui
    class ImageLoader,SoundMan,TrackLoader,ModelMan asset
    class MediaPlayback,QOA,SokolLibs external
```
