# vanshilshah97/graphics_rasterizer architecture

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

- Interactive diagram: https://gitdiagram.com/vanshilshah97/graphics_rasterizer
- Repository: https://github.com/vanshilshah97/graphics_rasterizer

## Overview

#### Purpose and Entry Points
This is a Qt/C++ desktop rasterizer project. It loads predefined 2D/3D scenes and renders polygonal geometry through a custom software rasterization pipeline. Application startup is `main.cpp`; the main UI/controller is `mainwindow.cpp` and `mainwindow.h`, with Qt layout and widget bindings in `mainwindow.ui`.

#### UI and Render Orchestration
`MainWindow` owns user-driven scene selection and render/display control, bridging Qt events to the rasterizer. The principal boundary is GUI code versus rendering/model code: UI should request scene loading or redraws, while rendering state and pixel generation belong below it.
Paths: `mainwindow.cpp`, `mainwindow.h`, `mainwindow.ui`.

#### Rasterization Pipeline
The custom rendering engine is centered on the rasterizer component. It likely receives polygon/mesh data, applies the selected 2D or 3D rendering path, and produces the image consumed by the Qt presentation layer. This is the core computational boundary; it is independent of the scene assets and should avoid UI-specific policy.
Paths: `rasterizer.cpp`, `rasterizer.h`, `polygon.cpp`.

#### Geometry Model
`Polygon` represents renderable polygon geometry and is the handoff format between scene parsing and rasterization. 2D JSON scenes and imported 3D meshes must be normalized into this model or equivalent rasterizer inputs. Geometry operations depend on the bundled GLM types for vectors, matrices, transforms, and related math.
Paths: `polygon.h`, `polygon.cpp`, `include/glm/glm.hpp`.

#### Scene and Asset Ingestion
The repository ships scene descriptors under `scenes/`, covering 2D polygons and 3D models. JSON files select or describe scenes; Wavefront OBJ assets provide mesh geometry, while MTL/BMP files provide material/texture-related inputs. OBJ parsing is supplied locally by TinyObjLoader rather than an external runtime dependency.
Paths: `scenes/3D_cube.json`, `scenes/wahoo.obj`, `tiny_obj_loader.h`.

#### Math and Transform Layer
GLM is vendored as headers under `include/glm`, making the project largely self-contained for graphics math. Core vector/matrix types underpin vertex positions, transformations, projection, and geometric operations; extension headers support quaternions, transforms, packing, and matrix utilities when used by the renderer.
Paths: `include/glm/matrix.hpp`, `include/glm/gtc/matrix_transform.hpp`, `include/glm/gtc/quaternion.hpp`.

#### Build and Runtime Dependencies
The Qt qmake project definition is `rasterizer.pro`; the runtime is a native C++ Qt desktop executable, not a service or web application. Material dependencies are Qt for UI/image display, TinyObjLoader for OBJ import, and bundled GLM for math. There are no indicated network services, databases, or cloud infrastructure.
Paths: `rasterizer.pro`, `tiny_obj_loader.cc`, `include/glm/CMakeLists.txt`.

Main entry points: [`rasterizer.cpp`](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/rasterizer.cpp) (Rasterizer), [`mainwindow.cpp`](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/mainwindow.cpp) (Main window), [`polygon.cpp`](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/polygon.cpp) (Polygon geometry), [`include/glm/glm.hpp`](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/glm.hpp) (GLM core math)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop app"]
  node_build["qmake project<br/>build definition<br/>[rasterizer.pro]"]
  node_main["Application startup<br/>C++ entry point<br/>[main.cpp]"]
  node_ui["Main window<br/>Qt controller<br/>[mainwindow.cpp]"]
  node_ui_header["Main window API<br/>Qt header<br/>[mainwindow.h]"]
  node_ui_layout["Window layout<br/>Qt UI form<br/>[mainwindow.ui]"]
end

subgraph group_render["Software rendering"]
  node_rasterizer["Rasterizer<br/>software renderer<br/>[rasterizer.cpp]"]
  node_rasterizer_api["Rasterizer API<br/>renderer header<br/>[rasterizer.h]"]
  node_polygon["Polygon geometry<br/>render model<br/>[polygon.cpp]"]
  node_polygon_api["Polygon API<br/>model header<br/>[polygon.h]"]
end

subgraph group_assets["Scenes and assets"]
  node_scene_json["Scene descriptors<br/>JSON scene asset<br/>[3D_cube.json]"]
  node_obj_mesh["OBJ mesh asset<br/>Wavefront mesh<br/>[wahoo.obj]"]
end

subgraph group_deps["Bundled dependencies"]
  node_obj_loader["TinyObjLoader<br/>OBJ importer<br/>[tiny_obj_loader.h]"]
  node_obj_loader_impl["TinyObjLoader implementation<br/>C++ implementation<br/>[tiny_obj_loader.cc]"]
  node_glm_core["GLM core math<br/>header-only math<br/>[glm.hpp]"]
  node_glm_matrix["GLM transforms<br/>math extension"]
  node_glm_quaternion["GLM quaternions<br/>math extension<br/>[quaternion.hpp]"]
  node_glm_build["GLM package metadata<br/>CMake definition<br/>[CMakeLists.txt]"]
end

node_build -->|"builds"| node_main
node_main -->|"starts"| node_ui
node_ui -->|"implements"| node_ui_header
node_ui_layout -->|"binds widgets"| node_ui
node_ui -->|"selects/loads"| node_scene_json
node_ui -->|"requests render"| node_rasterizer_api
node_rasterizer -->|"implements"| node_rasterizer_api
node_rasterizer -->|"consumes"| node_polygon_api
node_polygon -->|"implements"| node_polygon_api
node_scene_json -->|"defines 2D/3D geometry"| node_polygon
node_obj_mesh -->|"parsed by"| node_obj_loader
node_obj_loader_impl -->|"implements"| node_obj_loader
node_obj_loader -->|"imports mesh into"| node_polygon
node_polygon -->|"render input"| node_rasterizer
node_rasterizer -->|"pixel image"| node_ui
node_polygon -->|"uses vectors"| node_glm_core
node_rasterizer -->|"applies transforms"| node_glm_matrix
node_rasterizer -.->|"uses rotations"| node_glm_quaternion
node_glm_matrix -->|"extends"| node_glm_core
node_glm_quaternion -->|"extends"| node_glm_core
node_glm_build -.->|"packages"| node_glm_core

click node_build "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/rasterizer.pro"
click node_main "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/main.cpp"
click node_ui "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/mainwindow.cpp"
click node_ui_header "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/mainwindow.h"
click node_ui_layout "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/mainwindow.ui"
click node_rasterizer "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/rasterizer.cpp"
click node_rasterizer_api "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/rasterizer.h"
click node_polygon "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/polygon.cpp"
click node_polygon_api "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/polygon.h"
click node_scene_json "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/scenes/3D_cube.json"
click node_obj_mesh "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/scenes/wahoo.obj"
click node_obj_loader "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/tiny_obj_loader.h"
click node_obj_loader_impl "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/tiny_obj_loader.cc"
click node_glm_core "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/glm.hpp"
click node_glm_matrix "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/gtc/matrix_transform.hpp"
click node_glm_quaternion "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/gtc/quaternion.hpp"
click node_glm_build "https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/CMakeLists.txt"

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_build,node_main,node_ui,node_ui_header,node_ui_layout toneBlue
class node_rasterizer,node_rasterizer_api,node_polygon,node_polygon_api toneAmber
class node_scene_json,node_obj_mesh toneMint
class node_obj_loader,node_obj_loader_impl,node_glm_core,node_glm_matrix,node_glm_quaternion,node_glm_build toneRose
```

## Components

### Desktop app

Qt entry point and presentation boundary.

- [qmake project](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/rasterizer.pro): build definition · `rasterizer.pro`
- [Application startup](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/main.cpp): C++ entry point · `main.cpp`
- [Main window](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/mainwindow.cpp): Qt controller · Owns scene selection, render requests, and image presentation. · `mainwindow.cpp`
- [Main window API](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/mainwindow.h): Qt header · `mainwindow.h`
- [Window layout](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/mainwindow.ui): Qt UI form · `mainwindow.ui`

### Software rendering

Custom scene-to-pixels pipeline.

- [Rasterizer](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/rasterizer.cpp): software renderer · Runs the selected 2D or 3D polygon rendering path and generates pixels. · `rasterizer.cpp`
- [Rasterizer API](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/rasterizer.h): renderer header · `rasterizer.h`
- [Polygon geometry](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/polygon.cpp): render model · Common geometry handoff from scene inputs to rendering. · `polygon.cpp`
- [Polygon API](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/polygon.h): model header · `polygon.h`

### Scenes and assets

Bundled scene descriptors and mesh inputs.

- [Scene descriptors](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/scenes/3D_cube.json): JSON scene asset · Selects or describes predefined scenes. · `scenes/3D_cube.json`
- [OBJ mesh asset](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/scenes/wahoo.obj): Wavefront mesh · `scenes/wahoo.obj`

### Bundled dependencies

Local import and graphics-math libraries.

- [TinyObjLoader](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/tiny_obj_loader.h): OBJ importer · Local parser for Wavefront mesh geometry. · `tiny_obj_loader.h`
- [TinyObjLoader implementation](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/tiny_obj_loader.cc): C++ implementation · `tiny_obj_loader.cc`
- [GLM core math](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/glm.hpp): header-only math · Vectors and matrices used by geometry and rendering. · `include/glm/glm.hpp`
- [GLM transforms](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/gtc/matrix_transform.hpp): math extension · Matrix transformation utilities for rendering. · `include/glm/gtc/matrix_transform.hpp`
- [GLM quaternions](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/gtc/quaternion.hpp): math extension · `include/glm/gtc/quaternion.hpp`
- [GLM package metadata](https://github.com/vanshilshah97/graphics_rasterizer/blob/master/include/glm/CMakeLists.txt): CMake definition · `include/glm/CMakeLists.txt`

## Connections

- qmake project → Application startup: builds
- Application startup → Main window: starts
- Main window → Main window API: implements
- Window layout → Main window: binds widgets
- Main window → Scene descriptors: selects/loads
- Main window → Rasterizer API: requests render
- Rasterizer → Rasterizer API: implements
- Rasterizer → Polygon API: consumes
- Polygon geometry → Polygon API: implements
- Scene descriptors → Polygon geometry: defines 2D/3D geometry
- OBJ mesh asset → TinyObjLoader: parsed by
- TinyObjLoader implementation → TinyObjLoader: implements
- TinyObjLoader → Polygon geometry: imports mesh into
- Polygon geometry → Rasterizer: render input
- Rasterizer → Main window: pixel image
- Polygon geometry → GLM core math: uses vectors
- Rasterizer → GLM transforms: applies transforms
- Rasterizer → GLM quaternions: uses rotations
- GLM transforms → GLM core math: extends
- GLM quaternions → GLM core math: extends
- GLM package metadata → GLM core math: packages
