/cpp-wasm

An example C++ WebAssembly graphics application

Primary LanguageC++MIT LicenseMIT

C++ And WebAssembly

Build C++ WebAssembly Follow on Twitter

This is an example C++ graphics application using vcpkg as its package manager; the codebase can be compiled for both native and Web platforms.

  • Package Manager: vcpkg
  • Supported Platforms: MacOSX, Web

Getting Started

Requirements

Getting the Source Code

# Clone the repository
git clone --recurse-submodules https://github.com/painfulexistence/cpp-wasm && cd cpp-wasm

# Bootstrapping the package manager
./vcpkg/bootstrap-vcpkg.sh

Building

Building for native

# Building
cmake -S . -B build # Add -DCMAKE_BUILD_TYPE=release for release build
cmake --build build

# Running
./build/main

Building for WebAssembly

# Building
cmake -S . -B build-wasm -DEMSCRIPTEN=ON # Add -DCMAKE_BUILD_TYPE=release for release build
cmake --build build-wasm

# Running (open http://localhost:3000/ in your browser)
python -m http.server -d ./build-wasm 3000 # Use your preferred local server

Screenshot

Notes

  • I didn't use GLEW because the vcpkg wasm32 port is currently broken