Skip to content

Conversation

@konsumer
Copy link

@konsumer konsumer commented Feb 16, 2025

This is related to #36 but uses plain emscripten (no need for SDL-shim.)

There are a couple of caveats.

  • Because of how the main-loop and sleep works in fenster, you need ASYNCIFY, which adds a lot to js. This could be avoided, but would require changes to how fenster works (have a wrapper for a function like fenster_set_loop(cb) and don't use fenster_loop or fenster_sleep.) Asyncify also adds performance overhead, so getting rid of that might really be worth exploring.
  • I keep it in a seperate header, because I like the idea of conditionally including it (with #if EMSCRIPTEN) so people can choose if they want emscritpen support easily, sort of like audio.

I updated these examples, including Makefile:

  • drawing-c
  • input-c
  • minimal-c

For each, they will build for native with make, or for web with emmake make

some things that could be improved later:

  • no sound, but it could be added
  • I don't like adding event-listeners without a way to remove them. it's in js-space, so I think they need to be inserted into Module so they can be removed in fenster_close
  • keys need to be very closely checked. All my keyboard-keys worked on linux/chrome and mac/chrome, but I don't think there is any guarantee these keycodes will match, across browsers or platforms
  • fenster-doom would be a nice "kitchen sink" demo for web
  • didn't really attempt to port any other languages (go, lua, etc) to emscripten-method. They have their own ways of binding to web-wasm, and it can get complicated.

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.

1 participant