A 3×3 Rubik's Cube simulator implemented in Modern C++, supporting both Desktop and Web applications.
- CMake ≥ 3.20
- C++17 compiler (GCC 9+, Clang 10+, MSVC 2019+)
- SDL2 and SDL2_mixer (Desktop App only; optional for sound)
- Emscripten SDK (Web App only)
Other dependencies (Corrade, Magnum, Dear ImGui, spdlog, nlohmann/json) are fetched via CMake FetchContent.
Install SDL2 (Desktop):
- macOS:
brew install sdl2 sdl2_mixer - Ubuntu/Debian:
sudo apt install libsdl2-dev libsdl2-mixer-dev - Windows: SDL or
vcpkg install sdl2 sdl2-mixer
Install Emscripten (Web):
git clone https://github.com/emscripten-core/emsdk.git && cd emsdk
./emsdk install latest && ./emsdk activate latest
source ./emsdk_env.sh # Run before each Web build session| Desktop App | Web App | |
|---|---|---|
| Directory | build/ |
build-web/ |
| Configure | cmake .. |
emcmake cmake -DBUILD_DESKTOP_APP=OFF -DBUILD_WEB_APP=ON .. |
| Build | cmake --build . |
cmake --build . |
mkdir build && cd build
cmake ..
cmake --build .source ~/emsdk/emsdk_env.sh # Activate Emscripten
mkdir build-web && cd build-web
emcmake cmake -DBUILD_DESKTOP_APP=OFF -DBUILD_WEB_APP=ON ..
cmake --build .CMake options: -DBUILD_DESKTOP_APP=ON/OFF, -DBUILD_WEB_APP=ON/OFF, -DBUILD_TESTS=ON/OFF
| Desktop App | Web App | |
|---|---|---|
| Command | ./RubiksCube or ./src/RubiksCube |
cd build-web/bin && emrun --no_browser --port 8080 . |
| Open | — | http://localhost:8080/RubiksCubeWeb.html |
Web output: build-web/bin/ (HTML, JS, WASM, data). WASM must be served over HTTP; Python alternative: python3 -m http.server 8080.
- Move sound: Place
audio.mp3in project root; desktop uses SDL2_mixer, web preloads it. - Camera: Orbit, zoom, pan (right/middle drag or Shift+left drag).
- Input: Keyboard, mouse, file I/O — see interface-specification.md.
- 3D visualization with move animation.
- Magnum — graphics engine
- Corrade — utilities
- SDL2 — desktop windowing/input
- Emscripten — WebAssembly toolchain
- Dear ImGui — UI
- spdlog — logging
- CMake — build system
| Module | Components |
|---|---|
| Utils | Math, Timer, Logger, Config, File |
| Core | CubeState, Move, History |
| Render | Renderer, Camera, Light, Material, Mesh, Texture (Magnum scene graph) |
| App | DesktopApp (SDL2), WebApp (WASM), UI (ImGui) |
