A small C++ physics engine example project. The repository contains a simple simulation implemented in main.cpp and uses CMake as the build system. The application renders using SDL2 and produces the physics_engine executable.
- CMake (>= 3.10)
- A C++ compiler with C++17 support (GCC, Clang, MSVC)
- make / a build tool provided by your system
- SDL2 development libraries (libsdl2-dev on Debian/Ubuntu)
On Debian/Ubuntu:
sudo apt update
sudo apt install -y build-essential cmake libsdl2-devOn other Linux distros, install the equivalent SDL2 development packages.
A helper script build.sh is provided to simplify tasks. It builds the project into the build/ folder.
Common usages:
./build.sh # Configure & build Release
./build.sh --debug # Configure & build Debug
./build.sh --clean # Remove the build directory
./build.sh --pedantic # Enable extra compiler warnings
./build.sh --install # Install the built binary (system install)mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -- -j$(nproc)Executable will be at build/physics_engine.
From the repository root:
./build/physics_engineCMakeLists.txt- top-level CMake configurationmain.cpp- example entry point and minimal physics simulation/renderingbuild.sh- convenience scriptbuild/- out-of-source build artifacts
- Default C++ standard: C++17
ENABLE_PEDANTICoption toggles extra compiler warnings- For larger projects, consider
src/,include/,tests/and CI/tests
- Open an issue for features or bugs
- Create a branch, add code/tests
- Keep builds out-of-source
- Follow existing CMake conventions
See the LICENSE file.
Open an issue for help or discussion.