Raycasting engine project developed as part of the 42 curriculum. A 3D rendering system inspired by the classic Wolfenstein-style engines 🕹️
Zcadinot & Dedavid
cub3D consists of building a minimal 3D graphics engine using the raycasting technique.
From a 2D map described in a .cub configuration file, the program renders a first-person perspective environment.
The goal is to understand low-level graphics programming, mathematical projection, memory management, and clean architecture in C.
- 📐 Raycasting algorithm
- 🗺️ Map parsing and validation
- 🧮 Collision detection
- 🎨 Wall texturing
- 🌌 Floor and ceiling rendering
- 🎮 Player movement handling
- 🧵 Strict memory management
- ❌ Complete error handling
The configuration file contains:
NO→ North wall textureSO→ South wall textureWE→ West wall textureEA→ East wall texture
F R,G,B→ Floor colorC R,G,B→ Ceiling color
The map is composed of:
1→ Wall0→ Empty spaceN,S,E,W→ Player starting position and orientation
The map must:
- Be fully enclosed by walls
- Contain exactly one player
- Contain only valid characters
structure:
src/
parsing/
raycasting/
rendering/
movement/
utils/
include/
textures/
maps/
Architecture principles:
- Clear separation of responsibilities
- Small, focused functions
- High readability
- Robust error handling
- Easy maintainability
make
Cleaning rules:
make clean
make fclean
make re
./cub3D maps/map.cub
W→ Move forwardS→ Move backwardA→ Move leftD→ Move right←/→→ Rotate cameraESC→ Exit program
The program systematically checks:
- Argument validity
.cubfile format- Map enclosure
- Unique player presence
- Texture accessibility
- RGB value correctness
- Memory allocation failures
- Graphics library initialization errors
On any error:
- All allocated memory is freed
- The program exits cleanly
- 🖱️ Mouse rotation
- 🚪 Animated doors
- 👾 Sprites
- 🔫 Animations
- 🧱 Mini-map
- C language
- MiniLibX graphics library
- 42 coding standard
- Computational geometry
- Real-time rendering logic
- Memory management mastery
- Robust parsing techniques
- Software architecture design
- Graphics debugging and optimization
Developed as part of the 42 school curriculum.
cub3D is a deep dive into low-level graphics programming.
It combines mathematics, structured architecture, strict memory discipline, and algorithmic precision to create a minimal yet powerful 3D rendering engine.
🔥 A challenging and highly formative project.