Git Product home page Git Product logo

mandelbrot_cpp's Introduction

Multi-thread mandelbrot set rendering with C++ & OpenGL

To create mandelbrot set we must simply iterate: z -> z * z + c, where z and c are complex numbers. For every pixel in the wanted region we calculate mapping to the coordinates on the complex plane and then assign this point to c. For every c we start iterating from z = 0. Iteration stops when |z| or number of iterations reaches the boundaries.

Coloring scheme is a huge field for improvisation. Generally speaking, the intensity is determined by how fast z goes to infinity (relative to the maximum iterations).
Parallel rendering is done by independently processing chunks of window area (I should say, that it's implemented "dirty" - through the global variables).

In this implementation, you can zoom-in by double clicking inside the window. And zoom is actually not infinite, due to the limitation of floating point calculations precision. So if you zoom in up to 10e+13 you'll see very discrete image, something like this:

Requirements

Install OpenGL libraries and freeGlut:

sudo apt-get install mesa-utils
sudo apt-get install freeglut3-dev

Usage

Compile mandelbrot.cpp:

g++ -O2 -fno-stack-limit -x c++ mandelbrot.cpp -lglut -lGL -lpthread -o mandelbrot

Then you can specify arguments and run the code:

  • maximum number of iterations (250 by default);
  • number of threads (4 by default);
  • scale factor in range 0..1.0 to use zoom-in (0.5 by default);
./mandelbrot 1000 10 0.5

If you need to change the window size, replace variable width inside the code with whatever you want.

mandelbrot_cpp's People

Contributors

gasparian avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.