Lesson plan

Computer graphics from scratch lesson plan

Write every pixel yourself in C++ on an ESP32-C3: framebuffers, lines, circles, matrices, perspective and wireframes, ending with a spinning space station.

4 chapters, 7 lessons, about 6 hours, on the ESP32-C3-DevKitM-1. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • A picture in RAM, and the whole-number line every renderer still uses.
  • Circles, fills and the matrices that turn, move and scale anything.
  • Divide by depth, then spin a wireframe and profile every frame.
  • A space station built in code and flown from the game pad.

Materials for the whole unit

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • Game console buttons
  • TFT display, 240x320

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 50 min

Pixels and lines

A picture in RAM, and the whole-number line every renderer still uses.

LessonTimeWhat students do
FramebuffersHold a picture in RAM, one byte a pixel, draw a starfield and a planet into it, count and checksum it, and send it to the screen in one go.55 min
  1. A picture in RAM
  2. Draw by writing bytes
  3. Send it down the wire
  4. Move the planet
  5. Fill the sky
Bresenham linesDraw a straight line on a grid with whole numbers only, trace the error term pixel by pixel, race it against floats, and fan a starburst.55 min
  1. Rule a line
  2. Walk the error
  3. Integers against floats
  4. Steep lines
  5. A starburst

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • TFT display, 240x320

Check for understanding

Each student finishes "Bresenham lines" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A starburst".

Chapter 2. About 1 h 40 min

Shapes and transforms

Circles, fills and the matrices that turn, move and scale anything.

LessonTimeWhat students do
Circles and fillsDraw a circle with the midpoint rule and eight-way symmetry, fill a disc from spans, and flood a crater floor with a ring-buffer queue.55 min
  1. Eight for the price of one
  2. Fill with spans
  3. Flood the crater
  4. A bigger planet
  5. Seed the peak
TransformsTurn, move and scale a satellite outline with 2D matrices, prove that the order of transforms matters, and spin it on the screen.45 min
  1. Turn a point
  2. Order matters
  3. Spin the satellite
  4. Scale it up

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • TFT display, 240x320

Check for understanding

Each student finishes "Transforms" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Scale it up".

Chapter 3. About 1 h 40 min

Into 3D

Divide by depth, then spin a wireframe and profile every frame.

LessonTimeWhat students do
3D projectionDivide by depth: project a cube's eight corners onto the screen by hand, then move the camera and change its lens and watch perspective change.45 min
  1. Divide by depth
  2. Near is big
  3. Walk closer
  4. Change the lens
WireframesTurn, project, clear, draw, flush: spin a wireframe cube at 26 frames a second, profile every frame, and swap the model for your own.55 min
  1. Points and edges
  2. The render loop
  3. Where the time goes
  4. Spin faster
  5. Your own model

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • TFT display, 240x320

Check for understanding

Each student finishes "Wireframes" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your own model".

Chapter 4. About 55 min

Boss

A space station built in code and flown from the game pad.

LessonTimeWhat students do
Boss: a spinning space stationA wireframe space station built in code (hub, ring, spokes and solar panels), spun and tilted from the game pad, with depth shading on the far side.55 min
  1. Build it in code
  2. Take the controls
  3. Tilt it toward you
  4. Depth shading
  5. A smoother ring

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • Game console buttons
  • TFT display, 240x320

Check for understanding

Each student finishes "Boss: a spinning space station" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A smoother ring".

Your class

Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.