|
|
Hello I was able to get the PicoSDL driver to target wasm: (small demo) http://mohammed-alyousef.com/fltk.html
The changes I had to do are attached in the patch. Some are quite intrusive, like adding the Fl_PicoSDL_Window_Driver as a friend class to Fl_Window.
Keyboards events aren't handled, it's missing the mapping between SDL and FLTK keys.
To build wasm fltk app: - Install emscripten - git clone https://github.com/fltk/fltk - cd fltk - git apply /path/to/wasm.patch - emcmake cmake -Bbin -DFLTK_BUILD_TEST=OFF && cmake --build bin --parallel - cp bin/libs/libfltk* $EMSDK/upstream/emscripten/cache/wasm/ - mkdir $EMSDK/upstream/emscripten/system/include/FL - cp bin/FL/* $EMSDK/upstream/emscripten/system/include/FL/ - cp FL/* $EMSDK/upstream/emscripten/system/include/FL/
Now you can build with em++ or emcmake whatever. The emscripten_set_main_loop_arg() needs to be called. The sample program is something like: #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> #include <FL/Fl_Box.H> #include <emscripten.h> void main_loop(void *) { Fl::wait(); } void cb(Fl_Widget *w, void *data) { ((Fl_Box*)data)->color(FL_RED); Fl::redraw(); } int main() { auto win = new Fl_Window(600, 400); auto box = new Fl_Box(40, 40, 520, 220, "Hello from FLTK 1.4"); box->box(FL_SHADOW_BOX); box->labelsize(16); auto but = new Fl_Button(260, 300, 80, 40, "Click me"); win->end(); win->show(); but->callback(cb, box); emscripten_set_main_loop_arg(main_loop, NULL, 0, true); } Using em++, this can be built: em++ -o fltk.html main.cpp -s WASM=1 -s USE_SDL=2 -s USE_FREETYPE=1 -lfltk --shell-file shell_minimal.html
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/a4945449-5282-431b-bc78-e4ed17fbeffan%40googlegroups.com.
[ Direct Link to Message ] | |
|
| |