Skip to content
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. #41

Open
1 of 4 tasks
HexDecimal opened this issue Feb 1, 2020 · 3 comments
Open
1 of 4 tasks

Emscripten Support. #41

HexDecimal opened this issue Feb 1, 2020 · 3 comments

Comments

@HexDecimal
Copy link
Collaborator

HexDecimal commented Feb 1, 2020

Something that'd be really nice would be the ability to compile the samples to WebAssembly, and then make proper instructions on how to build WASM with other libtcod projects.

Right now I think the best method to attempt this would be to run Conan with an Emscripten profile.

I'm welcome for any suggestions on how to get this working. Anything preventing a WebAssembly build can be removed from libtcod.

Things I need to do:

  • Fix fullscreen toggle.
  • Update samples to use Emscripten.
  • Fix GLES2 renderer. (The SDL2 renderer is good enough that this is no longer a requirement.)
  • Add fallback tileset (or at least set an error.)
@HexDecimal
Copy link
Collaborator Author

HexDecimal commented Jun 2, 2021

Tested using a modified frost sample. Updates are on the develop branch.

  • Libtcod successfully compiles to WASM using the wasm32-emscripten triplet on Vcpkg.
  • Samples compile, but have to be modified for Emscripten to run. This is expected.
  • No fallback tileset, one has to be manually given.
  • Frost sample runs correctly at a decent speed.
  • Fullscreen results in a crash when the window size is checked with SDL.
  • OpenGL2 renderer crahes. SDL2 and OpenGL1 works correctly.

@lychees
Copy link

lychees commented Feb 26, 2022

ubuntu@ip-172-26-1-83:~/workdir/ynoclient/build$ ninja
[2/2] Linking CXX executable index.html
FAILED: index.html
: && /home/ubuntu/workdir/buildscripts/emscripten/emsdk-portable/upstream/emscripten/em++  -O3 -DNDEBUG  -s ALLOW_MEMORY_GROWTH=1 -s ASYNCIFY -s ASYNCIFY_IGNORE_INDIRECT -s MINIFY_HTML=0 --pre-js /home/ubuntu/workdir/ynoclient/resources/emscripten/emscripten-pre.js --post-js /home/ubuntu/workdir/ynoclient/resources/emscripten/emscripten-post.js -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=['$autoResumeAudioContext','$dynCall'] --shell-file /home/ubuntu/workdir/ynoclient/resources/emscripten/emscripten-shell.html -s EXPORTED_FUNCTIONS='["_SwitchNpcSync","_SetSwitchSync","_SetSwitchSyncWhiteList","_LogSwitchSyncWhiteList","_SetSwitchSyncLogBlackList","_SetWSHost","_SetPlayersVolume","_SlashCommandSetSprite","_ChangeName","_gotMessage","_gotChatInfo","_isChatOpen","_updateTypeDisplayText","_updateTypeDisplayCaret","_trySendChat","_main"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","intArrayFromString","ALLOC_NORMAL","allocate"]' -s ASSERTIONS=1 CMakeFiles/EasyRPG_Player_exe.dir/src/main.cpp.o  -o index.html  libEasyRPG_Player.a  -lidbfs.js  -lwebsocket.js  /home/ubuntu/workdir/buildscripts/emscripten/lib/liblcf.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libicui18n.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libicuuc.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libicudata.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libexpat.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libpng.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libpixman-1.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libfmt.a  ../vcpkg/installed/wasm32-emscripten/lib/libtcod.a  ../vcpkg/installed/wasm32-emscripten/lib/libSDL2.a  -lm  ../vcpkg/installed/wasm32-emscripten/lib/libz.a  ../vcpkg/installed/wasm32-emscripten/lib/libglad.a  ../vcpkg/installed/wasm32-emscripten/lib/liblodepng-c.a  ../vcpkg/installed/wasm32-emscripten/lib/libutf8proc.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libspeexdsp.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libmpg123.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libsndfile.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libvorbisfile.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libvorbis.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libogg.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libopusfile.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libopus.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libfluidsynth.a  /home/ubuntu/workdir/buildscripts/emscripten/lib/libxmp-lite.a && :
error: undefined symbol: _ZN6EngineC1Ev (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: __ZN6EngineC1Ev may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN6EngineD1Ev (referenced by top-level compiled C/C++ code)
warning: __ZN6EngineD1Ev may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
em++: error: '/home/ubuntu/workdir/buildscripts/emscripten/emsdk-portable/node/14.18.2_64bit/bin/node /home/ubuntu/workdir/buildscripts/emscripten/emsdk-portable/upstream/emscripten/src/compiler.js /tmp/tmpjgf_440m.txt' failed (1)
ninja: build stopped: subcommand failed.

When I using “TCODConsole::initRoot(80,50,"libtcod C++ tutorial",false);”, It throws an error while compiling.
Without this this line of code. It can works normally.

@HexDecimal
Copy link
Collaborator Author

TCODConsole::initRoot is deprecated. You might want to use tcod::new_context instead. See the getting started section.

error: undefined symbol: _ZN6EngineC1Ev

Libtcod doesn't actually have an Engine symbol (closest is TCOD_ctx.engine.) So I don't know what this refers to, but I know it isn't talking about TCODConsole::initRoot here. I can only assume this is your own Engine class constructor or something like that.

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

No branches or pull requests

2 participants