Skip to content
boldbug1Public

About

A 2d graphics engine implemented from scratch in C++

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meow

A 2D software renderer written in C++ from scratch. No graphics libraries: the CPU fills a pixel array, and the program saves it as an image.

Renders

Features

  • Framebuffer with bounds-checked setpixel
  • Alpha blending (semi-transparent shapes mix with what's underneath)
  • Anti-aliased circles (4x4 sampling per pixel)
  • Rectangles and lines (Bresenham, all directions)
  • Scene as data: a std::vector<std::variant<Circle, Rectangle, Triangle>> drawn by render()
  • PPM image output

Build and run

g++ -std=c++17 -Wall -Wextra main.cpp src/renderer.cpp -o main
./main

The image is written to images/. PPM isn't previewed by most viewers, so open it with IrfanView or GIMP, or convert it: magick images/castle.ppm images/castle.png.

Layout

lib/renderer.h     types and function declarations
src/renderer.cpp   rasterizer, blending, render()
main.cpp           builds a scene and saves it

Roadmap

  • Framebuffer, shapes, PPM output
  • Alpha blending
  • Anti-aliased circles
  • Scene as a list of shapes
  • Line drawing (Bresenham)
  • Scanline triangle fill (any triangle)
  • Polygons
  • Transforms (move, scale, rotate)
  • Window and frame loop (SDL2)
  • Save and load scenes from a file

About

A 2d graphics engine implemented from scratch in C++

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages