https://github.com/terenstare/sortviz
A sorting visualizer written in C++20
https://github.com/terenstare/sortviz
cpp cpp20 sdl2 sorting-algorithms visualization
Last synced: 12 months ago
JSON representation
A sorting visualizer written in C++20
- Host: GitHub
- URL: https://github.com/terenstare/sortviz
- Owner: TerensTare
- License: mit
- Created: 2024-01-12T22:20:25.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-13T09:41:47.000Z (about 2 years ago)
- Last Synced: 2025-03-26T17:40:45.698Z (about 1 year ago)
- Topics: cpp, cpp20, sdl2, sorting-algorithms, visualization
- Language: C++
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SortViz - A sorting algorithm visualizer written in C++20
This repo contains a program that demonstrates how common sorting algorithms work step by step.
## Building and running
To build and run the repo, you need a C++ compiler that supports C++20, [cmake](https://cmake.org/) (>= 3.25) and [vcpkg](https://github.com/microsoft/vcpkg) to manage the dependencies. On Linux [ninja](https://ninja-build.org/) is needed to configure the project with CMake. Please refer to the corresponding documentation on how to obtain these dependencies.
### 1. Installing the dependencies
The project uses SDL2 for rendering the data being sorted and ImGui to provide a simple control panel within the application. To install these packages, run the following command:
```sh
# Replace {arch} and {os} with what you want to target.
# Run `vcpkg help triplets` for a list of available options.
# Remember the arch for later steps.
# Also run this from a folder outside of the project, as vcpkg won't allow you
# to run the command from there.
vcpkg install sdl2 imgui imgui[sdl2-binding] imgui[sdl2-renderer-binding] --triplet={arch}-{os}
```
### 2. Configuring with CMake
CMake needs to configure the project first before building, which can be done with the following command:
```sh
# Presets are of format {gen}-{arch}, where {gen} and {arch} are as following:
# {gen} - vs2019, vs2022 and ninja
# {arch} - x86, arm64, x64
# eg. to use Visual Studio 2022 to build in x64 mode, run `cmake --preset vs2022-x64`
# Also, for macOS there is the preset xcode (so command would be `cmake --preset xcode`).
# If you are using an IDE/editor, it should automatically list the compatible presets for you.
# Remember to match the arch with the one you installed the vcpkg packages for.
cmake --preset {my-preset}
```
### 3. Building the project
To build the project, run the following command:
```sh
# See `CMakePresets.json` for a list of available presets.
# If you are using an IDE/editor, it should automatically list the compatible ones.
# Remember to match the arch with the one you installed vcpkg packages for.
cmake --build . --preset {my-preset}
```
The project should then be built and you should see where the executable file is located.
## License
The code is licensed under the [MIT license](./LICENSE).
## Contributing
Please open an issue if you notice a bug or have an idea for the project. Thank you!