From b183d216208f7109674b87ced1c5b65f320bb70b Mon Sep 17 00:00:00 2001 From: FalcoDJ <48579349+FalcoDJ@users.noreply.github.com> Date: Mon, 17 Jan 2022 00:13:08 -0500 Subject: [PATCH] Re-Added the fullscreen mod to basic_template --- WASM/basic_template.html | 48 +++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/WASM/basic_template.html b/WASM/basic_template.html index 1b2f8dd..ea7893b 100644 --- a/WASM/basic_template.html +++ b/WASM/basic_template.html @@ -20,21 +20,39 @@ canvas.emscripten { border: 0px none; background-color: black; } + function openFullscreen(elem) { + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.webkitRequestFullscreen) { /* Safari */ + elem.webkitRequestFullscreen(); + } else if (elem.msRequestFullscreen) { /* IE11 */ + elem.msRequestFullscreen(); + } + } + var Module = { + preRun: [], + postRun: [], + canvas: (function () { + const 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); + + canvas.addEventListener("keydown", (e) => { + if (e.key === "F11") { + openFullscreen(canvas); + } + }); + + return canvas; + })(), + }; +