From 7df7e9cc8bbe25148698f4350123a42e17033881 Mon Sep 17 00:00:00 2001 From: eska Date: Tue, 28 Mar 2017 03:21:21 +0200 Subject: WebGL 2 export per WebAssembly or asm.js --- platform/javascript/godot_shell.html | 199 ++++++++++------------------------- 1 file changed, 58 insertions(+), 141 deletions(-) (limited to 'platform/javascript/godot_shell.html') diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html index 65f3b4a34..6c7069a8f 100644 --- a/platform/javascript/godot_shell.html +++ b/platform/javascript/godot_shell.html @@ -2,8 +2,7 @@ - $GODOT_HEAD_TITLE -$GODOT_HEAD_INCLUDE + +$GODOT_HEAD_INCLUDE
- + HTML5 canvas appears to be unsupported in the current browser.
Please try updating or use a different browser.
Downloading page...
-
- - - -
@@ -226,33 +170,9 @@ $GODOT_STYLE_INCLUDE var canvasElement = document.getElementById("canvas"); var presentation = { - postRun: [ - function() { - var elements = document.getElementsByClassName("postRun-enable"); - Array.prototype.slice.call(elements).forEach(function(element) { - element.disabled = false; - }); - } - ], - requestFullscreen: function requestFullscreen() { - if (typeof Module !== "undefined" && Module.requestFullscreen) { - Module.requestFullscreen(false, false); - } - }, - /* - requestPointerlock: function requestPointerlock() { - if (typeof Module !== "undefined" && Module.requestPointerlock) { - Module.requestPointerlock(false, false); - } - }, - setCanvasMaximized: function setCanvasMaximized(enabled) { - if (typeof Module !== "undefined" && Module.setCanvasMaximized) { - Module.setCanvasMaximized(enabled); - } - }, - */ + postRun: [], setStatusVisible: function setStatusVisible(visible) { - statusElement.style.visibility = (visible?"visible":"hidden"); + statusElement.style.visibility = (visible ? "visible" : "hidden"); }, setStatus: function setStatus(text) { if (text.length === 0) { @@ -288,18 +208,13 @@ $GODOT_STYLE_INCLUDE window.onerror = function(event) { presentation.setStatus("Failure during start-up\nSee JavaScript console") }; - if ($GODOT_CONTROLS_ENABLED) { // controls enabled - document.getElementById("controls").style.visibility="visible"; - } - if ($GODOT_DEBUG_ENABLED) { // debugging enabled var outputRoot = document.getElementById("output-panel"); var outputElement = document.getElementById("output-scroll"); - var outputToggle = document.getElementById("output-toggle"); const maxOutputMessages = 400; presentation.setOutputVisible = function setOutputVisible(visible) { - outputRoot.style.display = (visible?"block":"none"); + outputRoot.style.display = (visible ? "block" : "none"); }; presentation.clearOutput = function clearOutput() { while (outputElement.firstChild) { @@ -308,7 +223,6 @@ $GODOT_STYLE_INCLUDE }; presentation.setOutputVisible(true); - outputToggle.style.display = "inline"; presentation.print = function print(text) { if (arguments.length > 1) { @@ -347,56 +261,59 @@ $GODOT_STYLE_INCLUDE })(); // Emscripten interface - var Module = { - TOTAL_MEMORY: $GODOT_TMEM, - postRun: (function() { - if (typeof Presentation !== "undefined" && Presentation.postRun instanceof Array) { - return Presentation.postRun; - } - })(), - print: function print(text) { - if (arguments.length > 1) { - text = Array.prototype.slice.call(arguments).join(" "); - } - console.log(text); - if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") { - Presentation.print(text); - } - }, - printErr: function printErr(text) { - if (arguments.length > 1) { - text = Array.prototype.slice.call(arguments).join(" "); - } - console.error(text); - if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") { - Presentation.print("**ERROR**:", text) - } - }, - canvas: (function() { - var canvas = document.getElementById("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. Plase reload the page."); e.preventDefault(); }, false); - return canvas; - - })(), - setStatus: function setStatus(text) { - var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); - var now = Date.now(); - if (m) { - if (now - Date.now() < 30) // if this is a progress update, skip it if too soon - return; - text = m[1]; - } - if (typeof Presentation !== "undefined" && typeof Presentation.setStatus == "function") { - Presentation.setStatus(text); + var Module = (function() { + const BASE_NAME = '$GODOT_BASE'; + var module = { + thisProgram: BASE_NAME, + wasmBinaryFile: BASE_NAME + '.wasm', + TOTAL_MEMORY: $GODOT_TMEM, + print: function print(text) { + if (arguments.length > 1) { + text = Array.prototype.slice.call(arguments).join(" "); + } + console.log(text); + if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") { + Presentation.print(text); + } + }, + printErr: function printErr(text) { + if (arguments.length > 1) { + text = Array.prototype.slice.call(arguments).join(" "); + } + console.error(text); + if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") { + Presentation.print("**ERROR**:", text) + } + }, + canvas: document.getElementById("canvas"), + setStatus: function setStatus(text) { + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); + var now = Date.now(); + if (m) { + if (now - Date.now() < 30) // if this is a progress update, skip it if too soon + return; + text = m[1]; + } + if (typeof Presentation !== "undefined" && typeof Presentation.setStatus == "function") { + Presentation.setStatus(text); + } } + }; + + // 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 + module.canvas.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false); + + if (typeof Presentation !== "undefined" && Presentation.postRun instanceof Array) { + module.postRun = Presentation.postRun; } - }; + + return module; + })(); if (!Presentation.isWebGL2Available()) { - Presentation.setStatus("WebGL2 appears to be unsupported in the current browser.\nPlease try updating or use a different browser."); + Presentation.setStatus("WebGL 2 appears to be unsupported.\nPlease update browser and drivers."); Presentation.preventLoading = true; } else { Presentation.setStatus("Downloading..."); -- cgit v1.3.1