This week I mostly worked to make my engine support Emscripten. It ended up being a good amount of build system work and figuring out how to convince CMake do what I wanted, but also to try to understand how Emscripten asset packaging can be done.
By the end of the week I got my current demo work nicely on the Chrome browser, both on my PC and on my mobile phone. This was unexpected, to be honest: although I had already successfully hacked Emscripten support for a minimal engine setup, I expected troubles when using a more complex example. What frightened me the most were the incompatibilities between OpenGL and OpenGL ES.
And indeed I encountered some issues. Most of them were minimal, though. Like using “#version 300 es” rather than “#version 430 core” as a header for GLSL shaders. The only issue I haven’t fixed has to do with using FP16 pixel formats (RGB are 16-bit floating point values) for rendering. OpenGL ES is much more restrictive on the formats that are guaranteed to work in textures and for rendering. For now, I use RGB8, basically losing the bloom effect.
I am happy, overall. My game even worked decently on a phone without much tweaking. However, I had to connect a keyboard to the phone, as there are no touch-screen controls for the demo. It shouldn’t take long to implement these, but it adds to my long long to-do list.
To any programmer reading this post I would warmly encourage trying the Emscripten toolchain. It is kinda magic. Just switch from your C++ toolchain to a different one and suddenly a program that was never meant to run on a browser actually does.