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.
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.
Pixels and lines
A picture in RAM, and the whole-number line every renderer still uses.
| Lesson | Time | What 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 |
|
| 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 |
|
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".
Shapes and transforms
Circles, fills and the matrices that turn, move and scale anything.
| Lesson | Time | What 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 |
|
| 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 |
|
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".
Into 3D
Divide by depth, then spin a wireframe and profile every frame.
| Lesson | Time | What 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 |
|
| 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 |
|
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".
Boss
A space station built in code and flown from the game pad.
| Lesson | Time | What 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 |
|
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".
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.