-
-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emscripten support #7510
Emscripten support #7510
Conversation
It's hidden in the commit-checker log but
|
@@ -14,8 +14,16 @@ | |||
|
|||
#include "video_driver.hpp" | |||
|
|||
#ifdef __EMSCRIPTEN__ | |||
void em_loop(void *arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a particular reason not to make this a (conditional) class method? would save the duplicate friend
definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is called by function pointer by emscripten. Is it safe to assume that calling convention would match?
@@ -42,6 +52,12 @@ class VideoDriver_SDL : public VideoDriver { | |||
int PollEvent(); | |||
bool CreateMainSurface(uint w, uint h); | |||
void SetupKeyboard(); | |||
|
|||
uint32 cur_ticks; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that these are necessary at all...
waiting for #7086 to merge both sdl1 and sdl2 emscripten changes at same time |
b6a5634
to
2280b2e
Compare
type macro from Squirrel code clashes with Emscripten math.h. This is likely Emscripten fault because it shouldn't define own identifiers without __ prefix, but, eh.
This reverts commit aa35052.
…'t call SDL_SetColors for 32bpp as it confuses Emscripten
Superseded by #8355 |
This is currently WIP, but I would appreciate feedback on it.
Libtimidity is restored with mixer output, Emscripten support is added and various fixes for Emscripten quirks are applied.
Dockerfile for build environment is here: https://github.com/Milek7/openttd-emscripten-dockerfile/tree/sdl1
It currently works on SDL1 on 32bpp blitter (8bpp blitter doesn't work, I suspect broken SDL palette support in emscripten shim). It doesn't look correct though, because html provides BGRA buffer and all blitters assume RGBA. Modifying
union Colour
works, but this is hacky solution.It works too on SDL2 branch, with significantly better performance, both on 8bpp (with correct colors) and 32bpp (same BGRA issue, but it is faster than 8bpp). Maybe this PR should wait on SDL2, as it works much better on it.
Network is handled by emscripten as WebSockets, both UDP and TCP. It requires proxy, like this one: https://gist.github.com/Milek7/b921ec9f8d875fe2d5a8b06bfd533834
sockaddr sizes and NetworkAddress comparing needs to be investigated, current workaround is to delete domain name after resolving, and comparing generated hostnames by strcmp. Using original code caused duplicated entries in gamelist as UDP queries received weren't matched to correct entry.