Skip to content

rmfleet/software-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Software Rasterizing 3D Renderer

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.

Features

  • Object Space Backface Removal
  • 3D Sutherland Hodgeman Clipping
  • Z Buffer Depth Sorting
  • Perspective Correct Texture Mapping

Requirements

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.

Installing SDL 1.2 on Ubuntu/Debian

# 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 imagemagick

Installing SDL 1.2 on Other Systems

Fedora/RHEL/CentOS:

sudo dnf install SDL-devel SDL_image-devel gcc make ImageMagick

Arch Linux:

sudo pacman -S sdl sdl_image gcc make imagemagick

macOS (via Homebrew):

brew install sdl sdl_image imagemagick

Automated Setup

Use the Makefile to automatically install dependencies:

make deps

Building

# Build the project
make all

# Or build with debug symbols
make debug

Running

# Run the software renderer
make run

The program will load assets/texture.jpg (a grey and white checkerboard pattern) and render a textured 3D scene using pure software rasterization.

Controls

Movement:

  • W - Move forward
  • S - Move backward
  • A - Strafe left
  • D - 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

Notes

This codebase represents software rendering techniques, including:

  • Pure CPU-based rasterization (no GPU acceleration)
  • Fixed-point mathematics for performance
  • Manual memory management

Rendering Pipeline

  • 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

About

Software 3D Triangle Renderer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published