This project demonstrates basic software rendering/rasterizing techniques without hardware acceleration.
It demonstrates how to render triangles in 3D space with perspective correct texture mapping, clip them to a frustum of 6 planes, and rasterize them onto a 2D view. It includes Z Buffer depth sorting of the objects. It also demonstrates setting up modelview and projection matrices and a basic camera movement system.
The project was originally created around 2001.
- Object Space Backface Removal
- 3D Sutherland Hodgeman Clipping
- Z Buffer Depth Sorting
- Perspective Correct Texture Mapping
This project uses SDL 1.2 for graphics and window management. SDL 1.2 is a legacy library but provides excellent compatibility for older codebases.
# Install SDL 1.2 development libraries
sudo apt update
sudo apt install libsdl1.2-dev libsdl-image1.2-dev
# Install additional build dependencies
sudo apt install build-essential imagemagickFedora/RHEL/CentOS:
sudo dnf install SDL-devel SDL_image-devel gcc make ImageMagickArch Linux:
sudo pacman -S sdl sdl_image gcc make imagemagickmacOS (via Homebrew):
brew install sdl sdl_image imagemagickUse the Makefile to automatically install dependencies:
make deps# Build the project
make all
# Or build with debug symbols
make debug# Run the software renderer
make runThe program will load assets/texture.jpg (a grey and white checkerboard pattern) and render a textured 3D scene using pure software rasterization.
Movement:
W- Move forwardS- Move backwardA- Strafe leftD- Strafe right
Camera Rotation:
Arrow Keys- Look around (Up/Down = pitch, Left/Right = yaw)
Other:
Escape- Exit program
Movement System:
- Frame-rate independent movement for consistent speed regardless of FPS
- Movement speed: 25 units/second
- Rotation speed: 90 degrees/second
- Mouse grabbing with cursor hiding for immersive experience
This codebase represents software rendering techniques, including:
- Pure CPU-based rasterization (no GPU acceleration)
- Fixed-point mathematics for performance
- Manual memory management
- Perform backface removal in object space
- Clip triangle to view frustum planes(6)
- Generate triangle fan from clipped polygon
- Project triangle into screen space
- Sort projected vertices from top to bottom
- Send projected triangle to be rasterized