A real-time 3D rendering engine built in C using raycasting techniques, inspired by early first-person games such as Wolfenstein 3D.
This project focuses on low-level graphics programming, mathematical rendering systems, and performance-oriented software design without relying on modern graphics APIs.
The goal of this project is to transform a 2D map into a dynamic 3D environment using raycasting. The engine simulates a first-person perspective by casting rays from the player’s position, calculating wall intersections, and rendering a 3D projection in real time.
This project was built entirely in C using MiniLibX and emphasizes understanding how real-time rendering systems work at a fundamental level.
- Real-time raycasting engine
- 3D perspective projection from 2D maps
- Fish-eye distortion correction
- Texture mapping on walls
- Frame-based rendering loop
- First-person camera control
- Smooth movement (WASD controls)
- Rotation system (left/right camera turning)
- Collision detection with map boundaries
- Custom
.cubfile parser - Map validation (walls, structure, rules)
- Texture path loading
- Error detection and handling
- Modular design separated by responsibility
- Clean rendering pipeline
- Organized memory management
- Event-driven input system
.
├── includes/
│ └── cub3d.h
├── map/
│ └── *.cub maps
├── src/
│ ├── init_game/
│ ├── move/
│ ├── parsing/
│ ├── ray/
│ ├── render/
│ └── texture/
├── cub3d.c
└── Makefile| Module | Responsibility |
|---|---|
init_game/ |
Game initialization and setup |
move/ |
Player movement and input handling |
parsing/ |
Map parsing and validation |
ray/ |
Raycasting calculations |
render/ |
Rendering pipeline |
texture/ |
Texture loading and management |
Each frame, the engine performs the following steps:
- Cast a ray for every vertical screen column
- Detect intersection with walls
- Compute distance from player to wall
- Correct fish-eye distortion
- Calculate projected wall height
- Apply correct texture slice
- Render final frame to the screen
This process creates the illusion of a 3D environment from a 2D map in real time.
| Key | Action |
|---|---|
| W | Move forward |
| S | Move backward |
| A | Strafe left |
| D | Strafe right |
| ← | Rotate camera left |
| → | Rotate camera right |
| ESC | Exit program |
- C Programming Language
- MiniLibX (graphics library)
- X11 (window system)
- Make (build system)
- Linux environment
This project follows the 42 School Norminette coding standard, which enforces strict rules to ensure clean, readable, and maintainable C code.
- Functions limited in size (max 25 lines)
- Strict naming conventions and formatting rules
- No unused variables or redundant code
- Clear separation of responsibilities per module
- Structured and readable logic flow
- Modular design enforced by file organization
Although restrictive, these constraints improve real-world engineering skills:
- Forces modular and maintainable architecture
- Encourages clean function decomposition
- Improves debugging and traceability
- Builds discipline in low-level programming
- Simulates production-level code standards
- Low-level C programming
- Graphics and rendering systems
- Raycasting and geometric computation
- Memory management
- Event-driven programming
- Software architecture design
- Performance optimization
- Parsing and validation systems
- Sprite rendering (objects inside the world)
- Floor and ceiling casting
- Dynamic lighting system
- Minimap integration
- Mouse-based camera control
- Advanced enemy AI system
- Performance optimizations (ray batching, caching)
This project provides deep insight into how early 3D engines work internally, demonstrating how mathematical models, memory handling, and rendering loops combine to create real-time interactive environments.
It bridges the gap between theoretical computer graphics and practical system-level implementation.
