Skip to content

marginalhours/mandelbrot-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mandelbrot Renderer

This is a (keyboard and mouse) interactive C++ renderer of the Mandelbrot set, using SDL2 for output. The main thread maintains an array of pixel data in memory. A pool of rendering threads are passed messages containing a reference to this pixel data and some bounds, and compute new colour values for the pixels within those bounds as the user provides new inputs for zoom level, iterations, and so on.

Realistically this parallelises so well only because each pixel value is truly independent from all the other pixels -- so this work really belongs in a GPU shader rather than on the CPU. It's fun to see how large the speedup from multithreading can be when the work truly is parallelisable, though!

Obligatory action shots

Command-line flags

The program supports the following command line flags:

  • -h / --help: prints help message and exits
  • -wx / --screen-width: sets the image width in pixels
  • -hx / --screen-height: sets the image height in pixels
  • -c / --concurrency: set number of render threads. Default is the number of cpu cores, so one thread per core.

Viewer controls:

Mouse

Click + drag to draw a rectangle to zoom into it.

Keyboard

  • space -- take screenshot (screenshots are saved to screenshot-<n>.bmp in the current directory) (inc. trashy screen flash effect)
  • r -- reset viewer
  • c -- cycle colour scheme
  • +/= -- zoom in
  • - -- zoom out
  • . -- increase detail (iterations)
  • , -- decrease detail (iterations)
  • , , , -- pan image
  • ESC -- quit

Dependencies for Running Locally

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory in the top level directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./Mandelbrot.

Releases

No releases published

Packages

No packages published