summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2018-07-21 17:13:59 +0200
committerraysan5 <[email protected]>2018-07-21 17:13:59 +0200
commit4c15515ba687931ee3353e32b25c2ba0427d67b1 (patch)
tree62a5394c201b012f9ef42dc8930629a9d0cbde09 /examples
parent7dc66d2d3f0668edd46ed3380656692d67ae6da0 (diff)
downloadraylib-4c15515ba687931ee3353e32b25c2ba0427d67b1.tar.gz
raylib-4c15515ba687931ee3353e32b25c2ba0427d67b1.zip
Support examples with Emterpreter
Examples can be compiled for web with no code change at all! Usually examples need to be refactored for web... using emscripten code interpreter (emterpreter), it can manage synchronous while() loops internally... as a downside, execution is very slow...
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile27
1 files changed, 18 insertions, 9 deletions
diff --git a/examples/Makefile b/examples/Makefile
index 518b9fbd..7ab6527f 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -117,13 +117,13 @@ endif
ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables
- EMSDK_PATH = C:/emsdk
- EMSCRIPTEN_VERSION = 1.37.28
- CLANG_VERSION=e1.37.28_64bit
- PYTHON_VERSION=2.7.5.3_64bit
- NODE_VERSION=4.1.1_64bit
- export PATH=$(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
- EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
+ EMSDK_PATH = C:/emsdk
+ EMSCRIPTEN_VERSION = 1.38.8
+ CLANG_VERSION = e1.38.8_64bit
+ PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
+ NODE_VERSION = 8.9.1_64bit
+ export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
+ EMSCRIPTEN = $(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION)
endif
# Define raylib release directory for compiled library.
@@ -236,14 +236,23 @@ ifeq ($(PLATFORM),PLATFORM_RPI)
CFLAGS += -std=gnu99
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
- # -O2 # if used, also set --memory-init-file 0
+ # -Os # size optimization
+ # -O2 # optimization level 2, if used, also set --memory-init-file 0
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
# -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
# -s USE_PTHREADS=1 # multithreading support
# -s WASM=1 # support Web Assembly (https://github.com/kripken/emscripten/wiki/WebAssembly)
+ # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow)
+ # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter
+ # --profiling # include information for code profiling
# --preload-file resources # specify a resources folder for data compilation
- CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 --profiling --preload-file resources
+ CFLAGS += -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1
+
+ # NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way,
+ # we can compile same code for ALL platforms with no change required, but, working on bigger
+ # projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw
+ # logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.
# Define a custom shell .html and output extension
CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html