From acc5e196e988c83e1472ee261e9b17880061ac04 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 16 Sep 2023 02:55:13 +0200 Subject: [PATCH] Usability: give error message if WebGL is disabled --- src/index.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ebdabc56e..2a5b2600c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,9 +7,22 @@ import Combine from "./UI/Base/Combine" import { SubtleButton } from "./UI/Base/SubtleButton" import Svg from "./Svg" import { Utils } from "./Utils" - +function webgl_support() { + try { + var canvas = document.createElement("canvas") + return ( + !!window.WebGLRenderingContext && + (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")) + ) + } catch (e) { + return false + } +} // @ts-ignore try { + if (!webgl_support()) { + throw "WebGL is not supported or not enabled. This is essential for MapComplete to function, please enable this." + } DetermineLayout.GetLayout() .then((layout) => { const state = new ThemeViewState(layout)