WebBoom is a WebAssembly port of Doom based on PrBoom+.
- Remain compatible with upstream by changing as little as possible in the codebase/build scripts, which enables WebBoom to:
- be compiled for desktop and WebAssembly targets
- incorporate changes made to the original PrBoom+ after this fork was created
- Retain all singleplayer core features, including sound/music
- Keep the git history intact and provide documentation on how to compile the project
This project uses Emscripten as its compiler toolchain. To install it, follow this instructions and activate the 2.0.30 version.
CMake is needed to generate and run the build scripts, so go ahead and install that too.
To run prboom-plus (on desktop or web), you'll first need the prboom-plus.wad
PWAD. It can be built off the prboom2/data
directory on this repository using the CMake commands to compile a desktop build:
cd prboom2
cmake . # Generate the build scripts
cmake --build . # Build prboom-plus.wad, client executable and server executable
After this, the executable can found in prboom2/
along prboom-plus.wad
. To run it, use:
./prboom-plus
Copy the prboom-plus.wad
above the repository root and then clean it using:
mkdir $HOME/prboom-data # Create a directory if you want
cp prboom-plus.wad $HOME/prboom-data # Copy the .wad there
git clean -xdf # WARNING: This will remove any untracked files added to the repository
After cleaning the repository, it's time to recreate the build files for WebAssembly. If there is an Emscripten version activated through emsdk
and the env file was sourced, emcc
, emcmake
and emmake
should be available in $PATH
. If that's the case, proceed with:
cd prboom2
emcmake cmake . \
-D BUILD_GL=0 \
-D WITH_DUMB=0 \
-D WITH_MAD=0 \
-D WITH_FLUIDSYNTH=0 \
-D WITH_VORBISFILE=0 \
-D WITH_PORTMIDI=0 \
-D WITH_ALSA=0 \
-D WITH_PCRE=0 \
-D WITH_NET=0 \
-D PRBOOM_WAD="$HOME/prboom-data/prboom-plus.wad" # Or the path pointing to where the prboom-plus.wad is
-D PRELOAD_IWAD="$HOME/prboom-data/doom1.wad" # Or some other IWAD that is recognized by prboom
-D PRELOAD_CONFIG="$HOME/prboom-data/prboom-plus.cfg" # Optional. A path to a prboom-plus valid config
-D CMAKE_BUILD_TYPE="Debug" # Or Release
emmake cmake --build .
This will generate the following files: index.html
, index.js
, index.wasm
, index.wasm.map
, and index.data
.
If you run python -m "http.server"
or any web server in that directory, you should be able to play Doom on your browser!
-D OUT_SUFFIX=".html" # emcc output format. Check "-o <target>" in the emmc reference
-D OUT_NAME="index" # Output name
-D EM_KEYBOARD_ELEMENT="\"doom\"" # DOM ID for the element that will capture mouse and keyboard events
-D ADDITIONAL_FLAGS="" # Any flag accepted by emcc in the linking stage
For instance, these are the ADDITIONAL_FLAGS
used in the hosted version:
-D ADDITIONAL_FLAGS="-s MODULARIZE=1 -s EXPORT_NAME=prboom --shell-file='../emscripten/shell.html' -s INVOKE_RUN=0"
See also:
Switching between "Release"
and "Debug"
in CMAKE_BUILD_TYPE
affect some defaults flags:
Type of release | Optimization | Output name | Output suffix | Other flags |
---|---|---|---|---|
Debug | -O0 (No optimization) |
index |
.html |
-gsource-maps --source-map-base / . (Emit source maps. This will only work if the website is served from the prboom2 directory) |
Release | -Oz (Optimize the code with focus on size) |
prboom |
.js |
None |
The following projects served as inspiration for WebBoom:
Project | Description | Play it |
---|---|---|
WebAssembly Doom | Based on Chocolate Doom/early Crispy Doom, and maybe other projects (git history erased). | WadCommander |
Chocolate Doom WebAssembly | Based on Chocolate Doom with multiplayer reimplementation and no music. | Silent Space Marine |
SDLDoom.wasm | Based on SDLDoom, one of the earliest source ports. | No link available |
1997 DooM to WebAssembly from Scratch | Based on LinuxDoom (original source code released). Has good documentation on the porting process and doesn't use Emscripten | DooM |
- Persist saves and settings
- Joystick support
- Improve UX
- Multiplayer?