How qwertop18/minirt works
Project Type and Purpose
• MINIRT is a lightweight, command-line ray-tracing renderer written in C.
• It reads a scene description (.rt files), builds an in-memory scene graph (cameras, lights, materials, primitives), performs ray-object intersection and shading calculations, and displays the result via the MiniLibX graphics library or logs for debugging.
File Structure Analysis
• Top-level directories:
• console, debug – logging/formatting and debug helpers
• incs – all project headers (scene, parse, math, system)
• input – sample and invalid .rt scene files
• libft, list, vector – three custom support libraries
• minilibx – external graphics library
• srcs – core source code, subdivided into:
– interface (MiniLibX hooks, window/pixel management)
– parse (lexing/parsing .rt files into scene objects)
– system.c (initialization, cleanup), raytrace.c, calculate.c, main.c
README Insights
• Describes project modules and their roles
• Provides build and run targets (make run, log, val)
Diagramming the Architecture
a. Main Components
• External Input: .rt files
• Parser Module: srcs/parse + incs/parse.h
• Math Libraries: vector (C_VECTOR), list (LINKED-LIST), libft (C std-lib replacement)
• Core Engine:
– Intersection Subsystem (srcs/intersection)
– Raytracer (srcs/raytrace.c)
• Rendering Interface: MiniLibX wrapper (srcs/interface)
• Logging & Debug: console/* and debug/*
• System & Utilities: memory management, file I/O (srcs/system.c)
b. Relationships and Data Flow
1. User invokes CLI → system.c initializes subsystems
2. Parser reads .rt file → builds scene graph (using list and vector libs)
3. Main render loop (raytrace.c):
– For each pixel, generate primary ray
– Call intersection subsystem → find nearest hit
4. Interface layer pushes frame buffer to display (MiniLibX)
5. Logging layer can intercept any stage for formatted debug output
c. Architectural Patterns and Principles
– Pipeline pattern: input → parse → scene build → ray-trace → render
– Modular separation: parsing, object model, intersection, shading, rendering
– Reusable utility libraries (vector, list, libft)
– Single-responsibility modules for maintainability
d. Key Technologies and Frameworks
– C (ISO C, organized per-feature in srcs/)
– MiniLibX for window creation and pixel drawing
– Custom math and data-structure libraries
– POSIX file I/O for reading scene files