SkillAgentSearch skills...

Samarium

2D physics simulation and rendering library in modern C++, with GPU acceleration

Install / Use

/learn @jjbel/Samarium
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

See installation instructions below

<!-- TODO make a script to merge these into 2x2 grid, loop them -->

$10^4$ particles interacting gravitationally in realtime, using a hashgrid:

$10^5$ particles moving in a velocity field of perlin noise:

Softbody, interact with a mouse:

An ideal gas's velocity distribution approaching the Maxwell-Boltzmann Distribution:

Graphics:

Animating levels of the Hilbert Curve:

Animating levels of the Fourier transform of a shape:

Samarium

<!-- [![GCC](https://github.com/jjbel/samarium/actions/workflows/gcc.yml/badge.svg)](https://github.com/jjbel/samarium/actions/workflows/gcc.yml) [![Clang](https://github.com/jjbel/samarium/actions/workflows/clang.yml/badge.svg)](https://github.com/jjbel/samarium/actions/workflows/clang.yml) [![MSVC](https://github.com/jjbel/samarium/actions/workflows/msvc.yml/badge.svg)](https://github.com/jjbel/samarium/actions/workflows/msvc.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jjbel_samarium&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jjbel_samarium) --> <!-- [![MIT License](https://img.shields.io/badge/license-MIT-yellow)](https://github.com/jjbel/samarium/blob/main/LICENSE.md) --> <!-- ![language: C++20](https://img.shields.io/badge/language-C%2B%2B20-yellow) [![Latest Github Release](https://img.shields.io/github/v/tag/jjbel/samarium?label=latest%20release)](https://github.com/jjbel/samarium/tags) -->

Samarium is a 2d physics simulation and rendering library written in C++20, with a focus on high performance using GPU acceleration (CUDA and compute shaders), and by using the CPU and memory better (multithreading, data-oriented-design).

I am actively working on adding 3D support and more simulation domains: chemical reactions, phase change, cloth etc.

<!-- Rendering is done directly with OpenGL. --> <!-- Offload more work to the GPU --> <!-- SIMD for increasing, CPU performance --> <!-- ## Contents --> <!-- TODO use vscode markdown auto TOC --> <!-- - [Examples](#examples) --> <!-- - [Quickstart](#quickstart) --> <!-- - [Prerequistes](#prerequistes) - [Installation](#installation) - [Example](#example) - [Tools](#tools) - [Documentation](#documentation) - [License](#license) -->

Quickstart

git clone --depth 1 https://github.com/jjbel/samarium.git
python samarium/bootstrap.py
<!-- TODO make sure bootstrap works --> <!-- TODO make it easy to run examples, easier than copy pasting the code into a source file? -->

Installation

<!-- | Dependency | URL | Documentation | | ---------- | ----------------------------------- | --------------------------- | | python | <https://www.python.org/downloads/> | | | git | <https://git-scm.com/downloads/> | <https://git-scm.com/docs/> | --> <!-- | cmake | <https://cmake.org/download/> | <https://cmake.org/cmake/help/latest/> | --> <!-- | conan | <https://conan.io/downloads.html/> | <https://docs.conan.io/en/latest/> | -->

Install python and git.

A compiler supporting C++20 is required, namely Visual C++ 2019 on Windows, or GCC-11/Clang-13 on Linux.

To install, do the following, or just run python samarium/boostrap.py

  1. Install CMake and Conan
  2. Download the zip or clone the repo:
git clone https://github.com/jjbel/samarium.git
  1. build the library for your machine:
conan create ./samarium/ -b missing
<!-- ## Installation To install the library locally: ``` conan download samarium/1.1.0@ ``` or for the latest version ```sh git clone --depth 1 https://github.com/jjbel/samarium.git conan create ./samarium/ -b missing ``` --> <!-- ## Example -->

For a fully-featured and self-contained example, run:

<!-- is depth 1 rly faster? -->
git clone --depth 1 https://github.com/jjbel/samarium_example.git .
cmake --preset default
cmake --build --preset default

Now try the examples/ directory!

Documentation

View the docs at Github Pages: https://jjbel.github.io/samarium/

License

Samarium is distributed under the MIT License.

Libraries Used

Many thanks to the following wonderful libraries:

  1. GLFW, glad and glm for OpenGL support
  2. fmtlib to completely replace iostream
  3. range-v3
  4. BS::thread_pool
  5. PCG RNG for simple and fast randomness
  6. tl::function_ref and tl::expected
  7. znone/call_thunk for using with GLFW's C callback
  8. itlib-static-vector
  9. unordered-dense for faster unordered_map
  10. stb for image reading and writing
  11. FreeType for text rendering

Related Skills

View on GitHub
GitHub Stars9
CategoryDevelopment
Updated2mo ago
Forks2

Languages

C++

Security Score

90/100

Audited on Feb 3, 2026

No findings