Wasm Builders

Cover image for Serious Sam in the Browser
Martin Mullins
Martin Mullins

Posted on

Serious Sam in the Browser

Inspired by QuakeJS I set out to port the open source Serious Sam Game to JavaScript. This project (circa Dec 2020) was a great learning experience and the result runs surprisingly smoothly.

Things that don’t work in the build:

  • Mutliplayer/Networking
  • Splitscreen
  • There is a small audio delay

The overall process invoked using Emscripten to compile the engine C source code into a wasm/js runtime. Here’s a quick overview of the steps involved porting the code base to Emscripten:

  • Remove threaded code
  • Ensure 32bit build works
  • Ensure static build works (except for libraries provided by emscripten)
  • Use gl4es library that translates/maps the OpenGL calls to OpenGL ES.
  • Replace the infinite main loop with function to be called at the desired FPS from emscripten (emscripten_set_main_loop(..))

Discussion (1)

Collapse
manuschillerdev profile image
Manu Schiller

That's awesome!