forked from MapComplete/MapComplete
Feature: automatically detect missing WebGL in generated themes
This commit is contained in:
parent
df88fd2f71
commit
ea19cca387
1 changed files with 19 additions and 5 deletions
|
@ -4,9 +4,23 @@ import ThemeViewGUI from "./src/UI/ThemeViewGUI.svelte"
|
||||||
import LayoutConfig from "./src/Models/ThemeConfig/LayoutConfig";
|
import LayoutConfig from "./src/Models/ThemeConfig/LayoutConfig";
|
||||||
import MetaTagging from "./src/Logic/MetaTagging";
|
import MetaTagging from "./src/Logic/MetaTagging";
|
||||||
|
|
||||||
|
function webgl_support() {
|
||||||
|
try {
|
||||||
|
var canvas = document.createElement("canvas")
|
||||||
|
return (
|
||||||
|
!!window.WebGLRenderingContext &&
|
||||||
|
(canvas.getContext("webgl") || canvas.getContext("experimental-webgl"))
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MetaTagging.setThemeMetatagging(new ThemeMetaTagging())
|
if (!webgl_support()) {
|
||||||
const state = new ThemeViewState(new LayoutConfig(<any> layout))
|
new FixedUiElement("WebGL is not supported or not enabled. This is essential for MapComplete to function, please enable this.").SetClass("block alert").AttachTo("maindiv")
|
||||||
const main = new SvelteUIElement(ThemeViewGUI, { state })
|
}else{
|
||||||
main.AttachTo("maindiv")
|
MetaTagging.setThemeMetatagging(new ThemeMetaTagging())
|
||||||
|
const state = new ThemeViewState(new LayoutConfig(<any> layout))
|
||||||
|
const main = new SvelteUIElement(ThemeViewGUI, { state })
|
||||||
|
main.AttachTo("maindiv")
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue