- 📖 About
- 🌟 Showcase
- 🎨 Color palettes
- 🧪 How to Use
- ⌨️ Keybindings
- 🧰 Implementation details
- ✨ Features
- 📦 Structure
- 📚 Libraries
- 🔧 Build
- 🙏 Acknowledgements
- 📚 Resources
- 🚀 Releases
- 📜 License
- 🤩 Gorgeous
This lightweight C/C++ application lets you generate and explore colorful fractals in real time, leveraging the power of the GPU. You can zoom in and out and navigate the complex plane using your mouse.
To enable deep zoom capabilities, the program simulates double-precision calculations on the GPU. This boosts the accuracy of computations, allowing for much deeper zoom levels.
Settings
-
Initial C value:
$0.280 + i0$ - Color palette: Original
Settings
-
Initial C value:
$-0.561 + i0.527$ - Color palette: Original
| Original | Electrical | Sky |
|---|---|---|
![]() |
![]() |
![]() |
| Fire | Shades of Gray | Gold |
![]() |
![]() |
![]() |
- Zoom: Zoom in or out by scrolling forward or backward.
- Move: Move in the 2D plane of the window by right-clicking and dragging your cursor.
Note
By default, all fractals are centered in the window.
When running the program, a sub-window titled "Simulation Settings" will appear in your main window. This menu allows you to adjust various parameters:
-
Fractal Type: Choose which fractal structure to display from a predefined list.
-
Maximum Iterations: Set the maximum number of iterations for constructing the fractal. This determines the resolution of the displayed fractal. For more details, see this resource.
[!WARNING] Since calculations are performed in real-time and recalculated with each zoom change, higher iterations can significantly reduce performance. The deeper you zoom, the more precise (and computationally intensive) the calculations become. This can quickly lead to lag or instability, depending on your GPU's capabilities.
-
Color Palette: Select from multiple predefined color palettes to customize the fractal's appearance.
Note
For the Julia fractal type, two additional parameters allow you to set the real and imaginary parts of the constant C in the Julia set equation. For more information, visit this Wikipedia page.
| Key | Action |
|---|---|
| Escape | Close the window. |
| S | Take a screenshot and save it as screen_<number>.png. |
| R | Reset the view (zoom, position, iterations, and Julia constant). |
| Right Arrow | Cycle forward through color palettes. |
| Left Arrow | Cycle backward through color palettes. |
| Up Arrow | Increase the number of iterations. |
| Down Arrow | Decrease the number of iterations. |
| Space | Zoom in (hold Shift to zoom out). |
| Z | Move the view upward (increase imaginary coordinate). |
| S (hold) | Move the view downward (decrease imaginary coordinate). |
| Q | Move the view leftward (decrease real coordinate). |
| D | Move the view rightward (increase real coordinate). |
| Right Mouse | Click and drag to pan the view. |
| Mouse Wheel | Scroll up to zoom in, scroll down to zoom out. |
| Shift + Space | Zoom out (instead of zooming in). |
Since this section could grow rapidly in size, refer to the details right here.
-
Project
- 🔄 Reproducible: Built with Nix, this configuration can be effortlessly reproduced on other machines, ensuring a consistent setup.
- 📖 Documented: Most of the parts of my configuration files are commented and documented with links and explanations if necessary
-
Application
- 🌀 Real-time fractal generation: Utilizes GPU acceleration to render fractals instantly.
- 🎨 Colorful visualizations: Generates vivid, dynamic color schemes for fractals.
- 🖱️ Interactive exploration: Navigate the complex plane with your mouse — zoom in, zoom out, and pan smoothly.
- 🔍 Deep zoom support: Emulates double-precision floating point on the GPU to allow ultra-deep zoom levels without significant loss of precision.
-
Directories
-
Files
flake.nix- Environment configuration (based on dev-templates).envrc- Used by direnv to load Flakesflake.lock- Used by Flakes to version packagesCMakeLists.txt- CMake configuration to build the project
- Dear ImGui ~ Bloat-free Graphical User interface for C++ with minimal dependencies
- SFML ~ Simple and Fast Multimedia Library
- GLAD ~ OpenGl loader
Note
Looking at the source code of SFML, it appears that stb and GLAD are already included (but I keep them here anyway).
Note
I'm using NixOS as my day-to-day OS, and I have found that Nix with Flakes was the simplest and fastest way for me to setup C/C++ project with external libraries.
To build this project, first make sure you have Nix installed as a package manager and direnv as a shell extension.
Then, configure it to enable Flakes according to your setup.
Once you're ready, you can start by cloning this repo
git clone https://github.com/leoraclet/fractals-generator
cd fractalsTip
Now, direnv should load the environment when inside the project directory, if not, try
direnv allowThe flake.nix file is where the project's environment is defined, and you can see in it that
CMake is part of the packages. So, if everything went well, you should be able
to build the project like so
cmake -B build -S .
cd build
cmake --build .Then, you can run the produced executable in build with
cd build/ # Move to build directory
./fractals # Run executableCaution
While the previous steps should work as expected, running fractals from a different location may cause issues.
Always ensure the shaders directory — containing shader files — is placed in the same directory as the executable.
Without these files, the program will fail to locate the necessary resources.
Warning
I have NOT tested the building process on Windows, so you're basically on your own for this.
The best solution to build this project on Windows is to use WSL and follow the Nix way in it.
You can start by installing nix over here.
Thanks to Henry Thasler for those great articles (part of a serie) that tought me a lot
- Heavy computing with GLSL - Part 1
- Heavy computing with GLSL - Part 2
- Heavy computing with GLSL - Part 3
- Heavy computing with GLSL - Part 4
- Heavy computing with GLSL - Part 5
Thanks to the original concept and the Fortran / C++ sourcecode that was developed by Yozo Hi, Xiaoye S. Li and David H. Bailey at Berkeley
- Library for Double-Double and Quad-Double Arithmetic
- Quad-Double Arithmetic: Algorithms, Implementation, and Application
Thanks to Eric Bainville for those amazing pages (CPU/GPU Multiprecision Mandelbrot Set)
Finally, some features were inspired from this website
Note
You can find the mentionned papers under doc/pdfs right there
- Heavy computing with GLSL
- CPU/GPU Multiprecision Mandelbrot Set
- Library for Double-Double and Quad-Double Arithmetic
- Quad-Double Arithmetic: Algorithms, Implementation, and Application
- Algorithms for Quad-Double Precision Floating Point Arithmetic
- Wikipedia - Buddhabrot
- Wikipedia - Plotting algorithms for the Mandelbrot set
- Stack Exchange - Zoom to cursor calculation
- Stack overflow - How does C compute sin() and other math functions?
- C++11 library for double-double (emulated quad precision) arithmetic
- A double-double and quad-double package for Fortran and C++
- A mostly branchless and somewhat efficient implementation of arbitrary precision fixed point numbers in GLSL
- Fork of Henry Thasler's quadruple precision GLSL Mandelbrot demo
- An arbitrary-precision arithmetic library for GLSL
- Generate a high resolution, deep mandelbrot zoom
- quadmath_snprintf (GCC libquadmath)
To run the program without editing the source code or building it yourself, go see the Releases.
Caution
I’ve built a Windows-compatible executable for this project using Visual Studio in a custom Windows VM. Since it requires GPU support, I wasn’t able to test it directly — I didn’t set up GPU pass-through. However, it should work on a native Windows system (fingers crossed).
Important: Make sure to run the executable from the same directory as the DLL files. The build isn’t static, so it will crash if it can’t find the required libraries. Looking forward to a static build in the future!
This project is licensed under the MIT License - see the LICENSE file for details.













