C++20 Python 3.9+ Vulkan runtime

Getting Started with Spectra

From zero to GPU-accelerated plots in under five minutes — C++ and Python.

1install prerequisites
2configure CMake
3build examples
4run C++ or Python

1. Prerequisites

DependencyRequiredNotes
C++20 compilerYesGCC 12+, Clang 15+, or MSVC 2022+
CMake 3.20+YesBuild system
Vulkan runtime / driversYesRequired to run Spectra binaries; usually installed with graphics drivers
Vulkan development filesSource builds onlylibvulkan-dev on Linux, Vulkan SDK on Windows, vulkan-headers + vulkan-loader on macOS
glslangValidatorSource builds onlyglslang-tools on Linux, glslang on macOS
Python 3.9+OptionalFor the Python API

2. Platform-Specific Setup

Linux (Ubuntu / Debian)

sudo apt install build-essential cmake git \
    libvulkan-dev libglfw3-dev glslang-tools

For headless builds, you can omit libglfw3-dev and configure with -DSPECTRA_USE_GLFW=OFF -DSPECTRA_USE_IMGUI=OFF.

macOS

xcode-select --install
brew install cmake vulkan-headers \
    vulkan-loader glslang molten-vk

Windows

  • Install Visual Studio 2022 with C++ workload
  • Install Vulkan SDK (1.2+)
  • CMake auto-detects MSVC and Vulkan SDK path

3. Build from Source

git clone https://github.com/danlil240/Spectra.git
cd Spectra
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
The build system requires Vulkan development files and glslangValidator for source builds. GLFW is optional as a system package and is fetched automatically if missing.

Makefile Shortcuts

CommandDescription
make buildConfigure + build (Release)
make testBuild + run tests
make installInstall to /usr/local
make packageCreate .deb/.rpm/.tar.gz via CPack
make cleanRemove build directory
make formatRun clang-format

4. CMake Options

cmake -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DSPECTRA_BUILD_TESTS=ON \
    -DSPECTRA_BUILD_EXAMPLES=ON \
    -DSPECTRA_BUILD_GOLDEN_TESTS=ON \
    -DSPECTRA_USE_FFMPEG=ON
FeatureCMake Flag
Video export (MP4)-DSPECTRA_USE_FFMPEG=ON (requires ffmpeg in PATH)
Eigen support-DSPECTRA_USE_EIGEN=ON
Build tests-DSPECTRA_BUILD_TESTS=ON
Build examples-DSPECTRA_BUILD_EXAMPLES=ON
Golden image tests-DSPECTRA_BUILD_GOLDEN_TESTS=ON
ROS2 adapter-DSPECTRA_USE_ROS2=ON
ROS2 bag support-DSPECTRA_ROS2_BAG=ON

Build Targets

TargetDescription
spectraCore library (static)
spectra-backendMultiproc daemon (IPC server)
spectra-windowMultiproc window agent
spectra-rosROS2 adapter (requires SPECTRA_USE_ROS2)
examples/*All example programs
unit_test_*Individual unit test executables

5. First Plot (C++)

#include <spectra/easy.hpp>

int main() {
    spectra::plot({0.f, 1.f, 2.f, 3.f, 4.f},
                  {0.f, 1.f, 0.5f, 1.5f, 2.f}, "c-o");
    spectra::title("First Spectra Plot");
    spectra::show();
}

Or use the full object API for maximum control:

#include <spectra/spectra.hpp>

int main() {
    spectra::App app;
    auto& fig = app.figure({.width = 1280, .height = 720});
    auto& ax  = fig.subplot(1, 1, 1);

    ax.line(x, y).label("signal").color(spectra::rgb(0.2f, 0.8f, 1.0f));
    ax.title("Sensor Data");
    ax.xlabel("Time (s)");
    ax.ylabel("Amplitude");

    fig.show();
}

Run an Example

# Linux / macOS
./build/examples/basic_line
./build/examples/easy_api_demo
./build/examples/demo_3d

# Windows
.\build\examples\Release\basic_line.exe

6. Python Quick Start

# Install
pip install spectra-plot

# Or development install from source
cd python && pip install -e ".[dev]"

The Python package (spectra-plot) communicates with the spectra-backend daemon over Unix sockets. The backend is auto-launched on first connection.

Python IPC sequence

Session lifecycle from socket connect through figure creation, series updates, and GPU render.

Python IPC sequence
import spectra as sp
sp.plot([1, 4, 9, 16, 25])
sp.show()
For Qt embed mode, build with -DSPECTRA_BUILD_EMBED_SHARED=ON.

7. Eigen Integration

Spectra accepts Eigen vectors directly — no conversions needed. Build with -DSPECTRA_USE_EIGEN=ON (requires Eigen3 headers).

#include <spectra/eigen_easy.hpp>

Eigen::VectorXf x = Eigen::VectorXf::LinSpaced(100, 0, 2 * M_PI);
Eigen::VectorXf y = x.array().sin();

spectra::plot(x, y, "r--o");  // zero-copy, direct Eigen support
spectra::show();

8. CMake Integration (Downstream Projects)

After installing Spectra (cmake --install build), use it from your project:

find_package(spectra 0.1 REQUIRED)
target_link_libraries(myapp PRIVATE spectra::spectra)

9. Deployment & Packaging

APT Repository (Ubuntu 22.04 / 24.04)

The recommended Linux install — adds the Spectra repo so apt handles updates automatically:

# Import the signing key
curl -fsSL https://danlil240.github.io/Spectra/apt/spectra-archive-keyring.asc \
  | sudo gpg --dearmor -o /etc/apt/keyrings/spectra.gpg

# Add the repository (auto-detects your Ubuntu codename)
echo "deb [signed-by=/etc/apt/keyrings/spectra.gpg] https://danlil240.github.io/Spectra/apt $(lsb_release -cs) main" \
  | sudo tee /etc/apt/sources.list.d/spectra.list

# Install
sudo apt update
sudo apt install spectra
Supported codenames: jammy (22.04) and noble (24.04). The $(lsb_release -cs) command auto-detects the correct one.

Install from Source

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
sudo cmake --install build --prefix /usr/local

This installs headers to include/spectra/, libraries to lib/, binaries (spectra-backend, spectra-window) to bin/, and fonts/icons to share/spectra/.

Runtime Dependencies by Artifact

ArtifactHow to installWhat the user must install manually first
Debian packagesudo apt install ./spectra_<version>_amd64.debNothing in the common case. Do not preinstall -dev packages; apt resolves runtime dependencies.
AppImageRun the downloaded .AppImageUsually nothing beyond a working Vulkan-capable driver/runtime.
Python wheelpip install spectra-plotNo compiler, CMake, or Vulkan SDK. A working Vulkan runtime/driver is still required to run the backend.
Source buildBuild from the repositorylibvulkan-dev and glslang-tools on Linux, plus optional libglfw3-dev for system GLFW.

CPack Packages

FormatCommandOutput
Debiancpack -G DEBspectra_0.1.0_amd64.deb
RPMcpack -G RPMspectra-0.1.0-1.x86_64.rpm
Tarballcpack -G TGZspectra-0.1.0-Linux.tar.gz
Windowscpack -G NSISspectra-0.1.0-win64.exe
macOScpack -G DragNDropspectra-0.1.0.dmg

Additional Package Formats

Python Wheel

pip install build
python -m build

Or install directly: pip install spectra-plot

Homebrew (macOS)

brew install spectra

Formula at packaging/homebrew/spectra.rb

AUR / AppImage

PKGBUILD at packaging/aur/PKGBUILD.
AppImage built via linuxdeploy in release workflow.

10. Docker

# Full deployment test
./docker/ubuntu22/run_tests.sh

# With GPU tests
RUN_GPU_TESTS=1 ./docker/ubuntu22/run_tests.sh

# Docker Compose
cd docker && docker compose up --build spectra-xvfb

11. Testing

cmake -B build -DSPECTRA_BUILD_TESTS=ON -DSPECTRA_BUILD_GOLDEN_TESTS=ON
cmake --build build -j$(nproc)
cd build && ctest --output-on-failure
CategoryCountDescription
Unit tests1,200+All core systems, UI, animation, serialization, 3D, IPC
Golden image tests50+Headless renders compared pixel-by-pixel (2D + 3D)
Integration tests100+Cross-component workflows, 3D regression
Benchmarks100+Rendering, data structures, animation, 3D scaling
Python tests50+Codec, transport, session, easy API

Running Specific Tests

# Single test suite
cd build && ./tests/unit/unit_test_math3d

# Pattern match
ctest -R "3d" --output-on-failure

# Benchmarks
./tests/bench/bench_3d

# Python tests
cd python && pytest tests/ -v

# Sanitizers
cmake -B build-asan -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
cmake --build build-asan && cd build-asan && ctest --output-on-failure

12. CI/CD

Continuous Integration

Every push and PR triggers (.github/workflows/ci.yml):

JobPlatformDescription
build-linuxUbuntu 24.04GCC 13 + Clang 17 matrix, unit tests
build-macosmacOS 14/15 (ARM)Apple Clang, unit tests (no GPU)
build-windowsWindows 2022MSVC, Vulkan SDK install, unit tests
golden-testsUbuntu 24.04Headless golden tests with lavapipe
sanitizersUbuntu 24.04ASan + UBSan with leak detection

Release Pipeline

Triggered on v* tag push (.github/workflows/release.yml):

  1. package-linux.deb, .rpm, .tar.gz, AppImage
  2. package-macos.tar.gz for ARM64
  3. package-windows.zip with Vulkan SDK
  4. python-wheels — via cibuildwheel for Linux/macOS/Windows × Python 3.9–3.13
  5. python-sdist — Source distribution
  6. release — GitHub Release with all artifacts, publishes to PyPI
# Trigger a release
git tag v0.1.0 && git push origin v0.1.0

Verify Installation

cd build && ctest --output-on-failure
vulkaninfo --summary

Where Next?