summaryrefslogtreecommitdiff
path: root/src/gfx_type.h
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2020-12-05 21:57:47 +0100
committerPatric Stout <github@truebrain.nl>2020-12-15 15:46:39 +0100
commitd15dc9f40f5a20bff452547a2dcb15231f9f969d (patch)
tree7b8d88635c048d906cbb6358007fb26055e24410 /src/gfx_type.h
parent2da07f76154d841bcfe9aaff4833144550186deb (diff)
downloadopenttd-d15dc9f40f5a20bff452547a2dcb15231f9f969d.tar.xz
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>
Diffstat (limited to 'src/gfx_type.h')
-rw-r--r--src/gfx_type.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gfx_type.h b/src/gfx_type.h
index 6fca2228d..452bc2c7e 100644
--- a/src/gfx_type.h
+++ b/src/gfx_type.h
@@ -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)