| PSHOT-ENG — Build Your Own 3D Engine in ISO C89 | Contents | Chapter 02 | Going Further |
A chapter-by-chapter manual for writing a Quake-era first-person 3D software renderer from scratch in strict ISO C89 and SDL 1.2.
| 7 Chapters Setup to Win32 build |
Strict ISO C89 -std=c89 -pedantic |
1 Dependency SDL 1.2 only |
Pure CPU Raster Zero OpenGL drivers |
Continue at Chapter 02: 3D Math, Camera & Wireframe Cube » | Start from Chapter 00
This manual walks through building PSHOT-ENG (pshot) manually, one file and one chapter at a time. We open a window with SDL 1.2, allocate a raw 320x240 pixel buffer in RAM, and build every layer of a 3D first-person engine on top of it: vector and matrix math, perspective projection, Bresenham lines, 3D near-plane clipping, a 1/z depth buffer, perspective-correct texture mapping, distance fog, WASD + mouselook controls, sliding wall collision, software PCM audio, and Win32 cross-compilation from Linux Mint.
At the end of Chapter 06, you will have a working, playable, textured first-person 3D engine that runs at full speed on modern Linux and Windows machines as well as 1998 Pentium-class hardware. You will not yet have Quake’s full BSP compiler, pre-baked lightmaps, or animated MD2 monsters. Instead, every core mathematical and rasterization piece is clean, readable, and isolated so you can add BSP trees, lightmaps, and sprites straight on top—which we map out in Going Further.
Every C listing in this manual is written in strict -std=c89 -Wall -Wextra -pedantic with zero comments inside source files. All explanations live in the chapter text around each block so the code itself stays crisp and easy to type manually in VSCodium.
| # | Chapter | What you build | Time |
| 00 | Setup & Toolchain [Foundation] | Install GCC, SDL 1.2, and clangd on Linux Mint; configure VSCodium and a strict ISO C89 Makefile. | 20 min |
| 01 | Types, Platform Layer & Framebuffer [Foundation] | Fixed-width C89 types, isolating SDL 1.2 in platform.c, upscaled 320x240 software framebuffer, and FPS loop. | 45 min |
| 02 | 3D Math, Camera & Wireframe Cube [Up Next] | Write vec3/mat4 math, perspective projection, Cohen-Sutherland 2D line clipping, Bresenham lines, and a spinning 3D cube. | 1 hr |
| 03 | Filled Triangles, Z-Buffer & Clipping | Back-face culling, 3D near-plane polygon clipping, flat-shaded triangle rasterization, and a 1/z depth buffer. | 1 hr 15 |
| 04 | Perspective Textures, Fog & Bitmaps | Perspective-correct u/z and v/z texture mapping, a zero-dependency 24-bit BMP loader, procedural bricks, and distance fog. | 1 hr 30 |
| 05 | First-Person Controls & Level Geometry | WASD strafing, SDL mouselook, gravity, sliding AABB wall collision, and a multi-room textured Quake-style map. | 1 hr 30 |
| 06 | SDL Audio Mixer & Windows Builds | Software 16-bit PCM audio callback for retro sound effects, plus cross-compiling portable Win32 .exe binaries from Linux Mint. | 1 hr |
| ++ | Going Further | BSP trees, lightmaps, MD2 models, fixed-point 16.16 math, and hitscan weapons. | Ref |
| Table of Contents | Ch 00: Setup » |