cube

A rotating 3D wireframe cube rendered in the terminal
git clone https://github.com/michaelneuper/cube.git
README | Files | Log | Refs | LICENSE

cube

A rotating 3D wireframe cube rendered in the terminal using ncurses.

Vertices are projected onto the screen with perspective projection and connected by edges drawn with Bresenham's line algorithm. The cube spins continuously and can be quit with q.

Building

Requires clang and ncurses.

make          # release build
make debug    # debug build with AddressSanitizer and UBSan
make run      # build (debug) and run
make clean    # remove build artefacts

Usage

./bin/cube # or make run

Press q to quit.

Project structure

src/
  main.c      entry point and render loop
  cube.c/h    cube state, projection, rotation, and drawing
  ncdraw.c/h  ncurses drawing primitives (pixel, line)
  debug.h     assertion macros (active only with -DDEBUG)