diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f3457b046..6f9e4428a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -81,7 +81,7 @@ elseif(${PLATFORM} MATCHES "Web") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1") # Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html") set(OUTPUT_EXT ".html") diff --git a/examples/Makefile b/examples/Makefile index cb015fa73..e79bc3645 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -240,7 +240,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # 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 + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/CMakeLists.txt b/games/CMakeLists.txt index d3f9d9fcf..3ec6cb29f 100644 --- a/games/CMakeLists.txt +++ b/games/CMakeLists.txt @@ -8,7 +8,7 @@ set(OUTPUT_EXT) if(${PLATFORM} MATCHES "Web") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html") set(OUTPUT_EXT ".html") endif() diff --git a/games/cat_vs_roomba/Makefile b/games/cat_vs_roomba/Makefile index 620df80f9..87b052d26 100644 --- a/games/cat_vs_roomba/Makefile +++ b/games/cat_vs_roomba/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/drturtle/Makefile b/games/drturtle/Makefile index 4bab3e36e..8a7c67323 100644 --- a/games/drturtle/Makefile +++ b/games/drturtle/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/just_do/Makefile b/games/just_do/Makefile index 9bd09dd48..7b2d4d5fa 100644 --- a/games/just_do/Makefile +++ b/games/just_do/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/koala_seasons/Makefile b/games/koala_seasons/Makefile index 4688f3acf..5f3493e3c 100644 --- a/games/koala_seasons/Makefile +++ b/games/koala_seasons/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/light_my_ritual/Makefile b/games/light_my_ritual/Makefile index 1a90642e8..b14468318 100644 --- a/games/light_my_ritual/Makefile +++ b/games/light_my_ritual/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/skully_escape/Makefile b/games/skully_escape/Makefile index d57075da1..aa21763a5 100644 --- a/games/skully_escape/Makefile +++ b/games/skully_escape/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/transmission/Makefile b/games/transmission/Makefile index c78d7ef57..f4b303314 100644 --- a/games/transmission/Makefile +++ b/games/transmission/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/games/wave_collector/Makefile b/games/wave_collector/Makefile index 7f9b94e64..e2c039b61 100644 --- a/games/wave_collector/Makefile +++ b/games/wave_collector/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/projects/4coder/Makefile b/projects/4coder/Makefile index c7b9162aa..63d093a27 100644 --- a/projects/4coder/Makefile +++ b/projects/4coder/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile index c7b9162aa..63d093a27 100644 --- a/projects/VSCode/Makefile +++ b/projects/VSCode/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/src/core.c b/src/core.c index d8d851442..8dd1090b1 100644 --- a/src/core.c +++ b/src/core.c @@ -1640,7 +1640,7 @@ void TakeScreenshot(const char *fileName) #if defined(PLATFORM_WEB) // Download file from MEMFS (emscripten memory filesystem) - // SaveFileFromMEMFSToDisk() function is defined in raylib/templates/web_shel/shell.html + // SaveFileFromMEMFSToDisk() function is defined in raylib/src/shell.html emscripten_run_script(TextFormat("SaveFileFromMEMFSToDisk('%s','%s')", GetFileName(path), GetFileName(path))); #endif diff --git a/templates/web_shell/shell.html b/src/shell.html similarity index 75% rename from templates/web_shell/shell.html rename to src/shell.html index 641cfc02b..5d8e7e91c 100644 --- a/templates/web_shell/shell.html +++ b/src/shell.html @@ -27,51 +27,65 @@ - + -
+
- +
@@ -202,26 +215,26 @@ })(), printErr: function(text) { if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); - if (0) { // XXX disabled for safety typeof dump == 'function') { - dump(text + '\n'); // fast, straight to the real console - } else { - console.error(text); - } + console.error(text); }, canvas: (function() { var canvas = document.querySelector('#canvas'); + // As a default initial behavior, pop up an alert when webgl context is lost. To make your // application robust, you may want to override this behavior before shipping! // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); + return canvas; })(), setStatus: function(text) { if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; - if (text === Module.setStatus.text) return; + if (text === Module.setStatus.last.text) return; var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); var now = Date.now(); - if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon + if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon + Module.setStatus.last.time = now; + Module.setStatus.last.text = text; if (m) { text = m[1]; progressElement.value = parseInt(m[2])*100; @@ -232,7 +245,7 @@ progressElement.value = null; progressElement.max = null; progressElement.hidden = true; - if (!text) spinnerElement.style.display = 'none'; + if (!text) spinnerElement.hidden = true; } statusElement.innerHTML = text; }, @@ -243,8 +256,7 @@ } }; Module.setStatus('Downloading...'); - window.onerror = function(event) { - // TODO: do not warn on ok events like simulating an infinite loop or exitStatus + window.onerror = function() { Module.setStatus('Exception thrown, see JavaScript console'); spinnerElement.style.display = 'none'; Module.setStatus = function(text) { diff --git a/templates/advance_game/Makefile b/templates/advance_game/Makefile index 784c7dcaf..95fb6f6f2 100644 --- a/templates/advance_game/Makefile +++ b/templates/advance_game/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/simple_game/Makefile b/templates/simple_game/Makefile index a1e65772f..ea732c928 100644 --- a/templates/simple_game/Makefile +++ b/templates/simple_game/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/standard_game/Makefile b/templates/standard_game/Makefile index bd7906b80..56b76b424 100644 --- a/templates/standard_game/Makefile +++ b/templates/standard_game/Makefile @@ -230,7 +230,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif