A program to create interactable fractals in real-time, built in C++ using the SFML library.
The fractals themselves are generated by re-projecting the applications screen onto smaller, virtual, translucent sub-screens which can be translated, rotated and scaled by a user. When these sub-screens overlap, they become superimposed; this effect then recurses down the series of sub-screens, generating fractals without any taxing computation!
I created this after seeing a Youtube video from the channel CodeParade (see here) in which he uses a webcam to record the screen. I couldn't be bothered setting up a webcam, so I instead created this app as a means of learning the basics of SFML.
- Space Add new sub-screen at mouse position
- Left Mouse (Hold) Click and drag sub-screens
- Right Mouse Delete hovered sub-screen
- Scroll Rotate hovered sub-screen
- Shift + Scroll Scale hovered sub-screen
- Esc Close the program
Note: This project has been built from the CMake SFML Project Template and has been made with cross-OS compatability in mind. The following instructions have been modified slightly from the template repo's setup guide...
-
Install Git and CMake. Use your system's package manager if available.
-
If you use Linux, install SFML's dependencies using your system package manager. On Ubuntu and other Debian-based distributions you can use the following commands:
sudo apt update sudo apt install \ libxrandr-dev \ libxcursor-dev \ libxi-dev \ libudev-dev \ libfreetype-dev \ libflac-dev \ libvorbis-dev \ libgl1-mesa-dev \ libegl1-mesa-dev \ libfreetype-dev
-
Configure and build your project. Most popular IDEs support CMake projects with very little effort on your part.
Using CMake from the command line is straightforward as well. Be sure to run these commands in the root directory of the project you just created.
cmake -B build cmake --build build
-
Enjoy!
SFML is found via CMake's FetchContent module. FetchContent automatically downloads SFML from GitHub and builds it alongside your own code. Beyond the convenience of not having to install SFML yourself, this ensures ABI compatibility and simplifies things like specifying static versus shared libraries.
Modifying what version of SFML you want is as easy as changing the GIT_TAG
argument.
Currently it uses SFML 3 via the 3.0.0
tag.
See the variety of CMAKE_<LANG>_COMPILER
options.
In particular you'll want to modify CMAKE_CXX_COMPILER
to point to the C++ compiler you wish to use.
CMake abstracts away specific optimizer flags through the CMAKE_BUILD_TYPE
option.
By default this project recommends Release
builds which enable optimizations.
Other build types include Debug
builds which enable debug symbols but disable optimizations.
If you're using a multi-configuration generator (as is often the case on Windows), you can modify the CMAKE_CONFIGURATION_TYPES
option.
While CMake will attempt to pick a suitable default generator, some systems offer a number of generators to choose from.
Ubuntu, for example, offers Makefiles and Ninja as two potential options.
For a list of generators, click here.
To modify the generator you're using you must reconfigure your project providing a -G
flag with a value corresponding to the generator you want.
You can't simply modify an entry in the CMakeCache.txt file unlike the above options.
Then you may rebuild your project with this new generator.
The source code is licensed under Public Domain.