forked from Kitware/itk-vtk-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkForWebGL.js
29 lines (28 loc) · 1.01 KB
/
checkForWebGL.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function checkForWebGL(container) {
const testCanvas = document.createElement('canvas')
const gl =
testCanvas.getContext('webgl') ||
testCanvas.getContext('experimental-webgl')
if (!(gl && gl instanceof WebGLRenderingContext)) {
const suggestion = document.createElement('p')
const preSuggestionText = document.createTextNode(
'WebGL could not be loaded. '
)
suggestion.appendChild(preSuggestionText)
const getWebGLA = document.createElement('a')
getWebGLA.setAttribute('href', 'http://get.webgl.org/troubleshooting')
const getWebGLAText = document.createTextNode(
'Try a different browser or video drivers for WebGL support.'
)
getWebGLA.appendChild(getWebGLAText)
suggestion.appendChild(getWebGLA)
const suggestionText = document.createTextNode(
' This is required to view interactive 3D visualizations.'
)
suggestion.appendChild(suggestionText)
container.appendChild(suggestion)
return false
}
return true
}
export default checkForWebGL