How vanshilshah97/graphics_rasterizer works
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 Rasterizer · mainwindow.cpp Main window · polygon.cpp Polygon geometry · glm.hpp GLM core math
Components 17
Desktop app
Qt entry point and presentation boundary.
- qmake project
rasterizer.pro - Application startup
main.cpp - Main window · Owns scene selection, render requests, and image presentation.
mainwindow.cpp - Main window API
mainwindow.h - Window layout
mainwindow.ui
Software rendering
Custom scene-to-pixels pipeline.
- Rasterizer · Runs the selected 2D or 3D polygon rendering path and generates pixels.
rasterizer.cpp - Rasterizer API
rasterizer.h - Polygon geometry · Common geometry handoff from scene inputs to rendering.
polygon.cpp - Polygon API
polygon.h
Scenes and assets
Bundled scene descriptors and mesh inputs.
- Scene descriptors · Selects or describes predefined scenes.
scenes/3D_cube.json - OBJ mesh asset
scenes/wahoo.obj
Bundled dependencies
Local import and graphics-math libraries.
- TinyObjLoader · Local parser for Wavefront mesh geometry.
tiny_obj_loader.h - TinyObjLoader implementation
tiny_obj_loader.cc - GLM core math · Vectors and matrices used by geometry and rendering.
include/glm/glm.hpp - GLM transforms · Matrix transformation utilities for rendering.
include/glm/gtc/matrix_transform.hpp - GLM quaternions
include/glm/gtc/quaternion.hpp - GLM package metadata
include/glm/CMakeLists.txt
Connections 21
- 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