From cbe174bfa48e1d38e2502e4350518e517142b860 Mon Sep 17 00:00:00 2001 From: Pablo Marcos Oltra Date: Sat, 2 Nov 2019 08:47:52 +0100 Subject: [PATCH] Updated Working for Web (HTML5) (markdown) --- Working-for-Web-(HTML5).md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Working-for-Web-(HTML5).md b/Working-for-Web-(HTML5).md index c0e31ba..e692d6e 100644 --- a/Working-for-Web-(HTML5).md +++ b/Working-for-Web-(HTML5).md @@ -6,8 +6,16 @@ Download [emscripten SDK](http://kripken.github.io/emscripten-site/docs/getting_ After that, go to emsdk intallation folder, run `emcmdprompt.bat` and execute the following commands: - emsdk install latest - emsdk activate latest +``` +emsdk install latest-fastcomp +emsdk activate latest-fastcomp +``` + +This will update the latest version of the **fastcomp** compiler which needed to be able to use the [Emterpreter](https://github.com/emscripten-core/emscripten/wiki/Emterpreter). `EMPTERPRETIFY` is not supported on the WASM backend that is the default one in newer versions. + +On Linux and macOS you will also need to set the proper environment so that raylib build system can find the Emscripten compiler: + +`source ./emsdk_env.sh` _NOTE: Updated installation notes are always [available here](https://emscripten.org/docs/getting_started/downloads.html)._ @@ -15,14 +23,22 @@ _NOTE: Updated installation notes are always [available here](https://emscripten Before compiling your game, raylib library must be recompiled for HTML5, generating `libraylib.bc`. +#### Using Makefile Before compiling raylib, make sure all paths to emscripten sdk path (`EMSDK_PATH`) and version (`EMSCRIPTEN_VERSION`) are correctly configured on `C:/raylib/raylib/src/Makefile`, you must verify [this lines](https://github.com/raysan5/raylib/blob/master/src/Makefile#L149). To compile raylib source code, just execute Notepad++ script: `raylib_makefile` and `SET PLATFORM=PLATFORM_WEB`. That script just calls the following `make` line (in case you're are working on a custom environment): - make PLATFORM=PLATFORM_WEB -B +`make PLATFORM=PLATFORM_WEB -B` Generated `libraylib.bc` is placed in `raylib\src\libraylib.bc` directory. +#### Using CMake + +``` +cmake -H. -Bbuild -DPLATFORM=Web -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/emscripten.cmake +cmake --build build +``` + ### Preparing your raylib game for web To compile your game for web, code must be slightly adapted. Basically it implies moving all your Update and Draw code to an external function. The reason for that is the way web games work within a browser; the browser needs to control the game loop and just allow and Update-Draw in a time-frame and lock the execution when the tab is not active or browser is minimized. More details [here](https://kripken.github.io/emscripten-site/docs/porting/emscripten-runtime-environment.html#browser-main-loop)