Add: support for emscripten (play-OpenTTD-in-the-browser)

Emscripten compiles to WASM, which can be loaded via
HTML / JavaScript. This allows you to play OpenTTD inside a
browser.

Co-authored-by: milek7 <me@milek7.pl>
This commit is contained in:
Patric Stout
2020-12-05 21:57:47 +01:00
committed by Patric Stout
parent 2da07f7615
commit d15dc9f40f
25 changed files with 844 additions and 12 deletions

View File

@@ -162,7 +162,9 @@ struct DrawPixelInfo {
union Colour {
uint32 data; ///< Conversion of the channel information to a 32 bit number.
struct {
#if TTD_ENDIAN == TTD_BIG_ENDIAN
#if defined(__EMSCRIPTEN__)
uint8 r, g, b, a; ///< colour channels as used in browsers
#elif TTD_ENDIAN == TTD_BIG_ENDIAN
uint8 a, r, g, b; ///< colour channels in BE order
#else
uint8 b, g, r, a; ///< colour channels in LE order
@@ -177,7 +179,9 @@ union Colour {
* @param a The channel for the alpha/transparency.
*/
Colour(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) :
#if TTD_ENDIAN == TTD_BIG_ENDIAN
#if defined(__EMSCRIPTEN__)
r(r), g(g), b(b), a(a)
#elif TTD_ENDIAN == TTD_BIG_ENDIAN
a(a), r(r), g(g), b(b)
#else
b(b), g(g), r(r), a(a)