This repository contains simple projects demonstrating the use of SDL2.
cdinto the root folder of the repository.- Run
cmake -B build -S .to generate the build files. Dependencies are fetched automatically via CMake FetchContent. cd buildinto the build folder.- Run
maketo build the projects.
1-stamp: Basic window that allows stamping images with the mouse.- To run, execute
./1-stampfrom the build folder.
- To run, execute
2-sketchpad: A mini sketchpad application that allows drawing with the mouse, resizing cursor and changing colors.- To run, execute
./2-sketchpadfrom the build folder.
- To run, execute
3-connect4: A simple Connect 4 game with basic AI.- Uses alpha-beta pruning for the AI.
- Multithreaded to keep the UI responsive during AI calculations.
- Animated piece dropping effect.
- To run, execute
./3-connect4from the build folder.
4-dragbox: A simple drag-and-drop box for trying out SDL2 TTF- To run, execute
./4-dragboxfrom the build folder.
- To run, execute
5-snake: Snake game using ImGui for menu screens- To run, execute
./5-snakefrom the build folder.
- To run, execute
6-particlebox: Particle physics simulation with ImGui settings panel- Configurable particle count, radius range, mass range, gravity, and collision restitution (0–2, sub-elastic to super-elastic)
- Per-particle mass with mass-weighted elastic collisions; hue-based coloring (blue=light, red=heavy)
- Arena-allocated quadtree for O(n log n) spatial collision queries instead of brute-force O(n²)
- Multiple multithreading modes selectable at runtime: graph coloring (lock-free), mutex locks, unsafe (no lock), and naive N²
- Lock-free parallel collision resolution via greedy graph coloring — pairs are partitioned into conflict-free batches so no two pairs in a batch share a particle
- Cache-friendly compact particle layout and chunked quadtree storage to reduce allocation overhead
- To run, execute
./6-particleboxfrom the build folder.