So I spent some time to experiment with SDL2 and getting it to compile to HTML5 via emscripten. It was a success!
The above is not a GIF, it’s an actual canvas, running Emscripten-generated code, compiled from C++/SDL2.
The only minor problem I discovered with Emscripten-generated JS files is, the page loses all keylistener events, so I’m unable to perform any key shortcuts like page refresh (
CTRL+R) or copy-pasting.
It’s probably nothing exciting, but this is just proof that SDL2 + Emscripten = the most lightweight web game written in C++. I’m looking forward to experimenting more throughout the weekend.