Answer the question
In order to leave comments, you need to log in
How to check webGL and OpenGL support on the user side using JavaScript?
There is a site on which there is a 3D model working using the potree.js library. But on some devices (on some phones) it does not work, I suspect that due to the lack of webGL support. I found the modernizr library, which seems to check webGL support, but on a phone where the 3D model does not work, it shows that webGL is supported. Or am I checking something wrong?
How I checked support:
if (Modernizr.webgl) {
// WebGL supported
} else {
// WebGL not supported
}
Answer the question
In order to leave comments, you need to log in
function initWebGL(canvas){
var ctx = null;
for (name of ["webgl", "experimental-webgl"]){
try {
ctx = canvas.getContext(name);
} catch(error) {
console.log(name + ' not supported');
}
if (ctx) break;
}
return ctx;
}
let canvas = document.createElement('canvas');
const webGL = initWebGL(canvas);
if (webGL) // supported
else // not supported
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question