Master the fundamental concepts of software rasterizer through this focused micro-challenge.
A framebuffer is a region of memory that stores pixel color values. Before GPUs existed, all rendering wrote colors directly into a framebuffer in system RAM. The concept remains central: your monitor displays whatever sits in the framebuffer.
Each pixel typically stores red, green, and blue as 8-bit channels (24 bits total). Some formats add an alpha channel for transparency. Every shader, texture upload, and swapchain present ultimately resolves to reading and writing these bytes.
PPM (Portable Pixmap) is one of the simplest image formats. It stores pixels as plain text, ideal for learning and debugging:
cLoading…
For example, an 8x8 gradient from black at top-left to yellow at bottom-right uses red = (x * 255) / 7 and green = (y * 255) / 7.
You will create an 8x8 RGB framebuffer, fill it with a red-green gradient, and print a valid PPM header plus pixel data to stdout. This task also asks for an ASCII preview using # and . characters. Our sandbox has no display, so stdout replaces writing a file. The row-major layout you build here is the same abstraction behind Linux /dev/fb0 and every software renderer in this subtrack.
Write a C program that creates a framebuffer and outputs it in PPM format.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github