Skip to content

Support for building with Emscripten#14

Open
parkertomatoes wants to merge 5 commits intojno6809:masterfrom
parkertomatoes:master
Open

Support for building with Emscripten#14
parkertomatoes wants to merge 5 commits intojno6809:masterfrom
parkertomatoes:master

Conversation

@parkertomatoes
Copy link

@parkertomatoes parkertomatoes commented Jan 30, 2024

I updated this to run in the browser using Emscripten. It runs well on Chrome and Firefox for me
jc_reborn_firefox

It still builds under MacOS X using the Linux Makefile (make -f Makefile.linux), but now it also builds with Emscripten (emmake make -f Makefile.linux).

Since the code uses blocking calls to SDL_Delay I built with Asyncify, and only a few minor changes were required.

  • Calls to SDL_Delay were changed to emscripten_sleep to avoid blocking the main thread.
  • Calls to exit were changed to emscripten_force_exit to avoid exceptions being thrown after exiting
  • A hint function is called to keep Emscripten from resizing the canvas element.

All emscripten-specific changes, including in the Makefile, are made with a preprocessor switch (#ifdef __EMSCRIPTEN__), so the old functionality isn't affected.

UPDATE: Removed main loop refactor after realizing it wasn't necessary when using Asyncify

@xesf
Copy link
Collaborator

xesf commented Feb 22, 2024

Merged your changes into my fork and made a release version of it: https://github.com/xesf/jc_reborn

@xesf
Copy link
Collaborator

xesf commented Apr 1, 2024

This PR has been applied in these changes: #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants