# awss1236/gpu-raytracer architecture

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

- Interactive diagram: https://gitdiagram.com/awss1236/gpu-raytracer
- Repository: https://github.com/awss1236/gpu-raytracer

## Overview

This is a small interactive OpenGL raytracer. The user launches the app and steers its camera; `main.c` initializes the window and repeatedly renders a raytraced frame, updates a running average, and displays the result. `back.c` supplies GLFW setup, input handling, and shader-file loading/linking. The shader roles and render-pass order are evident from filenames and `main.c`; shader internals were not sampled, so no claims about raytracing algorithms or scene contents are made.

Main entry points: [`main.c`](https://github.com/awss1236/gpu-raytracer/blob/master/main.c) (Render Loop), [`back.c`](https://github.com/awss1236/gpu-raytracer/blob/master/back.c) (GLFW and Shaders), [`average.glsl`](https://github.com/awss1236/gpu-raytracer/blob/master/average.glsl) (Average Pass), [`raytrace.glsl`](https://github.com/awss1236/gpu-raytracer/blob/master/raytrace.glsl) (Raytrace Pass)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Render Loop<br/>[main.c]"]
end

subgraph group_gpu["GPU Passes"]
  node_gpu_frames[("Frame Textures<br/>[main.c]")]
  node_raytrace["Raytrace Pass<br/>[raytrace.glsl]"]
  node_average["Average Pass<br/>[average.glsl]"]
  node_display["Display Pass<br/>[passtex.glsl]"]
  node_fullscreen["Pass Vertex Shader<br/>[pass.glsl]"]
end

subgraph group_support["Window Support"]
  node_back["GLFW and Shaders<br/>[back.c]"]
end

node_user(("User"))
node_glfw["GLFW"]
node_gl["OpenGL"]

node_user -->|"launches"| node_main
node_user -->|"steers camera"| node_glfw
node_glfw -->|"dispatches input"| node_back
node_main -->|"initializes and loads"| node_back
node_back -->|"creates window"| node_glfw
node_back -->|"sets up context"| node_gl
node_main -->|"polls events"| node_glfw
node_main -->|"dispatches draws"| node_gl
node_main -->|"runs pass"| node_raytrace
node_main -->|"runs pass"| node_average
node_main -->|"runs pass"| node_display
node_main -->|"uses vertex stage"| node_fullscreen
node_raytrace -->|"writes new frame"| node_gpu_frames
node_gpu_frames -->|"provides frame inputs"| node_average
node_average -->|"updates average"| node_gpu_frames
node_gpu_frames -->|"provides current image"| node_display
node_main -->|"copies and binds textures"| node_gpu_frames

click node_main "https://github.com/awss1236/gpu-raytracer/blob/master/main.c"
click node_back "https://github.com/awss1236/gpu-raytracer/blob/master/back.c"
click node_gpu_frames "https://github.com/awss1236/gpu-raytracer/blob/master/main.c"
click node_raytrace "https://github.com/awss1236/gpu-raytracer/blob/master/raytrace.glsl"
click node_average "https://github.com/awss1236/gpu-raytracer/blob/master/average.glsl"
click node_display "https://github.com/awss1236/gpu-raytracer/blob/master/passtex.glsl"
click node_fullscreen "https://github.com/awss1236/gpu-raytracer/blob/master/pass.glsl"

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_main,node_user toneBlue
class node_gpu_frames,node_raytrace,node_average,node_display,node_fullscreen toneAmber
class node_back toneMint
class node_glfw,node_gl toneIndigo
```

## Components

### Application

- [Render Loop](https://github.com/awss1236/gpu-raytracer/blob/master/main.c): `main.c`

### GPU Passes

- [Frame Textures](https://github.com/awss1236/gpu-raytracer/blob/master/main.c): `main.c`
- [Raytrace Pass](https://github.com/awss1236/gpu-raytracer/blob/master/raytrace.glsl): `raytrace.glsl`
- [Average Pass](https://github.com/awss1236/gpu-raytracer/blob/master/average.glsl): `average.glsl`
- [Display Pass](https://github.com/awss1236/gpu-raytracer/blob/master/passtex.glsl): `passtex.glsl`
- [Pass Vertex Shader](https://github.com/awss1236/gpu-raytracer/blob/master/pass.glsl): `pass.glsl`

### Window Support

- [GLFW and Shaders](https://github.com/awss1236/gpu-raytracer/blob/master/back.c): `back.c`

### Other components

- **User**
- **GLFW**
- **OpenGL**

## Connections

- User → Render Loop: launches
- User → GLFW: steers camera
- GLFW → GLFW and Shaders: dispatches input
- Render Loop → GLFW and Shaders: initializes and loads
- GLFW and Shaders → GLFW: creates window
- GLFW and Shaders → OpenGL: sets up context
- Render Loop → GLFW: polls events
- Render Loop → OpenGL: dispatches draws
- Render Loop → Raytrace Pass: runs pass
- Render Loop → Average Pass: runs pass
- Render Loop → Display Pass: runs pass
- Render Loop → Pass Vertex Shader: uses vertex stage
- Raytrace Pass → Frame Textures: writes new frame
- Frame Textures → Average Pass: provides frame inputs
- Average Pass → Frame Textures: updates average
- Frame Textures → Display Pass: provides current image
- Render Loop → Frame Textures: copies and binds textures
